1 2 Previous Next 19 Replies Latest reply: Jan 5, 2012 6:59 AM by stephan972 RSS

JBoss 5.1.0.GA, JPA 2.0, and EClipseLink 2.0

Dale Highfill Newbie

I have been working on an issue getting JBoss, JPS, and EClipseLink all working together for several days now.  I believe it's in the class loading of the JPA through JBoss, but I just can't figure it out.

 

I have the development environment all setup in Eclipse Gannymede and I can start up the server and all works fine.  I do however have to put the WebContent directory of my Eclipse Project on the launch configuration of the startup of the JBoss Server in Eclise so that it can find my META-INF\persistence.xml file.  This is using RESOURCE-LOCAL as the transaction type.

 

Now I'm trying to build team testing server, obviously outside of Eclipse, but I cannot get the environment to run.  I'll have errors like there is no @Id defined for the entity class when that is clearly not the case because it runs fine through JUnit.  Sometimes it just depends on where I put the META-INF directory and what exception gets thrown.

 

Can one run these three technologies together?  I would assume so?

 

I'm attaching a zip file of my deployed Ear file from Eclipse that runs fine through Eclipse (with the WebContent added to the startup) but will not run by starting up JBoss with run.bat.  I've tried passing the same VM args Eclipse does, but still no dice.  In this Ear, I've also taken the META-INF folder and moved it under the WEB-INF\classes directory and I a different set of exceptions.

 

I can attach the Eclipse Workspace as well if that would help.

 

Is there something that I'm doing wrong that is very obvious?  Is there something special in the JBoss configuration that I need to do to support EclipseLink or JPA 2.0 or get the class loading to occur properly.

 

I'm stuck and cannot proceed further as I've exaushted all my resources on this one.  Normally I can figure things out on my own or find another post with the answer, but I'm really stumped this time.

 

It's been a couple of days and I have a lot of reviews, but still responses.  I thought I'd add a few of the exceptions that are thrown by the JPA to see if it may better describe what is going on.  I'm also going to attach the Eclipse workspace to see if there's something obvious.  After I start the server, I run the com.dstsystems.services.ProductSponsorTest from the JUnit source directory.  I realize that anyone trying to test this will not have the schema for the database and can't run the tests, but I'm hoping that something is obvious in what I'm doing wrong.

 

01-11-2010 - With everything running in Eclipse and the WebContent directory added to my "Open Launch Configuration" for the JBoss Server in Eclipse. I open a DOS window and run JBoss from the installation directory and type run.bat.

 

This results in the following exception.

     Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named RICCDB

 

I'm pretty confident this is because the META-INF directory is not included in the classpath running from the DOS window.  I've added the WebContent directory to the classpath in Eclipse and I don't get this error.  So I then moved the take the META-INF directory from the SampleService.war to the SampleService.war\WEB-INF\classes directory.  I restart the server.

 

This results in the following exception.

     java.lang.RuntimeException: Specification violation [EJB3 JPA 6.2.1.2] - You have not defined a non-jta-data-source for a RESOURCE_LOCAL enabled persistence context named: RICCDB

 

So I then add the following two lines to the persistence.xml

     <jta-data-source>java:RICCDB</jta-data-source>
     <non-jta-data-source>java:RICCDB</non-jta-data-source>

 

This change results in the following exception

     Exception Description: Entity class [class com.dstsystems.entity.ProductSponsorEntity] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.

 

I believe this is where the ProductSponsorEntity cannot be found in the classpath, because I can get the same error from my JUnit tests if I specify the wrong package name for a class in the classes element of the persistence.xml.

 

Any help would be greatly appreciated.

  • 1. Re: JBoss 5.1.0.GA, JPA 2.0, and EClipseLink 2.0
    Dale Highfill Newbie

    I'm still digging around through message posts and I stumbled across this one which indicates some classpath issues with JBoss 5.1.0.GA and using isoloate="true" which is one of the many exceptions I've recevied on the configuration changes.  A co-worker has a different application running JPA 2.0 EclipseLink 2.0 and JBoss 4.2.  I really don't want to install previous version, but is the 5.1.0 version of JBoss causing the issue here.  The post recommends.

     

    http://community.jboss.org/thread/2282?tstart=0

     

    This bug post tells me I need to install the 5.1.0.CR1 or JBossAS-6.0.M3

    https://jira.jboss.org/jira/browse/JBAS-6600

     

    Would that help?

  • 2. Re: JBoss 5.1.0.GA, JPA 2.0, and EClipseLink 2.0
    jaikiran pai Master

    Sorry, I read your first post in this thread (more than once), but am not sure i understand what issue you are running into and how that's related to the JIRA you pointed out.  Maybe they are related, but i am not sure   So can you please explain (again) what the issue is? Let's leave out the IDE from the equation. Try deploying your application manually and start the server outside of the IDE. What error do you run into? Post the entire exception stacktrace and also more details about your application packaging (some of which you already posted, but was a bit confusing with the IDE in picture).

  • 3. Re: JBoss 5.1.0.GA, JPA 2.0, and EClipseLink 2.0
    jaikiran pai Master

    dghighfill wrote:

     


     

    This bug post tells me I need to install the 5.1.0.CR1 or JBossAS-6.0.M3

    https://jira.jboss.org/jira/browse/JBAS-6600

     

    Would that help?

    5.1.0.GA (which you are already using) is a version released after 5.1.0.CR1. So any bug fixes in 5.1.0.CR1 will also be available in 5.1.0.GA. So you do not have to downgrade to 5.1.0.CR1 from 5.1.0.GA.

  • 4. Re: JBoss 5.1.0.GA, JPA 2.0, and EClipseLink 2.0
    Dale Highfill Newbie

    Thanks for responding.  I figured that, but 5.1.0.GA wasn't listed so I just wanted to be sure.  The log message below is from starting outside of the IDE with run.bat

     

    Attached is a current version of the deployed ear, the log file for the server startup, as well as the Java Source for the class in question.

     

    Working through this yesterday, I've made the following changes to the server configuration based on someone else's recomendation, but it still hasn't resolved anything yet.

     

    [jboss-home]/server/default/deploy/conf/jobs-service.xml

         Make sure that isolated is set to true.
          <attribute name="CallByValue">true</attribute>

    [jboss-home]/server/default/deployers/ear-deployer-jboss-beans.xml

         Make sure that isolated is set to true.

          <property name="isolated">true</property>
          <property name="callByValue">true</property>

     

    I also added a jboss-app.xml according to the bug post, but it looks like I can probably remove this.  It didn't resolve anything.

     

    <jboss-app>
    <loader-repository>
      somename:someothername=UltimatelyAnUniqueObjectNameTwo
      <loader-repository-config>
       java2ParentDelegation=false
       </loader-repository-config>
    </loader-repository>
    </jboss-app>

  • 5. Re: JBoss 5.1.0.GA, JPA 2.0, and EClipseLink 2.0
    Dale Highfill Newbie

    I can eliminate the no Primary Key error by commentting out my entity in the orm.xml as shown below.

    <!-- <entity class="com.dstsystems.entity.ProductSponsorEntity"/> -->

     

    However, based on what I've read, I should be able to do this.  If it's there it complains that it doesn't have a primary key.  If I add the id element, I get another error but I haven't been down that path in awhile. I can post that if need be.

     

    But then when I run it now, I get a malformed url exception.  I've tried a number of different things in the persisence.xml, but I'm not sure what URL its referring to.

     

    I've also changed the peristence.xml file to use the DefaultDS.  Could it be that my persistence unit and jndi name of the database is the same (i.e. RICCDB)

     

    Lastly, I'm attaching a new db2-ds.xml file.  I made a slight change and it still seems to be registerting correctly.

  • 6. Re: JBoss 5.1.0.GA, JPA 2.0, and EClipseLink 2.0
    jaikiran pai Master

    I was able to deploy the ear you attached, successfully (on 6.0.0.M1, haven't tried 5.1.0) by following the steps below:

     

    1) Delete the javax.persistence_2.0.0.v200911271158.jar from the application packaging. JBoss already ships the javax.persistence.* classes.

    2) Edit the orm.xml to comment out the entity class mapping (which you already mentioned in your earlier post)

    3) Move those db2jcc.jar, db2jcc_license_cu.jar and eclipselink.jar to .ear/lib folder.

  • 7. Re: JBoss 5.1.0.GA, JPA 2.0, and EClipseLink 2.0
    Dale Highfill Newbie

    By commenting out the entity in the orm, it will deploy correctly and will remove the @PrimaryKey issue as I've noted above, but will not run.  I haven't tried with JBoss 6, but with 5.1.0 I get the Malformed URL exception when parsing the persistence.xml.  Please see the previous stack traces in the server.log file I attached.  Aren't I able to have an entity in the orm.xml file.  I'm certain I've read this is where you can override what the annotated java class may have.  If I can't have an orm.xml entity, then this indeed seems to be an issue.

     

    Don't I have to include the javax.persistence_2.0.0.v200911271158.jar file since this is EclipseLink's implementation class of the PersistenceProvider?  I believe that I'll get a class not found exception for PersistenceProvide if I don't include the javax.persistence_2.0.0.v200911271158.jar file.

     

    Also can you explain why the .jars need to be in the ear/lib directory.  Are they not getting picked up at the root.  I'll also need to change my manifest.mf right or will they get picked up for free.

     

    Here's just a basic question on JBoss.  What if any configuration files needs to change and with what properties to support EclipseLink?

     

    One other thing that is also required is that I have installed the JaxWS components for JBoss.  I'm not sure if that has anything to do with my issue but I'd thought I throw it out there.

  • 8. Re: JBoss 5.1.0.GA, JPA 2.0, and EClipseLink 2.0
    jaikiran pai Master

    dghighfill wrote:

     

    Aren't I able to have an entity in the orm.xml file.  I'm certain I've read this is where you can override what the annotated java class may have.  If I can't have an orm.xml entity, then this indeed seems to be an issue.

     


    That's something you will have to ask in the EclipseLink forum

     

    dghighfill wrote:

     

     

     

    Don't I have to include the javax.persistence_2.0.0.v200911271158.jar file since this is EclipseLink's implementation class of the PersistenceProvider?  I believe that I'll get a class not found exception for PersistenceProvide if I don't include the javax.persistence_2.0.0.v200911271158.jar file.

     


    From what i see, it just contains javax.persistence.* classes and not EclipseLink implementation classes

     

    dghighfill wrote:

     

    Here's just a basic question on JBoss.  What if any configuration files needs to change and with what properties to support EclipseLink?

     

    Not sure i understand this question. Can you elaborate?

     

    dghighfill wrote:

     

    One other thing that is also required is that I have installed the JaxWS components for JBoss.  I'm not sure if that has anything to do with my issue but I'd thought I throw it out there.

    I don't think that's related.

  • 9. Re: JBoss 5.1.0.GA, JPA 2.0, and EClipseLink 2.0
    Dale Highfill Newbie

    We are using JPA 2.0 functionality which is in the javax.persistence_2.0.0.v200911271158.jar (i.e. TypedQuery) so that's the reason for the inclusion.  Does JBoss 5.1.0 provided JPA 2.0 functionality?

     

    My question was around what all xml configuration files need to change to enable EclispeLink 2.0 to work in JBoss.  I've went down a number of different rabbit trails from other posts, none of which seemed to work.  I want to know if there is any JBoss configuration that must be changed in order for EclipseLink to work.

     

    I've read post about having configuring different class loaders, using different XML parsers, but those seem to be trial and experiments on different version of JBoss or JPA and never with the specific conifguration I have JBoss 5.1, JPA 2.0 and EclipseLink 2.0.

     

    I'm also reviewing this link -> http://www.jboss.org/file-access/default/members/jbossejb3/freezone/docs/reference/1.0.7/html/entityconfig.html

     

    We are unable to put the / (i.e. forward slash) in the jta datasource here.  Could this be the cause of the malformed URL exception?  This datasource is what's in the db2-ds.xml file correct?  It shouldn't be dependent on an ear or packaging location should it?

     

    <jta-data-source>java:/DefaultDS</jta-data-source>

  • 10. Re: JBoss 5.1.0.GA, JPA 2.0, and EClipseLink 2.0
    jaikiran pai Master

    dghighfill wrote:

     

    We are using JPA 2.0 functionality which is in the javax.persistence_2.0.0.v200911271158.jar (i.e. TypedQuery) so that's the reason for the inclusion.  Does JBoss 5.1.0 provided JPA 2.0 functionality?

     

    Ah ok! No JBoss AS 5.1.0 does not have JPA2.0. However, JBoss AS 6.0.0.M1 has the initial JPA 2.0 functionality.

     

    dghighfill wrote:

     

     

     

    My question was around what all xml configuration files need to change to enable EclispeLink 2.0 to work in JBoss.  I've went down a number of different rabbit trails from other posts, none of which seemed to work.  I want to know if there is any JBoss configuration that must be changed in order for EclipseLink to work.

    Just the persistence.xml file (and optionally orm.xml) of your application should be enough.

     

    So your goal is to enable JPA 2.0 implementation of EclipseLink in AS 5.1.0? And any chance of trying this against 6.0.0.M1?
  • 11. Re: JBoss 5.1.0.GA, JPA 2.0, and EClipseLink 2.0
    Dale Highfill Newbie

    That was my next step to either go 4.2 or 6.0.  I'll give it a try and start the download process.  I have one other peer trying to get it running on 5.1 but still has some deployment to go through.

     

    Do I need to add this configuration to my persistence.xml.  This is to reference from Globabl JNDI.  Would this enable me to add the forward slash in the JTA datasource?

     

    <property name="jboss.entity.manager.jndi.name" value="java:/Manager1"/>
    <property name="jboss.entity.manager.factory.jndi.name" value="java:/Manager1Factory

  • 12. Re: JBoss 5.1.0.GA, JPA 2.0, and EClipseLink 2.0
    jaikiran pai Master

    dghighfill wrote:

     


    Do I need to add this configuration to my persistence.xml.  This is to reference from Globabl JNDI.  Would this enable me to add the forward slash in the JTA datasource?

     

    <property name="jboss.entity.manager.jndi.name" value="java:/Manager1"/>
    <property name="jboss.entity.manager.factory.jndi.name" value="java:/Manager1Factory

    forward slash? Do you mean the MalformedURLException (which i looked at now):

     

    vfsfile:/C:/Program%20Files/JBoss/jboss-5.1.0.GA/server/default/deploy/SampleServiceEAR.ear/
    Internal Exception: java.net.MalformedURLException
        at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionProcessingPersistenceXML(PersistenceUnitLoadingException.java:117)
        at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processPersistenceXML(PersistenceUnitProcessor.java:444)
        at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processPersistenceArchive(PersistenceUnitProcessor.java:401)
        at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.getPersistenceUnits(PersistenceUnitProcessor.java:310)
        at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfoInArchive(JPAInitializer.java:149)
        at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfoInArchives(JPAInitializer.java:136)
        at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfo(JPAInitializer.java:125)
        at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:98)
        ... 40 more
    Caused by: java.net.MalformedURLException
        at java.net.URL.<init>(URL.java:601)
        at java.net.URL.<init>(URL.java:464)
        at java.net.URL.<init>(URL.java:413)
        at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
        at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
        at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processPersistenceXML(PersistenceUnitProcessor.java:442)
    

     

    Hmm, this one is bad. Starting AS-5, the concept of Virtual File System (VFS) was introduced. The deployments in AS have a VFS protocol URL (ex: vfsfile:/ which use see in the log). The bad part is, no one other than the AS knows about this protocol and can lead to exceptions like this. The EclipseLink isn't aware of this VFS thing. I don't know of any way, other than changing the EclipseLink implementation to get past this.

  • 13. Re: JBoss 5.1.0.GA, JPA 2.0, and EClipseLink 2.0
    Dale Highfill Newbie

    Well JBoss 6.0 M1 won't start due to my JDK version.  Startup yields a whole host of Bad Version Numbers and if I remember correctly, that's due to different versions of the JDK used for compilation vs. the runtime.  I'm tied to JDK 5 and cannot use 6 yet anyway.

     

    Yesterday, I went back to how I was getting a reference to the Entity Manager.  I was still using my resource local approach for JSE and this may have been the cause of the malformed url exception, but I'm not sure.  What I'm finding now that if I use @PersistentUnit or get the entity manager by JNDI name, its always null.  Here's some code.

     

    What I don't understand is what's the point of the persistence unit name if I have to give the JNDI name of the datasource.  This seems wrong to me and may be part of the issues, but no matter what name I give the persistence unit, it either can't be found

     

     

    <persistence-unit name="RICCPU" transaction-type="JTA">

     

       <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

     

       <jta-data-source>java:RICCDB</jta-data-source>

     

    My db2-ds.xml file looks like this

    <datasources>
        <local-tx-datasource>
            <jndi-name>RICCDB</jndi-name>
            <connection-url>jdbc:db2://wdc-aixtmpdb-02:50000/RICTST01</connection-url>
            <driver-class>com.ibm.db2.jcc.DB2Driver</driver-class>
            <user-name>user</user-name>
            <password>pwd</password>
            <min-pool-size>0</min-pool-size>
            <metadata>
                <type-mapping>DB2</type-mapping>
            </metadata>
        </local-tx-datasource>
    </datasources>

     

    When the server starts, the db2 datasource registers the JNDI name of:

    13:56:50,656 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=RICCDB' to JNDI name 'java:RICCDB'
    13:56:51,296 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS'
    13:56:52,046 INFO  [ServerPeer] JBoss Messaging 1.4.3.GA server [0] started

     

    I don't see anything else in the server startup log that has to do with the JNDI name of the Persistence Unit.  Should I? This may be my problem.

     

    Here's the code I'm using to lookup up the Persistence Unit.

     

    final

     

     

     

         String emname = "RICCPU";

                         entityManager = ( EntityManager ) initialContext.lookup( emname );

     

    I've tried to lookup the Entity Manager by RICCPU (which is what I think it should be)

    javax.naming.NameNotFoundException: RICCPU not bound

     

    I've tried to lookup the Entity Manager by java:RICCPU which appears to be the same message but with the java off the front.

    javax.naming.NameNotFoundException: RICCPU not bound

     

    I've tried to lookup the Entity Manager by java:/RICCPU

    javax.naming.NameNotFoundException: RICCPU not bound

     

    And finally the actually JTA JNDI name java:RICCDB Class cast exception and I would expect this.  Its the datasource and not the Persistence Unit JNDI name.

    java.lang.ClassCastException: org.jboss.resource.adapter.jdbc.WrapperDataSource

     

  • 14. Re: JBoss 5.1.0.GA, JPA 2.0, and EClipseLink 2.0
    jaikiran pai Master

    dghighfill wrote:

     

    Well JBoss 6.0 M1 won't start due to my JDK version.  Startup yields a whole host of Bad Version Numbers and if I remember correctly, that's due to different versions of the JDK used for compilation vs. the runtime.  I'm tied to JDK 5 and cannot use 6 yet anyway.

    Yes JBoss AS 6.0 M1 requires JDK/JRE 6

     

    dghighfill wrote:

     


     

    What I don't understand is what's the point of the persistence unit name if I have to give the JNDI name of the datasource.

    Both are totally different things. The persistence unit can interact with the database through a datasource. The datasource is usually bound in JNDI. So for accessing the datasource, the persistence unit needs to know the *jndi-name* of the datasource. This configuration is done in the persistence.xml file through the jta-data-source element.

     

    Now each persistence unit will have a *name*. This name is in no way related to the jndi-name of the datasource. Applications interact with the EntityManager (injected through @PersistenceContext or created through an EntityManagerFactory) for DB operations. Applications can inject a @PersistenceContext using the "unitName" attribute. The "unitName" points to the name of the persistence unit as configured in persistence.xml. So in your example, the persistence unit is named  RICCPU. So the injection would be done as follows:

     

    @PersistenceContext(unitName="RICCPU")
    private EntityManager em;
    

     

     

    By default, (unlike datasources) persistence units are _not_ bound to the JNDI. But you can bind them to JNDI by configuring a couple of properties in the persistence.xml. Follow the tutorial here

     

    As i mentioned, binding the entity manager or the entity manager factory to the jndi is optional. However, if you have bound it to JNDI, then you can use those JNDI names to lookup the entity manager and/or the entity manager factory.

1 2 Previous Next