2 Replies Latest reply on Oct 31, 2002 7:59 AM by vman

    JBoss and app. client - name not bound error

    vman

      Hi everyone,

      I have searched and read through everything in the forums regarding: application clients, jndi lookups, etc. and I'm very confused at this point.
      I have written a J2EE application which runs fine on SUNs reference implementation, and deploys ok on JBoss 3.0.
      The application is non-web based; it uses application clients to connect to it.
      I have fought this thing to the point where at least I can successfully (i.e. with no errors shown by JBoss...) deploy the .ear file.
      I have manually edited the XML files, with various combinations of JNDI names, no JNDI names given, etc. and at this point I think I'm just not seeing the forest for the trees. The problem is that when I try to start the client from the commandline , it bombs out with

      ~/jbossdeploy/STS/code> java -jar AppClient.jar
      Client Started
      looking up bean
      Caught an exception @ MainClient
      comp not bound
      javax.naming.NameNotFoundException: comp not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:253)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:536)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:456)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:440)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at MainClient.main(MainClient.java:25)

      I know that the problem (probably) has to do with some JNDI naming error, but I have no clue how to go about fixing it.
      I'm looking things up with:
      Context initial = new InitialContext();
      Object objref = initial.lookup(JNDINames.CONTROLLERSESSIONBEAN);

      and CONTROLLERSESSIONBEAN is

      public static final String CONTROLLERSESSIONBEAN = "java:comp/env/ejb/ControllerSessionBeanCode";

      Here are my XML files (excuse the lengthy post...
      :(

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>

      <ejb-jar>
      <display-name>STSAppJAR</display-name>
      <enterprise-beans>

      <display-name>PaymentBean</display-name>
      <ejb-name>PaymentBean</ejb-name>
      Beans.PaymentHome
      Beans.Payment
      <ejb-class>Beans.PaymentBean</ejb-class>
      <persistence-type>Bean</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <security-identity>

      <use-caller-identity></use-caller-identity>
      </security-identity>
      <resource-ref>
      <res-ref-name>jdbc/STSDB</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      <res-sharing-scope>Shareable</res-sharing-scope>
      </resource-ref>


      <display-name>ChequeBean</display-name>
      <ejb-name>ChequeBean</ejb-name>
      Beans.ChequeHome
      Beans.Cheque
      <ejb-class>Beans.ChequeBean</ejb-class>
      <persistence-type>Bean</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <security-identity>

      <use-caller-identity></use-caller-identity>
      </security-identity>
      <resource-ref>
      <res-ref-name>jdbc/STSDB</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      <res-sharing-scope>Shareable</res-sharing-scope>
      </resource-ref>


      <display-name>InterviewOptionBean</display-name>
      <ejb-name>InterviewOptionBean</ejb-name>
      Beans.InterviewOptionHome
      Beans.InterviewOption
      <ejb-class>Beans.InterviewOptionBean</ejb-class>
      <persistence-type>Bean</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <ejb-ref>
      <ejb-ref-name>ejb/InterviewOptionBeanCode</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      InterviewOptionHome
      InterviewOption
      </ejb-ref>
      <security-identity>

      <use-caller-identity></use-caller-identity>
      </security-identity>
      <resource-ref>
      <res-ref-name>jdbc/STSDB</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      <res-sharing-scope>Shareable</res-sharing-scope>
      </resource-ref>


      <display-name>LoadTypeBean</display-name>
      <ejb-name>LoadTypeBean</ejb-name>
      Beans.LoadTypeHome
      Beans.LoadType
      <ejb-class>Beans.LoadTypeBean</ejb-class>
      <persistence-type>Bean</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <ejb-ref>
      <ejb-ref-name>ejb/LoadTypeBeanCode</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      LoadTypeHome
      LoadType
      </ejb-ref>
      <security-identity>

      <use-caller-identity></use-caller-identity>
      </security-identity>
      <resource-ref>
      <res-ref-name>jdbc/STSDB</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      <res-sharing-scope>Shareable</res-sharing-scope>
      </resource-ref>

      and on and on...

      and my JBoss.xml file:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>

      <enterprise-beans>

      <ejb-name>DubFormatBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/DubFormatBeanCode</ejb-ref-name>
      <jndi-name>DubFormatBean</jndi-name>
      </ejb-ref>


      <ejb-name>InterviewOptionBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/InterviewOptionBeanCode</ejb-ref-name>
      <jndi-name>InterviewOptionBean</jndi-name>
      </ejb-ref>


      <ejb-name>OrderOptionSelectionBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/OrderOptionBeanCode</ejb-ref-name>
      <jndi-name>OrderOptionBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/OrderBeanCode</ejb-ref-name>
      <jndi-name>OrderBean</jndi-name>
      </ejb-ref>


      <ejb-name>LoadTypeBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/LoadTypeBeanCode</ejb-ref-name>
      <jndi-name>LoadTypeBean</jndi-name>
      </ejb-ref>


      <ejb-name>InterviewBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/InterviewerBeanCode</ejb-ref-name>
      <jndi-name>InterviewerBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/IntervieweeBeanCode</ejb-ref-name>
      <jndi-name>IntervieweeBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/InterviewOptionSelectionBeanCode</ejb-ref-name>
      <jndi-name>InterviewOptionSelectionBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/AssignmentBeanCode</ejb-ref-name>
      <jndi-name>AssignmentBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/TranscriptBeanCode</ejb-ref-name>
      <jndi-name>TranscriptBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/TranscriptItemBeanCode</ejb-ref-name>
      <jndi-name>TranscriptItemBean</jndi-name>
      </ejb-ref>


      <ejb-name>ReceiptBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/LoadBeanCode</ejb-ref-name>
      <jndi-name>LoadBean</jndi-name>
      </ejb-ref>



      <ejb-name>OrderBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/OrderAdjustmentBeanCode</ejb-ref-name>
      <jndi-name>OrderAdjustmentBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/ContactBeanCode</ejb-ref-name>
      <jndi-name>ContactBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/CustomerBeanCode</ejb-ref-name>
      <jndi-name>CustomerBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/OrderOptionSelectionBeanCode</ejb-ref-name>
      <jndi-name>OrderOptionSelectionBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/TranscriptBeanCode</ejb-ref-name>
      <jndi-name>TranscriptBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/InterviewBeanCode</ejb-ref-name>
      <jndi-name>InterviewBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/PaymentBeanCode</ejb-ref-name>
      <jndi-name>PaymentBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/ChequeBeanCode</ejb-ref-name>
      <jndi-name>ChequeBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/ReceiptBeanCode</ejb-ref-name>
      <jndi-name>ReceiptBean</jndi-name>
      </ejb-ref>


      <ejb-name>TranscriptTypeBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/TranscriptTypeBeanCode</ejb-ref-name>
      <jndi-name>TranscriptTypeBean</jndi-name>
      </ejb-ref>


      <ejb-name>ContactBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/CustomerBeanCode</ejb-ref-name>
      <jndi-name>CustomerBean</jndi-name>
      </ejb-ref>


      <ejb-name>LoadBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/DubBeanCode</ejb-ref-name>
      <jndi-name>DubBean</jndi-name>
      </ejb-ref>


      <ejb-name>OrderAdjustmentBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/OrderBeanCode</ejb-ref-name>
      <jndi-name>OrderBean</jndi-name>
      </ejb-ref>


      <ejb-name>TurnaroundBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/TurnaroundBeanCode</ejb-ref-name>
      <jndi-name>TurnaroundBean</jndi-name>
      </ejb-ref>


      <ejb-name>ReceiptTypeBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/ReceiptTypeBeanCode</ejb-ref-name>
      <jndi-name>ReceiptTypeBean</jndi-name>
      </ejb-ref>


      <ejb-name>SubBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/AssignmentBeanCode</ejb-ref-name>
      <jndi-name>AssignmentBean</jndi-name>
      </ejb-ref>


      <ejb-name>OrderOptionBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/OrderOptionBeanCode</ejb-ref-name>
      <jndi-name>OrderOptionBean</jndi-name>
      </ejb-ref>


      <ejb-name>CustomerBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/OrderBeanCode</ejb-ref-name>
      <jndi-name>OrderBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/ContactBeanCode</ejb-ref-name>
      <jndi-name>ContactBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/CreditCardBeanCode</ejb-ref-name>
      <jndi-name>CreditCardBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/ChequeBeanCode</ejb-ref-name>
      <jndi-name>ChequeBean</jndi-name>
      </ejb-ref>


      <ejb-name>InterviewOptionSelectionBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/InterviewOptionBeanCode</ejb-ref-name>
      <jndi-name>InterviewOptionBean</jndi-name>
      </ejb-ref>


      <ejb-name>TranscriptBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/OrderBeanCode</ejb-ref-name>
      <jndi-name>OrderBean</jndi-name>
      </ejb-ref>


      <ejb-name>AssignmentBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/SubBeanCode</ejb-ref-name>
      <jndi-name>SubBean</jndi-name>
      </ejb-ref>



      <ejb-name>ControllerSessionBean</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/InterviewerTypeBeanCode</ejb-ref-name>
      <jndi-name>InterviewerTypeBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/IntervieweeTypeBeanCode</ejb-ref-name>
      <jndi-name>IntervieweeTypeBean</jndi-name>
      </ejb-ref>
      <ejb-ref>
      <ejb-ref-name>ejb/CustomerBeanCode</ejb-ref-name>
      <jndi-name>CustomerBean</jndi-name>
      </ejb-ref>

      </enterprise-beans>


      What am I doing wrong here ?
      Please help...

      Regards,

      Volkmar

        • 1. Re: JBoss and app. client - name not bound error
          vickyk

          Hi,
          Try this way

          Properties p = new Properties();
          p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
          p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
          p.put(Context.PROVIDER_URL, "localhost:1099");
          Context ocontext=new InitialContext(p);

          Since you are using the Differnet JVM you require to tell the application where is the JNDI located so you have to set these properties.
          I would advice you to look the Workbook provided by orilley where they are using ant tool.
          regards
          Vicky

          • 2. Re: JBoss and app. client - name not bound error
            vman

            Thanks Vicky,

            I will try this now.
            By the way, will ant put in code such as the above bit you posted ? In other words, is Ant intelligent enough to figure these things out ?!? That would very much surprise me, but you never know...

            Thanks for your help

            Volkmar