6 Replies Latest reply on Apr 11, 2006 2:23 PM by Peter Voringer

    @PersistenceContext in JMX Service Object with 4.0.4RC2

    Peter Voringer Newbie

      Hi,

      until 4.0.4RC1 i could inject the EntityManager in JMX Service Objects (@Service) like in SessionBeans. But now in 4.0.4RC2 i get "null".
      My SessionBeans can inject, but my services not :'(

      Is this a bug or a feature, or am i too stupid? Any suggestions?

      Regards

      Peter

        • 1. Re: @PersistenceContext in JMX Service Object with 4.0.4RC2
          Peter Voringer Newbie

          ok.. it's really strange.

          Nothing is injected in my JMX Service Objects.

          even

          @Resource(mappedName = "java:/portalDS")
          private DataSource _dataSource;
          


          does not work. But if I try to get it from JNDI

          Context ctx = new InitialContext();
          _dataSource = (DataSource) ctx.lookup("java:/portalDS");
          


          it works.

          I tried to deploy it as .ejb3 and .jar, but everytime nothing happens.

          Any hints?

          Regards

          Peter

          • 2. Re: @PersistenceContext in JMX Service Object with 4.0.4RC2
            Bill Burke Master

            You are doing?:

            @Service
            public class MyBean implements ... {
            
             @PersistenceContext EntityManager entityManager;
            
            }
            
            


            and entityManager is null?

            • 3. Re: @PersistenceContext in JMX Service Object with 4.0.4RC2
              Bill Burke Master

              just tried this. Works fine for me on CR2:

              @Service
              public class TravelAgentBean implements TravelAgentRemote
              {
               @PersistenceContext(unitName="titan") private EntityManager manager;
              
               public void createCabin(Cabin cabin)
               {
               manager.persist(cabin);
               }
              
               public Cabin findCabin(int pKey)
               {
               return manager.find(Cabin.class, pKey);
               }
              }
              


              • 4. Re: @PersistenceContext in JMX Service Object with 4.0.4RC2
                Peter Voringer Newbie

                ok.. i tried again ;)

                Unfortunatelly same result.

                I thought it would be perhaps a bad configuration, so
                I install RC1 => it works, i install CR2 => null :'(

                My Service looks like this:

                @Service(objectName = "portal:service=SystemPropertyService")
                @Management(SystemPropertyManagement.class)
                @Local(SystemPropertyLocal.class)
                @LocalBinding(jndiBinding = SystemPropertyLocal.JNDI)
                public class SystemPropertyService implements SystemPropertyLocal,
                 SystemPropertyManagement {
                
                 private static final Log _log = LogFactory
                 .getLog(SystemPropertyService.class);
                
                 private final ConcurrentHashMap<String, String> _properties = new ConcurrentHashMap<String, String>();
                
                 @PersistenceContext(unitName = "portalEM")
                 protected EntityManager em;
                
                 public void create() throws Exception {
                 }
                
                 public void start() throws Exception {
                 List<SystemProperty> properties = _getProperties();
                
                 // add Properties
                 }
                
                 public void stop() {
                 _properties.clear();
                 }
                
                 public void destroy() {
                 }
                
                
                
                 @SuppressWarnings("unchecked")
                 @TransactionAttribute(TransactionAttributeType.REQUIRED)
                 private List<SystemProperty> _getProperties() {
                 try {
                
                 List<SystemProperty> list = em
                 .createQuery("from SystemProperty sp").getResultList();
                
                 em.flush();
                
                 return list;
                
                 } catch (RuntimeException e) {
                 throw new SystemException(e);
                 }
                
                 }
                }
                


                The Management Interface:

                public interface SystemPropertyManagement extends Service {
                }
                



                The entity-archiv is a .par, the service-archive is a .ejb3, directly in /deploy.

                Log entries:

                2006-04-11 18:26:44,531 DEBUG [org.jboss.ejb3.ServiceDelegateWrapper] Started persistence.units:unitName=portalEM
                
                2006-04-11 18:26:44,531 DEBUG [org.jboss.ejb3.Ejb3Module] Started jboss.j2ee:service=EJB3,module=2portal-entity.par
                
                


                ...

                and little later

                ....

                2006-04-11 18:26:59,625 DEBUG [org.jboss.ejb3.EJB3Deployer] init, 4portal-systemproperty.ejb3
                2006-04-11 18:26:59,625 DEBUG [org.jboss.ejb3.EJB3Deployer] looking for nested deployments in : file:/C:/workspaces/portal/portal-jboss/server/default/deploy/4portal-systemproperty.ejb3
                2006-04-11 18:26:59,625 DEBUG [org.jboss.deployment.DeploymentInfo] createLoaderRepository from config: LoaderRepositoryConfig(repositoryName: JMImplementation:service=LoaderRepository,name=Default, repositoryClassName: null, configParserClassName: null, repositoryConfig: null)
                2006-04-11 18:26:59,625 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx UCL with url file:/C:/workspaces/portal/portal-jboss/server/default/tmp/deploy/tmp569024portal-systemproperty.ejb3
                2006-04-11 18:26:59,625 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRepository, repository=org.jboss.mx.loading.UnifiedLoaderRepository3@d1c778, cl=org.jboss.mx.loading.UnifiedClassLoader3@a075e6{ url=file:/C:/workspaces/portal/portal-jboss/server/default/tmp/deploy/tmp569024portal-systemproperty.ejb3 ,addedOrder=0}
                2006-04-11 18:26:59,625 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRepository, repository=org.jboss.mx.loading.UnifiedLoaderRepository3@d1c778, cl=org.jboss.mx.loading.UnifiedClassLoader3@a075e6{ url=file:/C:/workspaces/portal/portal-jboss/server/default/tmp/deploy/tmp569024portal-systemproperty.ejb3 ,addedOrder=0}
                2006-04-11 18:26:59,625 DEBUG [org.jboss.mx.loading.UnifiedLoaderRepository3] Adding org.jboss.mx.loading.UnifiedClassLoader3@a075e6{ url=file:/C:/workspaces/portal/portal-jboss/server/default/tmp/deploy/tmp569024portal-systemproperty.ejb3 ,addedOrder=0}
                2006-04-11 18:26:59,640 DEBUG [org.jboss.deployment.MainDeployer] resolveLibraries:
                2006-04-11 18:26:59,640 DEBUG [org.jboss.deployment.MainDeployer] found 0 subpackages of file:/C:/workspaces/portal/portal-jboss/server/default/deploy/4portal-systemproperty.ejb3
                2006-04-11 18:26:59,640 DEBUG [org.jboss.deployment.MainDeployer] Watching new file: file:/C:/workspaces/portal/portal-jboss/server/default/deploy/4portal-systemproperty.ejb3
                2006-04-11 18:26:59,640 DEBUG [org.jboss.deployment.MainDeployer] create step for deployment file:/C:/workspaces/portal/portal-jboss/server/default/deploy/4portal-systemproperty.ejb3
                2006-04-11 18:26:59,640 DEBUG [org.jboss.ws.server.WebServiceDeployerEJB3] create: file:/C:/workspaces/portal/portal-jboss/server/default/deploy/4portal-systemproperty.ejb3
                2006-04-11 18:26:59,640 DEBUG [org.jboss.ejb3.EJB3Deployer] create, 4portal-systemproperty.ejb3
                2006-04-11 18:26:59,656 DEBUG [org.jboss.ejb3.EJB3Deployer] Deploying: file:/C:/workspaces/portal/portal-jboss/server/default/deploy/4portal-systemproperty.ejb3
                2006-04-11 18:26:59,656 DEBUG [org.jboss.system.ServiceController] Creating service jboss.j2ee:service=EJB3,module=4portal-systemproperty.ejb3
                2006-04-11 18:26:59,656 DEBUG [org.jboss.ejb3.Ejb3Module] Creating jboss.j2ee:service=EJB3,module=4portal-systemproperty.ejb3
                2006-04-11 18:26:59,656 DEBUG [org.jboss.ejb3.security.JaccHelper] Initialising JACC Context for deployment: 4portal-systemproperty.ejb3
                2006-04-11 18:26:59,796 DEBUG [org.jboss.ejb3.Ejb3AnnotationHandler] found EJB3: ejbName=SystemPropertyService, class=de.absoft.portal.systemproperty.SystemPropertyService, type=SERVICE
                2006-04-11 18:26:59,828 DEBUG [org.jboss.ejb3.ProxyDeployer] no declared remote bindings for : SystemPropertyService
                2006-04-11 18:26:59,843 INFO [org.jboss.ejb3.Ejb3Deployment] EJB3 deployment time took: 187
                2006-04-11 18:26:59,843 DEBUG [org.jboss.ejb3.Ejb3Module] Created jboss.j2ee:service=EJB3,module=4portal-systemproperty.ejb3
                2006-04-11 18:26:59,843 DEBUG [org.jboss.system.ServiceController] Creating dependent components for: jboss.j2ee:service=EJB3,module=4portal-systemproperty.ejb3 dependents are: []
                2006-04-11 18:26:59,843 DEBUG [org.jboss.deployment.MainDeployer] Done with create step of deploying 4portal-systemproperty.ejb3
                2006-04-11 18:26:59,843 DEBUG [org.jboss.deployment.MainDeployer] Begin deployment start file:/C:/workspaces/portal/portal-jboss/server/default/deploy/4portal-systemproperty.ejb3
                2006-04-11 18:26:59,843 DEBUG [org.jboss.ws.server.WebServiceDeployerEJB3] start: file:/C:/workspaces/portal/portal-jboss/server/default/deploy/4portal-systemproperty.ejb3
                2006-04-11 18:26:59,843 DEBUG [org.jboss.ejb3.EJB3Deployer] start application, deploymentInfo: org.jboss.deployment.DeploymentInfo@458bf562 { url=file:/C:/workspaces/portal/portal-jboss/server/default/deploy/4portal-systemproperty.ejb3 }
                 deployer: MBeanProxyExt[jboss.ejb3:service=EJB3Deployer]
                 status: Starting
                 state: START_DEPLOYER
                 watch: file:/C:/workspaces/portal/portal-jboss/server/default/deploy/4portal-systemproperty.ejb3
                 altDD: null
                 lastDeployed: 1144772819640
                 lastModified: 1144772819625
                 mbeans:
                , short name: 4portal-systemproperty.ejb3, parent short name: null
                2006-04-11 18:26:59,843 DEBUG [org.jboss.system.ServiceController] starting service jboss.j2ee:service=EJB3,module=4portal-systemproperty.ejb3
                2006-04-11 18:26:59,843 DEBUG [org.jboss.ejb3.Ejb3Module] Starting jboss.j2ee:service=EJB3,module=4portal-systemproperty.ejb3
                2006-04-11 18:27:00,046 DEBUG [org.jboss.ejb3.EJBContainer] Initialising interceptors for SystemPropertyService...
                2006-04-11 18:27:00,046 DEBUG [org.jboss.ejb3.EJBContainer] Default interceptors: null
                2006-04-11 18:27:00,046 DEBUG [org.jboss.ejb3.EJBContainer] Class interceptors: []
                2006-04-11 18:27:00,046 DEBUG [org.jboss.ejb3.EJBContainer] All applicable interceptor classes: []
                2006-04-11 18:27:00,046 DEBUG [org.jboss.ejb3.JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.service.ServiceContainer
                2006-04-11 18:27:00,062 INFO [org.jboss.ejb3.JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=4portal-systemproperty.ejb3,name=SystemPropertyService,service=EJB3 with dependencies:
                2006-04-11 18:27:00,062 INFO [org.jboss.ejb3.JmxKernelAbstraction] persistence.units:unitName=portalEM
                2006-04-11 18:27:00,078 DEBUG [org.jboss.system.ServiceController] Creating service jboss.j2ee:jar=4portal-systemproperty.ejb3,name=SystemPropertyService,service=EJB3
                2006-04-11 18:27:00,078 DEBUG [org.jboss.system.ServiceController] adding depends in ServiceController.register: [persistence.units:unitName=portalEM]
                2006-04-11 18:27:00,078 DEBUG [org.jboss.system.ServiceController] recording that jboss.j2ee:jar=4portal-systemproperty.ejb3,name=SystemPropertyService,service=EJB3 depends on persistence.units:unitName=portalEM
                2006-04-11 18:27:00,078 DEBUG [org.jboss.ejb3.ServiceDelegateWrapper] Creating jboss.j2ee:jar=4portal-systemproperty.ejb3,name=SystemPropertyService,service=EJB3
                2006-04-11 18:27:00,078 DEBUG [org.jboss.ejb3.ServiceDelegateWrapper] Created jboss.j2ee:jar=4portal-systemproperty.ejb3,name=SystemPropertyService,service=EJB3
                2006-04-11 18:27:00,078 DEBUG [org.jboss.system.ServiceController] Creating dependent components for: jboss.j2ee:jar=4portal-systemproperty.ejb3,name=SystemPropertyService,service=EJB3 dependents are: []
                2006-04-11 18:27:00,078 DEBUG [org.jboss.system.ServiceController] starting service jboss.j2ee:jar=4portal-systemproperty.ejb3,name=SystemPropertyService,service=EJB3
                2006-04-11 18:27:00,078 DEBUG [org.jboss.ejb3.ServiceDelegateWrapper] Starting jboss.j2ee:jar=4portal-systemproperty.ejb3,name=SystemPropertyService,service=EJB3
                2006-04-11 18:27:00,234 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] Added url: file:/C:/workspaces/portal/portal-jboss/server/default/tmp/aopdynclasses/ucl56903/?dynamic=true, to ucl: org.jboss.mx.loading.UnifiedClassLoader3@a075e6{ url=file:/C:/workspaces/portal/portal-jboss/server/default/tmp/deploy/tmp569024portal-systemproperty.ejb3 ,addedOrder=43}
                2006-04-11 18:27:00,484 DEBUG [org.jboss.ejb3.tx.UserTransactionImpl] new UserTx: org.jboss.ejb3.tx.UserTransactionImpl@10771a6
                2006-04-11 18:27:00,656 DEBUG [org.jboss.ejb3.security.JaccHelper] SystemPropertyService has no @SecurityDomain - skipping JACC configuration
                2006-04-11 18:27:00,656 INFO [org.jboss.ejb3.EJBContainer] STARTED EJB: de.absoft.portal.systemproperty.SystemPropertyService ejbName: SystemPropertyService
                2006-04-11 18:27:00,703 DEBUG [org.jboss.system.ServiceController] Creating service portal:service=SystemPropertyService
                2006-04-11 18:27:00,703 DEBUG [org.jboss.system.ServiceController] adding depends in ServiceController.register: [persistence.units:unitName=portalEM]
                2006-04-11 18:27:00,703 DEBUG [org.jboss.system.ServiceController] recording that portal:service=SystemPropertyService depends on persistence.units:unitName=portalEM
                2006-04-11 18:27:00,781 INFO [de.absoft.portal.systemproperty.SystemPropertyService] SystemPropertyService created
                2006-04-11 18:27:00,781 DEBUG [org.jboss.system.ServiceController] Creating dependent components for: portal:service=SystemPropertyService dependents are: []
                2006-04-11 18:27:00,781 DEBUG [org.jboss.system.ServiceController] starting service portal:service=SystemPropertyService
                2006-04-11 18:27:00,781 INFO [de.absoft.portal.systemproperty.SystemPropertyService] Try to start SystemPropertyService
                2006-04-11 18:27:12,187 DEBUG [de.absoft.portal.systemproperty.SystemPropertyService] private List<SystemProperty> _getProperties()
                2006-04-11 18:27:12,187 ERROR [de.absoft.portal.systemproperty.SystemPropertyService] private List<SystemProperty> _getProperties()
                java.lang.NullPointerException
                 at de.absoft.portal.systemproperty.SystemPropertyService._getProperties(SystemPropertyService.java:85)
                


                It does what it should in RC1 (so i don't think it's about my code), so what is going wrong in CR2?

                Any hint what is going wrong?

                Regards

                Peter


                • 5. Re: @PersistenceContext in JMX Service Object with 4.0.4RC2
                  Peter Voringer Newbie

                  What i find very interesting is this:

                  2006-04-11 18:27:00,703 DEBUG [org.jboss.system.ServiceController] recording that portal:service=SystemPropertyService depends on persistence.units:unitName=portalEM

                  ...

                  2006-04-11 18:27:00,781 DEBUG [org.jboss.system.ServiceController] Creating dependent components for: portal:service=SystemPropertyService dependents are: []

                  This looks like it looses some information.

                  Would be great if someone has an idea.

                  Regards

                  Peter

                  • 6. Re: @PersistenceContext in JMX Service Object with 4.0.4RC2
                    Peter Voringer Newbie


                    OK! THIS IS A BUG!

                    Problem is that the EntityManager is injected AFTER the start() method of the JMX Service Object is executed! Because of this bill.burke@jboss.com's code works, mine not :'(

                    Is this realy how it should work? I want my Objects injected before I start my service, especially if they are already started/available.

                    Regards

                    Peter