2 Replies Latest reply on Mar 8, 2006 10:29 AM by Mark Raadsen

    After upgrade 4.0.3SP1 to 4.0.4RC1 EJB session beans not cla

    Mark Raadsen Newbie

      Hi!

      Please correct me if I'm in the wrong forum. The problem I'm having is that I cannot acces my EJB 3.0 session beans anymore via JNDI, because - it seems - they're not being loaded anymore.

      In 4.0.3SP1 all worked well, via the code snippets below. After upgrading to 4.0.4RC1 I followed the Hibernate Migration guide and replaced all obsolete annotations with the new ones, etc, but I got stranded when accessing my session beans. I'm fairly new to EJB's and JBoss alltogether, so it's difficult for me to exactly explain what's relevant here.

      Here are some code snippets from my application.

      Deployment

      09:54:38,147 INFO [TomcatDeployer] undeploy, ctxPath=/ccgui, warUrl=.../tmp/deploy/tmp1965ccservice.ear-contents/ccgui-exp.war/
      09:54:38,444 INFO [SessionFactoryImpl] closing
      09:54:38,444 INFO [SchemaExport] Running hbm2ddl schema export
      09:54:38,491 INFO [SchemaExport] exporting generated schema to database
      09:54:38,507 INFO [SchemaExport] schema export complete
      09:54:38,913 INFO [EARDeployer] Undeploying J2EE application, destroy step: file:/D:/jboss-4.0.4RC1/server/default/deploy/ccservice.ear
      09:54:38,913 INFO [EARDeployer] Undeployed J2EE application: file:/D:/jboss-4.0.4RC1/server/default/deploy/ccservice.ear
      09:54:38,944 INFO [EARDeployer] Init J2EE application: file:/D:/jboss-4.0.4RC1/server/default/deploy/ccservice.ear
      09:54:40,850 INFO [Ejb3AnnotationHandler] found EJB3: ejbName=ListenerProcessor, class=com.myapp.beans.message.ListenerProcessor, type=MESSAGE_DRIVEN
      09:54:40,960 INFO [Ejb3AnnotationHandler] found EJB3: ejbName=InitServiceBean, class=com.myapp.beans.session.impl.InitServiceBean, type=STATELESS
      09:54:41,053 INFO [Ejb3AnnotationHandler] found EJB3: ejbName=TestServiceBean, class=com.myapp.beans.session.impl.TestServiceBean, type=STATELESS
      09:54:41,163 INFO [Ejb3AnnotationHandler] found EJB3: ejbName=UserServiceBean, class=com.myapp.beans.session.impl.UserServiceBean, type=STATELESS
      09:54:41,288 FATAL [PersistenceXmlLoader] ccservice JTA
      09:54:41,288 INFO [Ejb3Deployment] EJB3 deployment time took: 516
      09:54:41,350 INFO [JmxKernelAbstraction] installing MBean: persistence.units:ear=ccservice.ear.ear,jar=ccservice.ejb3.jar,unitName=ccservice with dependencies:
      09:54:41,350 INFO [JmxKernelAbstraction] jboss.jca:name=DefaultDS,service=ManagedConnectionFactory
      09:54:41,397 INFO [Ejb3Configuration] found EJB3 Entity bean: com.myapp.beans.entity.Address
      [..snip..]
      09:54:41,428 INFO [Ejb3Configuration] found EJB3 Entity bean: com.myapp.beans.entity.User
      09:54:41,460 INFO [Ejb3Configuration] found EJB3 @EmbeddableSuperclass: com.myapp.beans.session.impl.BasicLifeCycleEntity
      09:54:41,678 INFO [AnnotationBinder] Binding entity from annotated class: com.myapp.beans.entity.Address
      09:54:41,678 INFO [EntityBinder] Bind entity com.myapp.beans.entity.Address on table Address
      [..snip..]
      09:54:41,960 INFO [CollectionBinder] Mapping collection: com.myapp.beans.entity.Athlete.matchEntries -> MatchEntry
      [..snip..]
      09:54:42,038 INFO [ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
      09:54:42,053 INFO [InjectedDataSourceConnectionProvider] Using provided datasource
      09:54:42,053 INFO [SettingsFactory] RDBMS: HSQL Database Engine, version: 1.8.0
      09:54:42,053 INFO [SettingsFactory] JDBC driver: HSQL Database Engine Driver, version: 1.8.0
      09:54:42,053 INFO [Dialect] Using dialect: org.hibernate.dialect.HSQLDialect
      09:54:42,053 INFO [TransactionFactoryFactory] Using default transaction strategy (direct JDBC transactions)
      09:54:42,053 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
      09:54:42,053 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
      09:54:42,053 INFO [SettingsFactory] Automatic flush during beforeCompletion(): enabled
      09:54:42,053 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
      09:54:42,053 INFO [SettingsFactory] JDBC batch size: 15
      09:54:42,053 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
      09:54:42,053 INFO [SettingsFactory] Scrollable result sets: enabled
      09:54:42,053 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
      09:54:42,053 INFO [SettingsFactory] Connection release mode: after_statement
      09:54:42,053 INFO [SettingsFactory] Default batch fetch size: 1
      09:54:42,053 INFO [SettingsFactory] Generate SQL with comments: disabled
      09:54:42,053 INFO [SettingsFactory] Order SQL updates by primary key: disabled
      09:54:42,053 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
      09:54:42,053 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
      09:54:42,053 INFO [SettingsFactory] Query language substitutions: {}
      09:54:42,053 INFO [SettingsFactory] Second-level cache: enabled
      09:54:42,053 INFO [SettingsFactory] Query cache: disabled
      09:54:42,053 INFO [SettingsFactory] Cache provider: org.hibernate.cache.HashtableCacheProvider
      09:54:42,053 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
      09:54:42,053 INFO [SettingsFactory] Structured second-level cache entries: disabled
      09:54:42,053 INFO [SettingsFactory] Statistics: disabled
      09:54:42,053 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
      09:54:42,053 INFO [SettingsFactory] Default entity-mode: pojo
      09:54:42,100 INFO [SessionFactoryImpl] building session factory
      09:54:43,225 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
      09:54:43,241 INFO [SchemaExport] Running hbm2ddl schema export
      09:54:43,272 INFO [SchemaExport] exporting generated schema to database
      09:54:43,319 INFO [SchemaExport] schema export complete
      09:54:43,335 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      09:54:43,475 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:service=EJB3,ear=ccservice.ear,jar=ccservice.ejb3,name=ListenerProcessor with dependencies:
      09:54:44,022 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:service=EJB3,ear=ccservice.ear,jar=ccservice.ejb3,name=InitServiceBean with dependencies:
      09:54:44,022 INFO [JmxKernelAbstraction] persistence.units:ear=ccservice.ear.ear,jar=ccservice.ejb3.jar,unitName=ccservice
      09:54:45,007 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:service=EJB3,ear=ccservice.ear,jar=ccservice.ejb3,name=TestServiceBean with dependencies:
      09:54:45,663 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:service=EJB3,ear=ccservice.ear,jar=ccservice.ejb3,name=UserServiceBean with dependencies:
      09:54:45,663 INFO [JmxKernelAbstraction] persistence.units:ear=ccservice.ear.ear,jar=ccservice.ejb3.jar,unitName=ccservice
      [..snip..]
      09:54:45,882 INFO [EJB3Deployer] Deployed: file:/D:/jboss-4.0.4RC1/server/default/tmp/deploy/tmp1967ccservice.ear-contents/ccservice.ejb3
      09:54:45,897 INFO [TomcatDeployer] deploy, ctxPath=/ccgui, warUrl=.../tmp/deploy/tmp1967ccservice.ear-contents/ccgui-exp.war/
      09:54:46,913 INFO [FacesConfigurator] Reading standard config org/apache/myfaces/resource/standard-faces-config.xml
      09:54:47,022 INFO [FacesConfigurator] Reading config jar:file:/D:/jboss-4.0.4RC1/server/default/tmp/deploy/tmp1967ccservice.ear-contents/ccgui-exp.war/WEB-INF/lib/tomahawk.jar!/META-INF/faces-config.xml
      09:54:47,069 INFO [FacesConfigurator] Reading config /WEB-INF/faces-config.xml
      09:54:47,069 INFO [FacesConfigurator] Reading config /WEB-INF/faces-managed-beans.xml
      09:54:47,085 INFO [FacesConfigurator] Reading config /WEB-INF/faces-navigation.xml
      09:54:47,100 INFO [FacesConfigurator] Reading config /WEB-INF/faces-config.xml
      09:54:48,507 INFO [StartupServletContextListener] ServletContext 'D:\jboss-4.0.4RC1\server\default\.\tmp\deploy\tmp1967ccservice.ear-contents\ccgui-exp.war\' initialized.
      09:54:48,647 INFO [EARDeployer] Started J2EE application: file:/D:/jboss-4.0.4RC1/server/default/deploy/ccservice.ear


      jndi.properties - for server and client, same as it was under 4.0.3SP1

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      java.naming.provider.url=localhost:1099


      persistence.xml - on same location in /META-INF but (hopefully succesfully) updated for 4.0.4

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence>
       <persistence-unit name="ccservice">
       <jta-data-source>java:/DefaultDS</jta-data-source>
       <properties>
       <property name="hibernate.hbm2ddl.auto" value="create-drop" />
       </properties>
       </persistence-unit>
      </persistence>
      


      Here are the listings as it was under 4.0.3 and now for 4.0.4.

      Global JNDI Namespace 4.0.3
      +- HASessionState (class: org.jnp.interfaces.NamingContext)
       | +- Default (class: org.jboss.ha.hasessionstate.server.HASessionStateImpl)
       +- com.myapp.beans.session.UserService (proxy: $Proxy234 implements No ClassLoaders found for: com.myapp.beans.session.UserService (no security manager: RMI class loader disabled))]
       +- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
       +- jmx (class: org.jnp.interfaces.NamingContext)
       | +- invoker (class: org.jnp.interfaces.NamingContext)
       | | +- RMIAdaptor (proxy: $Proxy38 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
       | +- rmi (class: org.jnp.interfaces.NamingContext)
       | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
       +- com.myapp.beans.session.InitService (proxy: $Proxy236 implements No ClassLoaders found for: com.myapp.beans.session.InitService (no security manager: RMI class loader disabled))
       +- HTTPXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
       +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
       +- com.myapp.beans.session.TestService (proxy: $Proxy233 implements No ClassLoaders found for: com.myapp.beans.session.TestService (no security manager: RMI class loader disabled))
       +- UserTransactionSessionFactory (proxy: $Proxy42 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
       +- HTTPConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
       +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
       +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
       +- containers (class: org.jnp.interfaces.NamingContext)
       | +- com.myapp.beans.session.impl.UserServiceBean (class: org.jboss.ejb3.stateless.StatelessContainer)
       | +- com.myapp.beans.session.impl.InitServiceBean (class: org.jboss.ejb3.stateless.StatelessContainer)
       | +- com.myapp.beans.session.impl.TestServiceBean (class: org.jboss.ejb3.stateless.StatelessContainer)
       +- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
       +- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
       +- HAPartition (class: org.jnp.interfaces.NamingContext)
       | +- DefaultPartition (class: org.jboss.ha.framework.server.HAPartitionImpl)
       +- queue (class: org.jnp.interfaces.NamingContext)
       | +- A (class: org.jboss.mq.SpyQueue)
       | +- testQueue (class: org.jboss.mq.SpyQueue)
       | +- ex (class: org.jboss.mq.SpyQueue)
       | +- DLQ (class: org.jboss.mq.SpyQueue)
       | +- D (class: org.jboss.mq.SpyQueue)
       | +- C (class: org.jboss.mq.SpyQueue)
       | +- B (class: org.jboss.mq.SpyQueue)
       +- topic (class: org.jnp.interfaces.NamingContext)
       | +- testDurableTopic (class: org.jboss.mq.SpyTopic)
       | +- testTopic (class: org.jboss.mq.SpyTopic)
       | +- securedTopic (class: org.jboss.mq.SpyTopic)
       +- console (class: org.jnp.interfaces.NamingContext)
       | +- PluginManager (proxy: $Proxy40 implements No ClassLoaders found for: org.jboss.console.manager.PluginManagerMBean (no security manager: RMI class loader disabled))
       +- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
       +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
       +- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
       +- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair)
       +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)


      Global JNDI Namespace 4.04
      +- HASessionState (class: org.jnp.interfaces.NamingContext)
       | +- Default (class: org.jboss.ha.hasessionstate.server.HASessionStateImpl)
       +- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
       +- jmx (class: org.jnp.interfaces.NamingContext)
       | +- invoker (class: org.jnp.interfaces.NamingContext)
       | | +- RMIAdaptor (proxy: $Proxy40 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
       | +- rmi (class: org.jnp.interfaces.NamingContext)
       | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
       +- HTTPXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
       +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
       +- UserTransactionSessionFactory (proxy: $Proxy44 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
       +- HTTPConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
       +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
       +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
       +- ccservice (class: org.jnp.interfaces.NamingContext)
       | +- UserServiceBean (class: org.jnp.interfaces.NamingContext)
       | | +- remote (proxy: $Proxy248 implements No ClassLoaders found for: com.myapp.beans.session.UserService (no security manager: RMI class loader disabled))
       | +- TestServiceBean (class: org.jnp.interfaces.NamingContext)
       | | +- remote (proxy: $Proxy245 implements No ClassLoaders found for: com.myapp.beans.session.TestService (no security manager: RMI class loader disabled))
       | +- InitServiceBean (class: org.jnp.interfaces.NamingContext)
       | | +- remote (proxy: $Proxy242 implements No ClassLoaders found for: com.myapp.beans.session.InitService (no security manager: RMI class loader disabled))
       [..snip..]
       +- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
       +- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
       +- HAPartition (class: org.jnp.interfaces.NamingContext)
       | +- DefaultPartition (class: org.jboss.ha.framework.server.HAPartitionImpl)
       +- queue (class: org.jnp.interfaces.NamingContext)
       | +- A (class: org.jboss.mq.SpyQueue)
       | +- testQueue (class: org.jboss.mq.SpyQueue)
       | +- ex (class: org.jboss.mq.SpyQueue)
       | +- DLQ (class: org.jboss.mq.SpyQueue)
       | +- D (class: org.jboss.mq.SpyQueue)
       | +- C (class: org.jboss.mq.SpyQueue)
       | +- B (class: org.jboss.mq.SpyQueue)
       +- topic (class: org.jnp.interfaces.NamingContext)
       | +- testDurableTopic (class: org.jboss.mq.SpyTopic)
       | +- testTopic (class: org.jboss.mq.SpyTopic)
       | +- securedTopic (class: org.jboss.mq.SpyTopic)
       +- console (class: org.jnp.interfaces.NamingContext)
       | +- PluginManager (proxy: $Proxy42 implements No ClassLoaders found for: org.jboss.console.manager.PluginManagerMBean (no security manager: RMI class loader disabled))
       +- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
       +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
       +- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
       +- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair)
       +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)


      As you can see, for every session bean there's the error

      "remote (proxy: $Proxy248 implements No ClassLoaders found for: com.myapp.beans.session.UserService (no security manager: RMI class loader disabled))"

      In the example UserServiceBean and InitServiceBean do have a part
      @PersistenceContext(unitName = "ccservice")
      protected EntityManager em;

      but the TestService interface and TestServiceBean do not have specific EJB parts:

      TestService.java
      package com.myapp.beans.session;
      
      import javax.ejb.Remote;
      
      @Remote
      public interface TestService {
      
       public String getString();
      }


      TestServiceBean.java
      package com.myapp.beans.session.impl;
      
      import javax.ejb.Stateless;
      
      import com.myapp.beans.session.TestService;
      
      @Stateless
      public class TestServiceBean implements TestService {
      
       public String getString() {
       return "bogus";
       }
      
      }
      


      As you can see in the JNDI views: in 4.0.3 there were also 'No ClassLoaders found for:' errors, but there were also listed as org.jboss.ejb3.stateless.StatelessContainer and that seemed to work. Under 4.0.4 I get a
      Exception in thread "main" javax.naming.NameNotFoundException: com.myapp.beans.session.InitService not bound
       [..snip..]
       at com.myapp.init.Init.main(Init.java:15)


      in

      public static void main( String args[] ) throws NamingException {
       Context context = new InitialContext();
       InitService initService = (InitService) context.lookup(InitService.class.getName());
      
      }


      which did work under 4.0.3SP1.

      In http://www.jboss.com/index.html?module=bb&op=viewtopic&t=77669 Bill Burke mentioned that fact that an Entity Manager was possibly not correctly injected because of of an invalid persistence.xml, but I created the TestService session bean on purpose without any Entity Manager to see if it had anything to do with that problem, but somehow also the TestService bean can not be loaded.

      I'm also not sure if I have to add jboss.entity.manager.jndi.name & jboss.entity.manager.factory.jndi.name to persistence.xml as described in http://www.jboss.com/index.html?module=bb&op=viewtopic&t=76134, since, again, the TestService bean doesn't contain any persistency item that need injection, if I'm correct.

      So, the question, what I can not find in the list JBoss & Hibernate changes on http://wiki.jboss.org/wiki/Wiki.jsp?page=FromJBossEJB3.0RC3ToRC4PFD is: if under 4.0.4 the JNDI lookup fails because there are no classloaders for the session beans, what has changed in JBoss or what have I forgotten during the upgrade?

      Thanks in advance.