10 Replies Latest reply on Jul 7, 2008 1:09 PM by juergen.zimmermann

    5.0.0CR1: deployment error with @PersistenceContext and @Ign

    juergen.zimmermann

      An exploded EAR deploys and runs fine with JBossAS 4.2.2. Adapting some DTD declarations and package names I tried the deployment with for 5.0.0CR1 and failed. The stacktrace is below.

      The problem:
      - KundenverwaltungBean is a SLSB and references the SLSB BestellverwaltungBean via its interface Bestellverwaltung
      - The reference is declared with @PersistenceContext and @IgnoreDependency because BestellverwaltungBean also has a reference back to KundenverwaltungBean via its interface Kundenverwaltung
      - BestellverwaltungBean has a field "em" of type EntityManager being annotated with @PersistenceContext(name="hskaPersistence")
      - hskaPersistence is the name of <persistence-unit> inside META-INF/persistence.xml

      Here is the stacktrace. Any hint is appreciated! Is this a bug in the hot deployment scanner?

      2008-07-04 06:00:55,388 INFO [org.apache.coyote.ajp.AjpAprProtocol] (main) Starting Coyote AJP/1.3 on ajp-localhost%2F127.0.0.1-8009
      2008-07-04 06:00:55,398 INFO [org.jboss.bootstrap.microcontainer.ServerImpl] (main) JBoss (Microcontainer) [5.0.0.CR1 (build: SVNTag=JBoss_5_0_0_CR1 date=200806301254)] Started in 1m:10s:120ms
      2008-07-04 06:01:14,105 INFO [STDOUT] (HDScanner) ======> Creating interceptor metadata bridge
      2008-07-04 06:01:14,816 INFO [STDOUT] (HDScanner) ======> Creating interceptor metadata bridge
      2008-07-04 06:01:14,866 INFO [STDOUT] (HDScanner) ======> Creating interceptor metadata bridge
      2008-07-04 06:01:15,007 INFO [STDOUT] (HDScanner) ======> Creating interceptor metadata bridge
      2008-07-04 06:01:15,137 WARN [org.jboss.ejb3.interceptors.aop.InjectInterceptorsFactory] (HDScanner) WEIRDNESS IN AOP: advisor org.jboss.ejb3.aop.ExtendedManagedObjectAdvisor@32d4a8
      2008-07-04 06:01:15,187 WARN [org.jboss.ejb3.interceptors.aop.InjectInterceptorsFactory] (HDScanner) WEIRDNESS IN AOP: advisor org.jboss.ejb3.aop.ExtendedManagedObjectAdvisor@32d4a8
      2008-07-04 06:01:15,207 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) Created KernelDeployment for: hskaEJB.jar
      2008-07-04 06:01:15,217 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) installing bean: persistence.units:ear=hska.ear,jar=hskaEJB.jar,unitName=hskaPersistence
      2008-07-04 06:01:15,217 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) with dependencies:
      2008-07-04 06:01:15,217 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) and demands:
      2008-07-04 06:01:15,217 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) jboss.jca:name=hskaDS,service=DataSourceBinding
      2008-07-04 06:01:15,217 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) and supplies:
      2008-07-04 06:01:15,217 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) persistence.units:unitName=hskaPersistence
      2008-07-04 06:01:15,217 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) Added bean(persistence.units:ear=hska.ear,jar=hskaEJB.jar,unitName=hskaPersistence) to KernelDeployment of: hskaEJB.jar
      2008-07-04 06:01:15,217 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (HDScanner) Error installing to Real: name=vfsfile:/C:/Programme/jboss/server/default/deploy/hska.ear/ state=PreReal mode=Manual requiredState=Real
      org.jboss.deployers.spi.DeploymentException: Error deploying hskaEJB.jar: <injection-target> could not be found: de.hska.bestellverwaltung.BestellverwaltungBean.hskaPersistence
       at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:192)
       at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:95)
       at org.jboss.deployers.vfs.spi.deployer.AbstractVFSRealDeployer.internalDeploy(AbstractVFSRealDeployer.java:45)
       at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
       at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:174)
       at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:970)
       at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1023)
       at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:911)
       at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
       at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1392)
       at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:784)
       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:912)
       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:834)
       at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:672)
       at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:455)
       at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:594)
       at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:541)
       at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:290)
       at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:221)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
       at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
       at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.RuntimeException: <injection-target> could not be found: de.hska.bestellverwaltung.BestellverwaltungBean.hskaPersistence
       at org.jboss.injection.InjectionUtil.findInjectionTarget(InjectionUtil.java:225)
       at org.jboss.injection.InjectionUtil.injectionTarget(InjectionUtil.java:301)
       at org.jboss.injection.PersistenceContextHandler.loadXml(PersistenceContextHandler.java:64)
       at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:561)
       at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:392)
       at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:505)
       at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:185)
       ... 27 more
      2008-07-04 06:01:15,217 WARN [org.jboss.system.server.profileservice.hotdeploy.HDScanner] (HDScanner) Failed to process changes
      org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
      
      *** CONTEXTS IN ERROR: Name -> Error
      
      vfsfile:/C:/Programme/jboss/server/default/deploy/hska.ear/ -> java.lang.RuntimeException: <injection-target> could not be found: de.hska.bestellverwaltung.BestellverwaltungBean.hskaPersistence
      
      
       at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:676)
       at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:661)
       at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:291)
       at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:221)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
       at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
       at java.lang.Thread.run(Thread.java:619)


        • 1. Re: 5.0.0CR1: deployment error with @PersistenceContext and
          zithuba

          I am experiencing almost the same problem. The problem is with the deployment order of the files. The persistence xml file is deployed first, and the whole ear and the datasource is deployed last. Therefore the persistence provider cannot be started as it requires the datasource. The line 'Demands ...' is the culprit.

          Well no answer yet, I will post it, if I find it.

          • 2. Re: 5.0.0CR1: deployment error with @PersistenceContext and
            jaikiran

            Juergen.Zimmermann,

            Have you deployed the hskaDS datasource? The logs dont show anything about this datasource.

            • 3. Re: 5.0.0CR1: deployment error with @PersistenceContext and
              juergen.zimmermann

              I've an exploded SAR archive inside the exploded EAR archive. The SAR archive contains a file hska-ds.xml (just as it is when running successfully with JBossAS 4.2.2)

              • 4. Re: 5.0.0CR1: deployment error with @PersistenceContext and
                jaikiran

                I don't see any mention of the sar being deployed, in the logs. What does your jboss-app.xml look like? I usually package the -ds.xml at the root of the EAR and then place the jboss-app.xml in the META-INF of EAR with the following contents:

                <jboss-app>
                
                 <module>
                 <service>myDS-ds.xml</service>
                 </module>
                
                </jboss-app>
                


                • 5. Re: 5.0.0CR1: deployment error with @PersistenceContext and
                  juergen.zimmermann

                  The exploded sar is contained in the exploded ear, and jboss-app.xml looks as follows (with the DTD for 5.0):

                  <?xml version="1.0"?>
                  <!DOCTYPE jboss-app
                   PUBLIC "-//JBoss//DTD Java EE Application 5.0//EN"
                   "http://www.jboss.org/j2ee/dtd/jboss-app_5_0.dtd">
                  <jboss-app>
                   <module>
                   <service>
                   hska.sar
                   </service>
                   </module>
                  </jboss-app>


                  • 6. Re: 5.0.0CR1: deployment error with @PersistenceContext and
                    jaikiran

                    Can you please post your EJB and its interface code? Also post the contents of your persistence.xml. And the logs from server.log when the application is being deployed.

                    Right now, i am not exactly sure what's wrong.

                    • 7. Re: 5.0.0CR1: deployment error with @PersistenceContext and
                      juergen.zimmermann

                      As mentioned before: it's an application that works fine with 4.2.2.

                      Here is the Interface without any annotation:

                      public interface Bestellverwaltung {
                      
                       Bestellung findBestellungById(Long id) throws BestellungNotFoundException;
                      ...


                      Here is the bean class:
                      @Stateless
                      @Local(Bestellverwaltung.class)
                      public class BestellverwaltungBean implements Bestellverwaltung {
                       @SuppressWarnings("unused")
                       @PersistenceContext(name="hskaPersistence")
                       private EntityManager em;
                      
                       @EJB
                       private Kundenverwaltung kv;
                      
                       @EJB
                       private BestellverwaltungDao dao;
                      
                       @SuppressWarnings("unused")
                       @PreDestroy
                       private void preDestroy() {...}
                      ...


                      And also the persistence.xml:
                      <?xml version="1.0" encoding="ISO-8859-1"?>
                      
                      <persistence 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_1_0.xsd"
                       version="1.0">
                      
                       <persistence-unit name="hskaPersistence">
                       <provider>org.hibernate.ejb.HibernatePersistence</provider>
                      
                       <!-- Hibernate Console: in Kommentar setzen -->
                       <jta-data-source>java:/hskaDS</jta-data-source>
                      
                       <properties>
                       <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
                      
                       <!-- Keine proprietaeren Erweiterungen von HQL nutzen -->
                       <property name="hibernate.query.jpaql_strict_compliance" value="true"/>
                      
                       <!-- In der Log-Datei die SQL-Anweisungen lesbarer rausschreiben -->
                       <property name="hibernate.format_sql" value="true"/>
                      
                       <!-- In der Log-Datei auch Kommentare zu den generierten SQL-Anweisungen hinzufuegen -->
                       <property name="hibernate.use_sql_comments" value="true"/>
                      
                       <!-- Batch fuer DML von automatisch versionierten Datensaetzen -->
                       <property name="hibernate.jdbc.batch_versioned_data" value="true"/>
                      
                       <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
                      
                       <property name="hibernate.cache.use_query_cache" value="true"/>
                      
                       <!-- Klassen und Collections fuer Caching der persistenten Objekte -->
                       <!-- falls TreeCache statt HashtableCache: read-write aendern in transactional -->
                       <property name="hibernate.ejb.classcache.de.hska.kundenverwaltung.db.Kunde" value="read-write, /kunden"/>
                       <property name="hibernate.ejb.collectioncache.de.hska.kundenverwaltung.db.Kunde.bestellungen" value="read-write, /bestellungen"/>
                       <property name="hibernate.ejb.classcache.de.hska.bestellverwaltung.db.Bestellung" value="read-write, /bestellungen"/>
                       <property name="hibernate.ejb.classcache.de.hska.bestellverwaltung.db.Lieferung" value="read-write, /lieferungen"/>
                       </properties>
                       </persistence-unit>
                      </persistence>


                      • 8. Re: 5.0.0CR1: deployment error with @PersistenceContext and
                        jaikiran

                        Just tried out with a simple application. I too see the same exception. Looks like a bug.

                        If your persistence.xml is in the same jar as the beans, then as a workaround, change your injection code as follows:

                        @SuppressWarnings("unused")
                        @PersistenceContext
                        private EntityManager em;


                        Specifying a "name" attribute to the @PersistenceContext injection seems to be creating the issue.


                        • 9. Re: 5.0.0CR1: deployment error with @PersistenceContext and
                          jaikiran

                           

                          "jaikiran" wrote:
                          I too see the same exception. Looks like a bug.



                          I guess its not a bug. I just read the @PersistenceContext reference here http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-annotations.html#PersistenceContext.

                          You should be using unitName attribute and not the name attribute, in this case. So the bean should be changed to:
                          @SuppressWarnings("unused")
                           @PersistenceContext(unitName="hskaPersistence")
                           private EntityManager em;


                          • 10. Re: 5.0.0CR1: deployment error with @PersistenceContext and
                            juergen.zimmermann

                            Thank you! That'sd the solution.