1 2 Previous Next 15 Replies Latest reply: Jun 23, 2012 10:05 AM by Craig Ringer RSS

How to use eclipselink in AS 7

Ralph Soika Newbie

Hi,

I am runnign JBoss AS 7 7.0.2 trying to deploy a web application which is using JPA and the Eclipse link persistence provider.

During deployment I got the following error message:

 

 

12:37:50,824 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.unit."imixs-workflow-web-sample-0.0.4-SNAPSHOT.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."imixs-workflow-web-sample-0.0.4-SNAPSHOT.war".INSTALL: Failed to process phase INSTALL of deployment "imixs-workflow-web-sample-0.0.4-SNAPSHOT.war"
          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]
          at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]
Caused by: javax.persistence.PersistenceException: PersistenceProvider 'org.eclipse.persistence.jpa.PersistenceProvider' not found
          at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.lookupProvider(PersistenceUnitDeploymentProcessor.java:491)
          at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.addPuService(PersistenceUnitDeploymentProcessor.java:245)
          at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.handleWarDeployment(PersistenceUnitDeploymentProcessor.java:170)
          at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deploy(PersistenceUnitDeploymentProcessor.java:100)
          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
          ... 5 more

 

my persistence.xml looks like this:

 

 

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
          <!-- eclipselink -->
          <persistence-unit name="org.imixs.workflow.jee.jpa" transaction-type="JTA"> 
                    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
                    <jta-data-source>jdbc/workflow-db</jta-data-source>
                    <jar-file>lib/imixs-workflow-engine-3.0.1-SNAPSHOT.jar</jar-file>
                    <properties>
                              <property name="eclipselink.ddl-generation"
                                        value="create-tables" />
                              <property name="eclipselink.logging.level" value="INFO"/>
                    </properties> 
          </persistence-unit>
  
</persistence>

 

I have installed the eclipselink.jar (containg the class org.eclipse.persistence.jpa.PersistenceProvider) into the folder

[JBOSS_INSTALL]/standalone/lib

also into

 

[JBOSS_INSTALL]/domain/lib

 

But this did not solve the PersistenceException.

 

Can anybody help me how to configure JBoss AS 7 to work with eclipselink?

 

Thanks for any help

 

=====
Ralph

  • 1. Re: How to use eclipselink in AS 7
    Ralph Soika Newbie

    Now I figuread out what was wrong in my setup.

    There is no need to add eclipselink int any lib folder

     

    My persistence.xml file was wrong. The correct persistence.xml file should look like this - than everything works fine

     

     

    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
      <persistence-unit name="org.imixs.workflow.jee.jpa" transaction-type="JTA">
        <jta-data-source>jdbc/workflow-db</jta-data-source>
        <jar-file>lib/imixs-workflow-engine-3.0.1-SNAPSHOT.jar</jar-file>
        <properties>
          <property name="eclipselink.ddl-generation" value="create-tables"/>
          <property name="eclipselink.cache.size.default" value="10000"/>
          <property name="eclipselink.cache.type.default" value="Soft"/>
        </properties>
      </persistence-unit>
    </persistence>
    

     

    Also a usefull link to add mysql support was

     

    http://community.jboss.org/wiki/DataSourceConfigurationInAS7

  • 2. Re: How to use eclipselink in AS 7
    Ralph Soika Newbie

    But it seems still not to work :-(

    No tables are created. I got the following error message:

     

    ....

    16:58:51,515 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-3) SQL Error: 1146, SQLState: 42S02

    16:58:51,525 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-3) Table 'workflow_db.EntityIndex' doesn't exist

    16:58:51,526 INFO  [org.hibernate.event.internal.DefaultLoadEventListener] (http--127.0.0.1-8080-3) HHH00327:Error performing load command : org.hibernate.exception.SQLGrammarException: Table 'workflow_db.EntityIndex' doesn't exist

    16:58:51,527 ERROR [org.jboss.as.ejb3.tx.CMTTxInterceptor] (http--127.0.0.1-8080-3) javax.ejb.EJBTransactionRolledbackException: org.hibernate.exception.SQLGrammarException: Table 'workflow_db.EntityIndex' doesn't exist

    16:58:51,527 INFO  [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (http--127.0.0.1-8080-3) HHH00106:Forcing container resource cleanup on transaction completion

    16:58:51,528 ERROR [stderr] (http--127.0.0.1-8080-3) javax.ejb.EJBException: java.lang.IllegalStateException: Failed to construct component instance

    16

    .....

  • 3. Re: How to use eclipselink in AS 7
    Matthias Reining Newbie

    Hello Ralph,

    have you meanwhile found a solution for your problem?

    I'm very interested!

     

    Thanks, matthias

  • 4. Re: How to use eclipselink in AS 7
    Ralph Soika Newbie

    Hi,

    no I am also still searching for an answer.

     

    ===
    Ralph

  • 5. Re: How to use eclipselink in AS 7
    john archer Newbie

    any update here Ralph?

  • 6. Re: How to use eclipselink in AS 7
    Scott Marlow Master

    John,

     

    One of the issues is that EclipseLink doesn't know how to lookup the AS 7 transaction manager, which is addressed by bug 365704.  The fix for that is checked into EclipseLink trunk (2.4) and 2.3.3.  Without this change, EclipseLink will not be able to determine that an active JTA transaction is available.  I'm not sure why EclipseLink isn't using the TransactionSynchronizationRegistry yet.

     

    There are nightly builds of both EclipseLink 2.4 + 2.3.3 here

     

    If there are other EclipseLink integration issues, they should be reported and fixed.

     

    Scott

  • 7. Re: How to use eclipselink in AS 7
    Scott Marlow Master

    Has anyone tried to grab the EclipseLink jars (either 2.4 or 2.3.3) from the EclipseLink nightly build site and tried to use them?  If someone could explain which jars are needed, that might help others test with EclipseLink.

     

    Scott

  • 8. Re: How to use eclipselink in AS 7
    Rich DiCroce Novice

    I just gave the 2.3.3 nightly from May 19th a try. Based on information I found here and here, I was able to get JBoss to try to use EclipseLink, but as reported in the thread that the first link points to, JBoss just hangs for some reason. I was debugging in Eclipse, so I suspended JBoss and examined the threads. I found this:

     

    Thread [MSC service thread 1-11] (Suspended)

    Object.wait(long) line: not available [native method]

    Module(Object).wait() line: 503 [local variables unavailable]

    Module.getPaths(boolean) line: 1141

    Module.getPathsUnchecked(boolean) line: 1164

    Module.getResources(String, boolean) line: 586

    ModuleClassLoader.findResources(String, boolean) line: 489

    ModuleClassLoader(ConcurrentClassLoader).getResources(String) line: 288

    ServiceLoader$LazyIterator.hasNext() line: not available

    ServiceLoader$1.hasNext() line: not available

    PersistenceProviderLoader.loadProviderModuleByName(String) line: 63

    PersistenceUnitDeploymentProcessor.lookupProvider(PersistenceUnitMetadata) line: 537

    PersistenceUnitDeploymentProcessor.addPuService(DeploymentPhaseContext, ArrayList<PersistenceUnitMetadataHolder>) line: 279

    PersistenceUnitDeploymentProcessor.handleJarDeployment(DeploymentPhaseContext) line: 145

    PersistenceUnitDeploymentProcessor.deploy(DeploymentPhaseContext) line: 120

    DeploymentUnitPhaseService<T>.start(StartContext) line: 113

    ServiceControllerImpl$StartTask.startService(Service<? extends S>, StartContext) line: 1811

    ServiceControllerImpl$StartTask.run() line: 1746

    ServiceContainerImpl$ContainerExecutor(ThreadPoolExecutor).runWorker(ThreadPoolExecutor$Worker) line: not available

    ThreadPoolExecutor$Worker.run() line: not available

    ServiceContainerImpl$ServiceThread(Thread).run() line: not available

     

     

    Thread [MSC service thread 1-12] (Suspended)

    Object.wait(long) line: not available [native method]

    Module(Object).wait() line: 503

    Module.getPaths(boolean) line: 1141

    Module.getPathsUnchecked(boolean) line: 1164

    Module.getResources(String, boolean) line: 586

    ModuleClassLoader.findResources(String, boolean) line: 489

    ModuleClassLoader(ConcurrentClassLoader).getResources(String) line: 288

    ServiceLoader$LazyIterator.hasNext() line: not available

    ServiceLoader$1.hasNext() line: not available

    ServletContainerInitializerDeploymentProcessor.deploy(DeploymentPhaseContext) line: 107

    DeploymentUnitPhaseService<T>.start(StartContext) line: 113

    ServiceControllerImpl$StartTask.startService(Service<? extends S>, StartContext) line: 1811

    ServiceControllerImpl$StartTask.run() line: 1746

    ServiceContainerImpl$ContainerExecutor(ThreadPoolExecutor).runWorker(ThreadPoolExecutor$Worker) line: not available

    ThreadPoolExecutor$Worker.run() line: not available

    ServiceContainerImpl$ServiceThread(Thread).run() line: not available

     

    Clearly JBoss is waiting for something to happen, but I have no idea what. Posting these stack traces here in the hope that someone who knows more about JBoss's internals can figure out what's going on.

  • 9. Re: How to use eclipselink in AS 7
    Rich DiCroce Novice

    Okay, I'm not quite sure what I did, but somehow I got past this hang! I've gotten EclipseLink fully working in my JBoss install and documented everything I found out here. Feel free to add to it!

  • 10. Re: How to use eclipselink in AS 7
    Scott Marlow Master

    Thanks for the "how to use EclipseLink" documentation!  That is a great start.

     

    You might be able to remove the "<property name="jboss.as.jpa.providerModule" value="org.eclipse.persistence" from the persistence.xml (AS7 will notice that org.eclipse.persistence.jpa.PersistenceProvider is being used and look for module "org.eclipse.persistence" based on an internal mapping).

     

    You also need to explicitly list all of your entity classes, if you are not currently doing that. EclipseLink seems unable to auto-detect entity classes, at least in an exploded deployment; from reading the EclipseLink documentation, it may work in a normal deployment, but this is unconfirmed.

    Does EclipseLink have any TRACE logging that could be enabled for its code that scans for entity classes?  EclipseLink is most likely not working well with the virtual file system (VFS) that deployments are in.  Here is an example of how we solved this in AS7/Hibernate integration code.  Perhaps a custom version of org.eclipse.persistence.jpa.ArchiveFactory would help (could be a blend of the above AS7/Hibernate integration code and org.eclipse.persistence.internal.jpa.deployment.ArchiveFactoryImpl).  I came across org.eclipse.persistence.jpa.ArchiveFactory in a google search and don't really know if it is intended to solve the "EclipseLink can't find entity classes on VFS" problem.

     

    Scott

  • 11. Re: How to use eclipselink in AS 7
    Rich DiCroce Novice

    You might be able to remove the "<property name="jboss.as.jpa.providerModule" value="org.eclipse.persistence" from the persistence.xml (AS7 will notice that org.eclipse.persistence.jpa.PersistenceProvider is being used and look for module "org.eclipse.persistence" based on an internal mapping).

    Good catch, I've confirmed this is not needed and will update the article accordingly.

     

    Does EclipseLink have any TRACE logging that could be enabled for its code that scans for entity classes?  EclipseLink is most likely not working well with the virtual file system (VFS) that deployments are in.  Here is an example of how we solved this in AS7/Hibernate integration code.  Perhaps a custom version of org.eclipse.persistence.jpa.ArchiveFactory would help (could be a blend of the above AS7/Hibernate integration code and org.eclipse.persistence.internal.jpa.deployment.ArchiveFactoryImpl).  I came across org.eclipse.persistence.jpa.ArchiveFactory in a google search and don't really know if it is intended to solve the "EclipseLink can't find entity classes on VFS" problem.

    EclipseLink's logging is, unfortunately, not nearly as thorough as Hibernate's. Even when I enable logging at the lowest level, I get no information about what EclipseLink is trying to do to find entities. But after looking at the EclipseLink source, I agree custom implementations of those would probably solve the issue. The default ArchiveFactoryImpl checks the root URL protocol (which presumably is VFS in this case) and defaults to a URLArchive if it can't identify it as a file or JAR. The URLArchive class, in turn, always returns no file entries. So we would need a VFSArchive class and a custom ArchiveFactory class, by the looks of it. I don't have time to do that right now; I might get to it eventually, but if anyone else wants to take a stab at it, feel free.

  • 12. Re: How to use eclipselink in AS 7
    john archer Newbie

    Do you know if this would be able to support proxy users on AS 7 with EL 2.4?  Or is there some type of datasource unwrapping capability?

  • 13. Re: How to use eclipselink in AS 7
    Rich DiCroce Novice

    Not sure what you mean by "proxy users". I can tell you that I didn't need to change much of my code; injecting the EntityManager into an EJB using @PersistenceContext still works fine. If I remember correctly, the EntityManager that gets injected is a special JBoss proxy/wrapper around the JPA implementation's EntityManager. You can get the actual EntityManager using EntityManager.getDelegate().

  • 14. Re: How to use eclipselink in AS 7
    Scott Marlow Master

    John,

     

    You probably could try using EntityManager.unwrap() to gain access to internal Oracle classes.  Or something like the following:

     

    @PersistenceContext
    OracleInternalClass injectedClass
    

     

    I know that your itching to try this, so let us know if it works. 

     

    Scott

1 2 Previous Next