2 Replies Latest reply on Jan 31, 2006 5:55 PM by Nikolaus Gerstmayr

    JNDI Lookup & JBoss EJB 3.0 RC4 ???

    Nikolaus Gerstmayr Newbie

      JBoss 4.0.3SP1 with EJB 3.0 RC4

      trying to get the trailblazer jboss-ide demo running with it.
      (got it working with RC3)

      deployment seems to be ok ...

      15:49:37,459 INFO [Ejb3AnnotationHandler] found EJB3: ejbName=AuthorsBean, class=org.jboss.ejb3demo.AuthorsBean, type=STATELESS
      15:49:37,474 INFO [Ejb3Deployment] EJB3 deployment time took: 62
      15:49:37,490 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:service=EJB3,jar=authors-beans.ejb3,name=AuthorsBean with dependencies:
      15:49:37,490 INFO [JmxKernelAbstraction] persistence.units:unitName=it
      15:49:37,506 INFO [EJB3Deployer] Deployed: file:/D:/jboss/server/default/deploy/authors-beans.ejb3
      15:49:37,615 FATAL [PersistenceXmlLoader] it JTA
      15:49:37,615 INFO [Ejb3Deployment] EJB3 deployment time took: 31
      15:49:37,615 INFO [JmxKernelAbstraction] installing MBean: persistence.units:unitName=it with dependencies:
      15:49:37,615 INFO [JmxKernelAbstraction] jboss.jca:name=MySqlDS,service=DataSourceBinding
      15:49:37,662 INFO [Ejb3Configuration] found EJB3 Entity bean: org.jboss.ejb3demo.Article
      15:49:37,677 INFO [Ejb3Configuration] found EJB3 Entity bean: org.jboss.ejb3demo.Author
      15:49:37,677 INFO [AnnotationBinder] Binding entity from annotated class: org.jboss.ejb3demo.Article
      15:49:37,677 INFO [EntityBinder] Bind entity org.jboss.ejb3demo.Article on table ARTICLES
      15:49:37,709 INFO [AnnotationBinder] Binding entity from annotated class: org.jboss.ejb3demo.Author
      15:49:37,709 INFO [EntityBinder] Bind entity org.jboss.ejb3demo.Author on table AUTHORS
      15:49:37,771 INFO [CollectionBinder] Mapping collection: org.jboss.ejb3demo.Author.articles -> ARTICLES
      15:49:37,818 INFO [ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
      15:49:37,834 INFO [InjectedDataSourceConnectionProvider] Using provided datasource
      15:49:37,834 INFO [SettingsFactory] RDBMS: MySQL, version: 4.1.10-log
      15:49:37,834 INFO [SettingsFactory] JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.12 ( $Date: 2005-11-17 15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
      15:49:37,834 INFO [Dialect] Using dialect: org.hibernate.dialect.MySQLInnoDBDialect
      15:49:37,849 INFO [TransactionFactoryFactory] Using default transaction strategy (direct JDBC transactions)
      15:49:37,849 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
      15:49:37,849 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
      15:49:37,849 INFO [SettingsFactory] Automatic flush during beforeCompletion(): enabled
      15:49:37,849 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
      15:49:37,849 INFO [SettingsFactory] JDBC batch size: 15
      15:49:37,849 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
      15:49:37,849 INFO [SettingsFactory] Scrollable result sets: enabled
      15:49:37,849 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): enabled
      15:49:37,849 INFO [SettingsFactory] Connection release mode: after_statement
      15:49:37,849 INFO [SettingsFactory] Maximum outer join fetch depth: 2
      15:49:37,849 INFO [SettingsFactory] Default batch fetch size: 1
      15:49:37,849 INFO [SettingsFactory] Generate SQL with comments: disabled
      15:49:37,849 INFO [SettingsFactory] Order SQL updates by primary key: disabled
      15:49:37,849 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
      15:49:37,849 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
      15:49:37,865 INFO [SettingsFactory] Query language substitutions: {}
      15:49:37,865 INFO [SettingsFactory] Second-level cache: enabled
      15:49:37,865 INFO [SettingsFactory] Query cache: disabled
      15:49:37,865 INFO [SettingsFactory] Cache provider: org.hibernate.cache.HashtableCacheProvider
      15:49:37,865 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
      15:49:37,865 INFO [SettingsFactory] Structured second-level cache entries: disabled
      15:49:37,865 INFO [SettingsFactory] Statistics: disabled
      15:49:37,865 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
      15:49:37,865 INFO [SettingsFactory] Default entity-mode: pojo
      15:49:37,881 INFO [SessionFactoryImpl] building session factory
      15:49:38,006 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
      15:49:38,006 INFO [SchemaUpdate] Running hbm2ddl schema update
      15:49:38,006 INFO [SchemaUpdate] fetching database metadata
      15:49:38,006 INFO [SchemaUpdate] updating schema
      15:49:38,037 INFO [TableMetadata] table found: ejb3test.ARTICLES
      15:49:38,037 INFO [TableMetadata] columns: [title, articleid, authorid, body]
      15:49:38,037 INFO [TableMetadata] foreign keys: [fke566c23d843a2a25]
      15:49:38,037 INFO [TableMetadata] indexes: [primary, fke566c23d843a2a25]
      15:49:38,052 INFO [TableMetadata] table found: ejb3test.AUTHORS
      15:49:38,052 INFO [TableMetadata] columns: [articleid, name]
      15:49:38,052 INFO [TableMetadata] foreign keys: []
      15:49:38,052 INFO [TableMetadata] indexes: [primary]
      15:49:38,068 INFO [SchemaUpdate] schema update complete
      15:49:38,068 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      15:49:38,412 INFO [EJB3Deployer] Deployed: file:/D:/jboss/server/default/deploy/authors.par
      15:49:38,490 INFO [TomcatDeployer] deploy, ctxPath=/authors, warUrl=.../tmp/deploy/tmp10950authors-exp.war/
      


      persistence.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence>
       <persistence-unit name="it">
       <!-- provider>org.hibernate.ejb.HibernatePersistence</provider> -->
       <jta-data-source>java:/MySqlDS</jta-data-source>
       <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
       <property name="hibernate.hbm2ddl.auto" value="update"/> <!-- Tables werden erzeugt beim Deployment falls nicht existierend -->
       <property name="hibernate.show_sql" value="false"/>
       </properties>
       </persistence-unit>
      </persistence>
      



      jmx-console JDNI view says

      Global JNDI Namespace
      
       +- AuthorsBean (class: org.jnp.interfaces.NamingContext)
       | +- remote (proxy: $Proxy75 implements interface org.jboss.ejb3demo.Authors,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
      


      but invoking the servlet gives

      5:53:25,084 INFO [STDOUT] javax.naming.NameNotFoundException: org.jboss.ejb3demo.Authors not bound
      15:53:25,084 INFO [STDOUT] at org.jnp.server.NamingServer.getBinding(NamingServer.java:514)
      15:53:25,084 INFO [STDOUT] at org.jnp.server.NamingServer.getBinding(NamingServer.java:522)
      15:53:25,084 INFO [STDOUT] at org.jnp.server.NamingServer.getObject(NamingServer.java:528)
      15:53:25,084 INFO [STDOUT] at org.jnp.server.NamingServer.lookup(NamingServer.java:281)
      15:53:25,084 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
      15:53:25,240 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
      15:53:25,240 INFO [STDOUT] at javax.naming.InitialContext.lookup(Unknown Source)
      15:53:25,240 INFO [STDOUT] at org.jboss.ejb3demo.web.AuthorServlet.init(AuthorServlet.java:30)
      15:53:25,240 INFO [STDOUT] at javax.servlet.GenericServlet.init(GenericServlet.java:211)
      15:53:25,240 INFO [STDOUT] at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
      15:53:25,240 INFO [STDOUT] at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
      15:53:25,240 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
      15:53:25,240 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      15:53:25,240 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      15:53:25,240 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
      15:53:25,240 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      15:53:25,240 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      15:53:25,240 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      15:53:25,240 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      15:53:25,240 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      15:53:25,240 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      15:53:25,240 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      15:53:25,240 INFO [STDOUT] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      15:53:25,240 INFO [STDOUT] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      15:53:25,240 INFO [STDOUT] at java.lang.Thread.run(Unknown Source)
      15:53:25,240 ERROR [[AuthorServlet]] Servlet.service() for servlet AuthorServlet threw exception
      java.lang.NullPointerException
      


      code:

       private Authors authorsBean;
      
       public void init() throws ServletException {
       try {
       Context context = new InitialContext();
       authorsBean = (Authors) context.lookup(Authors.class.getName());
       } catch (NamingException e) {
      
       e.printStackTrace();
       }
       }