4 Replies Latest reply: May 28, 2010 7:43 AM by NickAiva RSS

    EJB3 test client: javax.naming.NameNotFoundException  for JDev 11.1.1.3

    NickAiva
      Dear experts!

      The test client code,(given below) JDev 11.1.1.3 generated for a stateful ejb3 (code also given below) threw:

      actionbazaar.buslogic.BidderAccountCreatorWLClient
      +javax.naming.NameNotFoundException: While trying to lookup 'ejb3inaction-Chapter3-BidderAccountCreator#actionbazaar.buslogic.BidderAccountCreator' didn't find subcontext 'ejb3inaction-Chapter3-BidderAccountCreator#actionbazaar'. Resolved '' [Root exception is javax.naming.NameNotFoundException: While trying to lookup 'ejb3inaction-Chapter3-BidderAccountCreator#actionbazaar.buslogic.BidderAccountCreator' didn't find subcontext 'ejb3inaction-Chapter3-BidderAccountCreator#actionbazaar'. Resolved '']; remaining name 'ejb3inaction-Chapter3-BidderAccountCreator#actionbazaar/buslogic/BidderAccountCreator'+
      +     at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)+
      +     at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)+
      +     at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)+
      +     at weblogic.jndi.internal.ServerNamingNode_1033_WLStub.lookup(Unknown Source)+
      +     at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:405)+
      +     at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:393)+
      +     at javax.naming.InitialContext.lookup(InitialContext.java:392)+
      +     at actionbazaar.buslogic.BidderAccountCreatorWLClient.main(BidderAccountCreatorWLClient.java:13)+
      Caused by: javax.naming.NameNotFoundException: While trying to lookup 'ejb3inaction-Chapter3-BidderAccountCreator#actionbazaar.buslogic.BidderAccountCreator' didn't find subcontext 'ejb3inaction-Chapter3-BidderAccountCreator#actionbazaar'. Resolved ''
      +     at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)+
      +     at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)+
      +     at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)+
      +     at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)+
      +     at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)+
      +     at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)+
      +     at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)+
      +     at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)+
      +     at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)+
      +     at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)+
      +     at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)+
      +     at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)+
      +     at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)+
      +     at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)+
      Process exited with exit code 0.

      The ejb is not found in the JNDI tree.

      Deployments table shows an exclamation mark at Health column.

      The closest match I found was:

      Re: Weblogic 10.3-  NPE from RemoteBusinessIntfProxy.getTargetMethod

      Any helping hand available?
      Thank you very much indeed in advance!

      GENERATED CODE FOLLOWS:
      package actionbazaar.buslogic;

      import java.util.Hashtable;

      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;

      public class BidderAccountCreatorWLClient {
      public static void main(String [] args) {
      try {
      final Context context = getInitialContext();
      BidderAccountCreator bidderAccountCreator = (BidderAccountCreator)context.lookup("ejb3inaction-Chapter3-BidderAccountCreator#actionbazaar.buslogic.BidderAccountCreator");
      ...
      } catch (Exception ex) {
      ex.printStackTrace();
      }
      }

      private static Context getInitialContext() throws NamingException {
      Hashtable env = new Hashtable();
      // WebLogic Server 10.x connection details
      env.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory" );
      env.put(Context.PROVIDER_URL, "t3://127.0.0.1:7101");
      return new InitialContext( env );
      }
      }
      CODE OF EJB FOLLOWS:

      package actionbazaar.buslogic;

      import actionbazaar.persistence.BillingInfo;
      import actionbazaar.persistence.BiographicalInfo;
      import actionbazaar.persistence.LoginInfo;

      import java.sql.Connection;

      import java.sql.SQLException;

      import java.sql.Statement;

      import javax.annotation.PostConstruct;
      import javax.annotation.PreDestroy;
      import javax.annotation.Resource;

      import javax.ejb.PostActivate;
      import javax.ejb.PrePassivate;
      import javax.ejb.Remote;
      import javax.ejb.Remove;
      import javax.ejb.Stateful;

      import javax.sql.DataSource;

      @Stateful(name = "BidderAccountCreator", mappedName = "ejb3inaction-Chapter3-BidderAccountCreator")
      @Remote
      public class BidderAccountCreatorBean implements BidderAccountCreator {
      @Resource(name = "jdbc/ActionBazaarDS", mappedName="ActionBazaarDS")
      private DataSource dataSource;
      private LoginInfo loginInfo;
      private BiographicalInfo biographicalInfo;
      private BillingInfo billingInfo;
      private Connection connection;

      public BidderAccountCreatorBean() {
      }

      @PostConstruct
      @PostActivate
      public void openConnection() {
      try {
      connection = dataSource.getConnection();
      } catch (SQLException sqle) {
      sqle.printStackTrace();
      }
      }
      public void addLoginInfo(LoginInfo loginInfo) {
      this.loginInfo = loginInfo;
      }


      public void addBiographicalInfo(BiographicalInfo biographicalInfo)
      throws WorkflowOrderViolationException {
      if (loginInfo == null) {
      throw new WorkflowOrderViolationException(
      "Login info must be set before biographical info");
      }

      this.biographicalInfo = biographicalInfo;
      }


      public void addBillingInfo(BillingInfo billingInfo)
      throws WorkflowOrderViolationException {
      if (biographicalInfo == null) {
      throw new WorkflowOrderViolationException(
      "Biographical info must be set before billing info");
      }

      this.billingInfo = billingInfo;
      }


      @PrePassivate
      @PreDestroy
      public void cleanup() {
      try {
      connection.close();
      connection = null;
      } catch (SQLException sqle) {
      sqle.printStackTrace();
      }
      }


      @Remove
      public void cancelAccountCreation() {
      loginInfo = null;
      biographicalInfo = null;
      billingInfo = null;
      }


      @Remove
      public void createAccount() {
      try {
      Statement statement = connection.createStatement();
      String sql = "INSERT INTO BIDDERS(" + "username, " + "first_name, "
      + "credit_card_type" + ") VALUES (" + "'"
      + loginInfo.getUsername() + "', " +

      "'" + biographicalInfo.getFirstName() + "', " +

      "'" + billingInfo.getCreditCardType() + "'" +

      ")";
      statement.execute(sql);
      statement.close();
      System.out.println("Bidder successfully created ..");
      } catch (SQLException sqle) {
      sqle.printStackTrace();
      }
      }
      }
        • 1. Re: EJB3 test client: javax.naming.NameNotFoundException  for JDev 11.1.1.3
          Shay Shmeltzer-Oracle
          Did you run the EJB before you ran the client?
          • 2. Re: EJB3 test client: javax.naming.NameNotFoundException  for JDev 11.1.1.3
            NickAiva
            Thank you for your reply!

            When I deploy the whole application from JDev I don't get any obvious errors (deployment complete message appears). What I wrote in the first post is valid.

            But when I select to run the specific bean ( right click and run), I get the following:

            +[10:02:22 AM] Target platform is (Weblogic 10.3).+
            +[10:02:22 AM] Retrieving existing application information+
            +[10:02:22 AM] Running dependency analysis...+
            +[10:02:22 AM] Deploying 2 profiles...+
            +[10:02:22 AM] Wrote EJB Module to C:\Users\Nick\AppData\Roaming\JDeveloper\system11.1.1.3.37.56.60\o.j2ee\drs\ejb3inaction\Chapter3EJB.jar+
            +[10:02:22 AM] Wrote Enterprise Application Module to C:\Users\Nick\AppData\Roaming\JDeveloper\system11.1.1.3.37.56.60\o.j2ee\drs\ejb3inaction+
            +[10:02:22 AM] Deploying Application...+
            +<25 Μαϊ 2010 10:02:23 πμ EEST> <Warning> <J2EE> <BEA-160195> <The application version lifecycle event listener oracle.security.jps.wls.listeners.JpsAppVersionLifecycleListener is ignored because the application ejb3inaction is not versioned.>+
            +<25 Μαϊ 2010 10:02:23 πμ EEST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1274770942861' for task '6'. Error is: 'weblogic.application.ModuleException: Exception preparing module: EJBModule(Chapter3EJB.jar)+
            +[EJB:011023]An error occurred while reading the deployment descriptor. The error was:+
            Error processing annotations: .'
            weblogic.application.ModuleException: Exception preparing module: EJBModule(Chapter3EJB.jar)
            +[EJB:011023]An error occurred while reading the deployment descriptor. The error was:+
            Error processing annotations: .
            +     at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:467)+
            +     at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)+
            +     at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:507)+
            +     at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)+
            +     at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:149)+
            +     Truncated. see log file for complete stacktrace+

            Caused By: weblogic.utils.ErrorCollectionException:

            There are 1 nested errors:

            weblogic.j2ee.dd.xml.AnnotationProcessException: In the ejb-jar.xml, the EJB AccountCreator does not specify an ejb-class value and no annotated EJB class was found in the ejb-jar file with a matching ejb-name.  The ejb-class value must be specified.
            +     at weblogic.j2ee.dd.xml.BaseJ2eeAnnotationProcessor.addProcessingError(BaseJ2eeAnnotationProcessor.java:1323)+
            +     at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.loadBeanClass(EjbAnnotationProcessor.java:2129)+
            +     at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processSessionAnnotations(EjbAnnotationProcessor.java:380)+
            +     at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processAnnotations(EjbAnnotationProcessor.java:310)+
            +     at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processAnnotations(EjbAnnotationProcessor.java:180)+
            +     at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.processStandardAnnotations(EjbDescriptorReaderImpl.java:344)+
            +     at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.createReadOnlyDescriptorFromJarFile(EjbDescriptorReaderImpl.java:204)+
            +     at weblogic.ejb.spi.EjbDescriptorFactory.createReadOnlyDescriptorFromJarFile(EjbDescriptorFactory.java:93)+
            +     at weblogic.ejb.container.deployer.EJBModule.loadEJBDescriptor(EJBModule.java:1242)+
            +     at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:395)+
            +     at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)+
            +     at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:507)+
            +     at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)+
            +     at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:149)+
            +     at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:45)+
            +     at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:1221)+
            +     at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)+
            +     at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:367)+
            +     at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:58)+
            +     at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:154)+
            +     at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)+
            +     at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)+
            +     at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:98)+
            +     at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)+
            +     at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)+
            +     at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)+
            +     at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)+
            +     at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)+
            +     at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)+
            +     at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)+
            +     at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)+
            +     at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)+
            +     at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)+
            +     at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)+


            +     at weblogic.j2ee.dd.xml.BaseJ2eeAnnotationProcessor.addProcessingError(BaseJ2eeAnnotationProcessor.java:1322)+
            +     at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.loadBeanClass(EjbAnnotationProcessor.java:2129)+
            +     at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processSessionAnnotations(EjbAnnotationProcessor.java:380)+
            +     at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processAnnotations(EjbAnnotationProcessor.java:310)+
            +     at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processAnnotations(EjbAnnotationProcessor.java:180)+
            +     Truncated. see log file for complete stacktrace+
            +>+
            +<25 Μαϊ 2010 10:02:23 πμ EEST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application 'ejb3inaction'.>+
            +<25 Μαϊ 2010 10:02:23 πμ EEST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004+
            weblogic.application.ModuleException: Exception preparing module: EJBModule(Chapter3EJB.jar)
            +[EJB:011023]An error occurred while reading the deployment descriptor. The error was:+
            Error processing annotations: .
            +     at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:467)+
            +     at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)+
            +     at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:507)+
            +     at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)+
            +     at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:149)+
            +     Truncated. see log file for complete stacktrace+

            Caused By: weblogic.utils.ErrorCollectionException:

            There are 1 nested errors:

            weblogic.j2ee.dd.xml.AnnotationProcessException: In the ejb-jar.xml, the EJB AccountCreator does not specify an ejb-class value and no annotated EJB class was found in the ejb-jar file with a matching ejb-name.  The ejb-class value must be specified.
            +     at weblogic.j2ee.dd.xml.BaseJ2eeAnnotationProcessor.addProcessingError(BaseJ2eeAnnotationProcessor.java:1323)+
            +     at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.loadBeanClass(EjbAnnotationProcessor.java:2129)+
            +     at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processSessionAnnotations(EjbAnnotationProcessor.java:380)+
            +     at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processAnnotations(EjbAnnotationProcessor.java:310)+
            +     at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processAnnotations(EjbAnnotationProcessor.java:180)+
            +     at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.processStandardAnnotations(EjbDescriptorReaderImpl.java:344)+
            +     at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.createReadOnlyDescriptorFromJarFile(EjbDescriptorReaderImpl.java:204)+
            +     at weblogic.ejb.spi.EjbDescriptorFactory.createReadOnlyDescriptorFromJarFile(EjbDescriptorFactory.java:93)+
            +     at weblogic.ejb.container.deployer.EJBModule.loadEJBDescriptor(EJBModule.java:1242)+
            +     at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:395)+
            +     at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)+
            +     at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:507)+
            +     at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)+
            +     at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:149)+
            +     at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:45)+
            +     at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:1221)+
            +     at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)+
            +     at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:367)+
            +     at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:58)+
            +     at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:154)+
            +     at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)+
            +     at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)+
            +     at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:98)+
            +     at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)+
            +     at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)+
            +     at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)+
            +     at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)+
            +     at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)+
            +     at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)+
            +     at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)+
            +     at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)+
            +     at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)+
            +     at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)+
            +     at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)+


            +     at weblogic.j2ee.dd.xml.BaseJ2eeAnnotationProcessor.addProcessingError(BaseJ2eeAnnotationProcessor.java:1322)+
            +     at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.loadBeanClass(EjbAnnotationProcessor.java:2129)+
            +     at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processSessionAnnotations(EjbAnnotationProcessor.java:380)+
            +     at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processAnnotations(EjbAnnotationProcessor.java:310)+
            +     at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processAnnotations(EjbAnnotationProcessor.java:180)+
            +     Truncated. see log file for complete stacktrace+
            +>+
            +[10:02:23 AM] #### Deployment incomplete. ####+
            +[10:02:23 AM] Remote deployment failed (oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer)+
            +#### Cannot run application ejb3inaction due to error deploying to IntegratedWebLogicServer.+
            +[Application ejb3inaction stopped and undeployed from Server Instance IntegratedWebLogicServer]+

            Back in July 2009 someone had a similar issue:

            [http://www.manning-sandbox.com/thread.jspa?messageID=89455&#89455]

            That is, maybe a problem with annotations or generics still exists?

            Is there any possible workaround?

            Thank you very much for your time!
            • 3. Re: EJB3 test client: javax.naming.NameNotFoundException  for JDev 11.1.1.3
              NickAiva
              When one chooses to use both ejb annotations and xml deployment descriptors, the run attempt fails.

              The same ejb class runs well if the user chooses only annotations upon first ejb creation. The ejb then appears in the jndi tree.

              Edited by: Nick Aiva on May 26, 2010 4:07 PM
              • 4. Re: EJB3 test client: javax.naming.NameNotFoundException  for JDev 11.1.1.3
                NickAiva
                See [http://debupanda.blogspot.com/2008/03/ejb-3-in-action-examples-on-weblogic-10.html] for the solution:

                I only quote:" I could not make dependency injection work in the application client code in WebLogic 10, not sure they support it. So I had to change thick client to make use JNDI lookup instead. "

                Edited by: Nick Aiva on May 28, 2010 3:42 PM