openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Copeland <t...@jotobjects.com>
Subject Re: Questions about classpath for OpenJPA
Date Thu, 26 Mar 2009 18:03:49 GMT
Cool!  That's very nice and it makes sense that starting a new JVM 
changes the class loader issue.  Notice the ant lib directory includes 
xercesImpl.jar (ant 1.7.1).  That also explains why the OpenJPA examples 
work because the examples build.xml has fork=yes.

Thanks for figuring that out.  Might help the next poor developer that 
hits this. :-)

- Paul

On 3/26/2009 9:05 AM, Rick Curtis wrote:
> Paul -
> I don't fully understand whats going on, but I found what is causing the problems. When
you launch your java application, you don't fork the JVM. Adding fork="yes" to <java classname="com.s...
> made the problems go away.
>
> If you google around, you'll find other people having this very problem.
>
> -Rick
>
>
> Hi Rick -
>
> What I think is happening is that most containers have the JAXP jar 
> files, but if you run it standalone from the console this issue shows 
> up.  There was an evolution from java 1.4 to 1.5 that changed how this 
> works.  There are a lot of posts if you google it, but I'm no clear on 
> the what the configuration trick is so you don't have to have xercesIml.jar.
>
> Attached is is a bare bones zip file.  Directions -
>
> - Add the jars from OpenJPA 1.2.1 to the lib directory and your JDBC driver
> - Create a database with the test_person table for class 
> com.steelhead.lg.test.Person
> - Edit src/java/META-INF/persistence.xml with your connection properties
> - type "ant TestJPA"
>
> This should work.  If you remove the two sysproperty elements from the 
> ant build.xml then it fails with 
> javax.xml.parsers.FactoryConfigurationError unless you add 
> xercesImpl.jar to the lib directory.
>
> I'm using Java SE 1.6.0_12.  I had the same problem with Java 1.5.0_05. 
> Also had the same issue with OpenJPA 1.2.0.
>
> I'm using Postgres 8.2.13 but I had the same problem with MySql 1.31 so 
> probably the database does not matter.
>
> As I said, the OpenJPA hellojpa example works for me without 
> xercesImpl.jar so that adds to the mystery.
>
> - Paul
>
> On 3/23/2009 11:42 AM, Rick Curtis wrote:
>   
>> Paul-
>> <br>If you still are unable to figure out what's going on, feel free to zip
up your simple test app and I'll take a look at it.
>> <br><br>-Rick
>> <br><blockquote class="quote light-black dark-border-color"><div class="quote
light-border-color">
>> <div class="quote-author" style="font-weight: bold;">Paul Copeland wrote:</div>
>> <div class="quote-message shrinkable-quote">Hi Rick -
>> <br><br>Thanks. As I mentioned the openjpa example hellojpa also works
for me 
>> <br>WITHOUT the xerces jar. &nbsp;But my very simple test app does not
work with 
>> <br>xerces. &nbsp;However, I found out that if I add these two properties
to my 
>> <br>runtime ant task then I do NOT need the xerces jar.
>> <br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&lt;sysproperty key=&quot;javax.xml.parsers.SAXParserFactory&quot; 
>> <br>value=&quot;com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl&quot;/&gt;
>> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;sysproperty
key=&quot;javax.xml.parsers.DocumentBuilderFactory&quot; 
>> <br>value=&quot;com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl&quot;/&gt;
>> <br><br>There is some classloader subtlety that I don't fully understand
here.
>> <br><br>- Paul
>> <br><br>On 3/23/2009 8:17 AM, Rick Curtis wrote:
>> <br>&gt; Paul -
>> <br>&gt; I quickly looked through the javadoc for the 
>> <br>&gt; http://java.sun.com/javase/6/docs/api/javax/xml/parsers/SAXParserFactory.html#newInstance(
)
>> <br>&gt; SAXParserFactory &nbsp;and I'm thinking that your problem
is something specific
>> <br>&gt; to your environment.? I was able to run the examples on my box
without
>> <br>&gt; adding xercesImpl.jar to my classpath. With my JSE1.6 install,
>> <br>&gt; SAXParserFactoryImpl is found in the [java_home]\lib\rt.jar.
>> <br>&gt;
>> <br>&gt; -Rick
>> <br>&gt;
>> <br>&gt; Paul Copeland wrote:
>> <br>&gt; &nbsp; 
>> <br>&gt;&gt; More info on this. &nbsp;I upgraded to Java SE 1.6.0_12
and I still need the 
>> <br>&gt;&gt; same jars (including xerces).
>> <br>&gt;&gt;
>> <br>&gt;&gt; Using OpenJPA 1.2 -
>> <br>&gt;&gt;
>> <br>&gt;&gt; 1) Only two jars are needed to compile my (very simple)
test application -
>> <br>&gt;&gt;
>> <br>&gt;&gt; - openjpa-1.2.0.jar
>> <br>&gt;&gt; - geronimo-jta_1.1_spec-1.1.jar
>> <br>&gt;&gt;
>> <br>&gt;&gt; 2) At runtime (standalone, not in a container) I also
need these jars
>> <br>&gt;&gt; (plus JDBC driver of course) -
>> <br>&gt;&gt;
>> <br>&gt;&gt; - serp-1.13.1.jar
>> <br>&gt;&gt; - geronimo-jta_1.1_spec-1.1.jar
>> <br>&gt;&gt; - commons-collections-3.2.jar
>> <br>&gt;&gt; - commons-lang-2.1.jar
>> <br>&gt;&gt; - xercesImpl.jar
>> <br>&gt;&gt;
>> <br>&gt;&gt; 3) When I build and run the apache-openjpa-1.2.0/examples/hellojpa

>> <br>&gt;&gt; (Derby example) I do NOT need xerces.
>> <br>&gt;&gt; ....
>> <br>&gt;&gt;
>> <br>&gt;&gt; &nbsp; &nbsp; 
>> <br>&gt;
>> <br>&gt; &nbsp; 
>> <br></div>
>> </div></blockquote>
>>
>>   
>>     
>
>  
>
>
>   


Mime
View raw message