3 Replies Latest reply on Feb 11, 2007 5:05 PM by rzuidema

    NameNotFoundException: xxxx not bound

    rzuidema

      I am trying a simple ejb 3.0 which is called from a servlet.
      The messages I get from the server during start-up are fine:


      20:12:01,234 INFO [WrapperDataSourceService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'DefaultDS'
      20:12:02,366 INFO [A] Bound to JNDI name: queue/A
      20:12:02,376 INFO [B] Bound to JNDI name: queue/B
      20:12:02,386 INFO [C] Bound to JNDI name: queue/C
      20:12:02,396 INFO [D] Bound to JNDI name: queue/D
      20:12:02,406 INFO [ex] Bound to JNDI name: queue/ex
      20:12:02,466 INFO [testTopic] Bound to JNDI name: topic/testTopic
      20:12:02,476 INFO [securedTopic] Bound to JNDI name: topic/securedTopic
      20:12:02,776 INFO [testDurableTopic] Bound to JNDI name: topic/testDurableTopic
      20:12:02,796 INFO [testQueue] Bound to JNDI name: queue/testQueue
      20:12:02,826 INFO [UILServerILService] JBossMQ UIL service available at : /0.0.0.0:8093
      20:12:02,966 INFO [DLQ] Bound to JNDI name: queue/DLQ
      20:12:03,117 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-console.war/
      20:12:03,998 INFO [EARDeployer] Init J2EE application: file:/C:/jboss-4.0.4.GA/server/default/deploy/NewsApp.ear
      20:12:05,640 INFO [Ejb3Deployment] EJB3 deployment time took: 1372
      20:12:05,700 INFO [JmxKernelAbstraction] installing MBean: persistence.units:ear=NewsApp.ear,jar=NewsApp-ejb.jar,unitName=NewsApp-ejbPU with dependencies:
      20:12:05,700 INFO [JmxKernelAbstraction] jboss.jca:name=DefaultDS,service=ManagedConnectionFactory
      20:12:05,790 INFO [Version] Hibernate EntityManager 3.2.0.CR1
      20:12:05,841 INFO [Version] Hibernate Annotations 3.2.0.CR1
      20:12:06,011 INFO [Environment] Hibernate 3.2 cr2
      20:12:06,041 INFO [Environment] hibernate.properties not found
      20:12:06,051 INFO [Environment] Bytecode provider name : javassist
      20:12:06,071 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
      20:12:06,461 INFO [Ejb3Configuration] found EJB3 Entity bean: com.etrade.domain.Firstcategory
      20:12:06,471 WARN [Ejb3Configuration] Persistence provider caller does not implements the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.
      20:12:06,702 INFO [Configuration] Reading mappings from resource: META-INF/orm.xml
      20:12:06,702 INFO [Ejb3Configuration] [PersistenceUnit: NewsApp-ejbPU] no META-INF/orm.xml found
      20:12:06,922 INFO [AnnotationBinder] Binding entity from annotated class: com.etrade.domain.Firstcategory
      20:12:06,952 INFO [QueryBinder] Binding Named query: Firstcategory.findByFirstcategorykey => SELECT f FROM Firstcategory f WHERE f.firstcategorykey = :firstcategorykey
      20:12:07,042 INFO [QueryBinder] Binding Named query: Firstcategory.findByFirstcategorydescription => SELECT f FROM Firstcategory f WHERE f.firstcategorydescription = :firstcategorydescription
      20:12:07,192 INFO [EntityBinder] Bind entity com.etrade.domain.Firstcategory on table firstcategory
      20:12:07,733 INFO [ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
      20:12:07,743 INFO [InjectedDataSourceConnectionProvider] Using provided datasource
      20:12:07,753 INFO [SettingsFactory] RDBMS: MySQL, version: 5.0.15-nt
      20:12:07,753 INFO [SettingsFactory] JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.11 ( $Date: 2005-09-21 18:20:03 +0000 (Wed, 21 Sep 2005) $, $Revision: 4287 $ )
      20:12:08,204 INFO [Dialect] Using dialect: org.hibernate.dialect.MySQLDialect
      20:12:08,214 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory
      20:12:08,234 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
      20:12:08,244 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
      20:12:08,645 INFO [SettingsFactory] Automatic flush during beforeCompletion(): disabled
      20:12:08,645 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
      20:12:08,645 INFO [SettingsFactory] JDBC batch size: 15
      20:12:08,645 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
      20:12:08,645 INFO [SettingsFactory] Scrollable result sets: enabled
      20:12:08,645 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): enabled
      20:12:08,645 INFO [SettingsFactory] Connection release mode: auto
      20:12:08,645 INFO [SettingsFactory] Maximum outer join fetch depth: 2
      20:12:08,645 INFO [SettingsFactory] Default batch fetch size: 1
      20:12:08,645 INFO [SettingsFactory] Generate SQL with comments: disabled
      20:12:08,645 INFO [SettingsFactory] Order SQL updates by primary key: disabled
      20:12:08,645 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
      20:12:08,655 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
      20:12:08,655 INFO [SettingsFactory] Query language substitutions: {}
      20:12:08,655 INFO [SettingsFactory] Second-level cache: enabled
      20:12:08,655 INFO [SettingsFactory] Query cache: disabled



      However the code to locate the ejb fails..
       try {
       Properties p = new Properties();
       Context c = new InitialContext();
       return (FirstcategoryFacadeLocal) c.lookup("FirstcategoryFacade");
       }
      


      JNDI properties are OK (I guess)

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


      Any ideas what could be wrong?
      Thanks,
      BobZ

        • 1. Re: NameNotFoundException: xxxx not bound
          peterj

          What are the < ejb-ref > entries on your web.xml and jboss-web.xml files?

          • 2. Re: NameNotFoundException: xxxx not bound
            rzuidema

            In the web.xml

             <ejb-ref>
             <ejb-ref-name>FirstcategoryFacade</ejb-ref-name>
             <ejb-ref-type>Session</ejb-ref-type>
             <home>FirstcategoryFacadeHome</home>
             <remote>FirstcategoryFacade</remote>
             </ejb-ref>
            

            in the jboss-we.xml
            <?xml version="1.0" encoding="UTF-8"?>
            <jboss-web>
             <security-domain flushOnSessionInvalidation="false"/>
             <context-root>/NewsApp-war</context-root>
             <ejb-ref>
             <ejb-ref-name>FirstcategoryFacade</ejb-ref-name>
             <jndi-name>FirstcategoryFacade</jndi-name>
             </ejb-ref>
            </jboss-web>
            


            • 3. Re: NameNotFoundException: xxxx not bound
              rzuidema

              Found the problem, mostly pilot error, from the EJB Tutorial:


              JNDI Bindings
              By default, session beans will bind to JNDI in the form ejbName/remote for remote interfaces and ejbName/local in the case of local interfaces. When the EJBs are deployed in an .ear file, the default jndi binding will be prepended by the name of the .ear file. So if the ear file name is foo.ear the default jndi names would be foo/EJB-NAME/remote and foo/EJB-NAME/local. You can override this behavior by defining your own @org.jboss.ejb3.LocalBinding or @org.jboss.ejb3.remoting.RemoteBinding.

              Note the EJB name
              When I used the ear name it worked:
               try {
               Properties p = new Properties();
               Context c = new InitialContext();
               return (FirstcategoryFacadeLocal) c.lookup("NewsApp/FirstcategoryFacade/local");
               }
              
              


              Thanks anyway