2 Replies Latest reply on Feb 12, 2006 3:08 PM by Juan

    Error with JNDI Remote Binding

    Juan Newbie

      Hi, i have a problem with JNDI Remote Binding in my client application with the new JBossAS4.0.4-EJB3.
      The deploy-jar structrue here:

      infonds2server.ear:
       |----META-INF
       |----application.xml
       |----jboss-app.xml
       |----business.jar
       |----entities.jar
       |----META-INF
       |----persistence.xml
      

      application.xml:
      <?xml version="1.0" encoding="UTF-8"?>
      <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
       <display-name>infonds2</display-name>
       <description>Cleversoft Infonds2</description>
      
       <module>
       <ejb>beans.jar</ejb>
       </module>
      
       <module>
       <ejb>sessions.jar</ejb>
       </module>
      
      </application>
      

      jboss-app.xml:
      <!DOCTYPE jboss-app
       PUBLIC "-//JBoss//DTD J2EE Application 1.4//EN"
       "http://www.jboss.org/j2ee/dtd/jboss-app_4_0.dtd">
      <jboss-app>
       <loader-repository>
       infonds2:app=ejb3
       </loader-repository>
      </jboss-app>
      

      persistence.xml
      <entity-manager>
       <name>infonds2</name>
       <jta-data-source>java:/infonds2</jta-data-source>
       <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
       <property name="hibernate.show_sql"
      value="true"/>
       </properties>
      </entity-manager>
      

      the Stateless SessionBean:
      @Stateless
      @Local ({IInfondsQuery.class})
      @LocalBinding (jndiBinding="infonds2/LocalInfondsQuery")
      @Remote ({IInfondsQuery.class})
      @RemoteBinding (jndiBinding="infonds2/RemoteInfondsQuery")
      public class InfondsQueryBean implements IInfondsQuery, Serializable {
      
       private static final Log log = InfondsLogger.newLog(InfondsQueryBean.class);
      
       @PersistenceContext(unitName = "infonds2")
       private EntityManager entityManager;
      ......
      ......
      

      the remote client application:
       public IInfondsQuery getInfondsQuery(){
       try {
       Properties env = new Properties();
       env.setProperty(Context.PROVIDER_URL,"localhost:1099");
       env.setProperty(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
       env.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
       ctx = new InitialContext(env);
      
       return (IInfondsQuery) ctx.lookup("infonds2/RemoteInfondsQuery");
       } catch (NamingException e) {
       e.printStackTrace();
       }
       return null;
       }
      

      the ejb3 deployment-info in JBossAS4.0.4:
      10:20:40,562 INFO [EARDeployer] Init J2EE application: file:/D:/server/jboss-4.0.4RC1/server/default/deploy/infonds2server.ear
      10:20:41,093 INFO [Ejb3Deployment] EJB3 deployment time took: 281
      10:20:41,250 INFO [Ejb3AnnotationHandler] found EJB3: ejbName=InfondsErrorBean, class=eu.cleversoft.infonds2.business.InfondsErrorBean, type=STATEFUL
      10:20:41,343 INFO [Ejb3AnnotationHandler] found EJB3: ejbName=InfondsLoginBean, class=eu.cleversoft.infonds2.business.InfondsLoginBean, type=STATEFUL
      10:20:41,359 INFO [Ejb3AnnotationHandler] found EJB3: ejbName=InfondsPersistenceBean, class=eu.cleversoft.infonds2.business.InfondsPersistenceBean, type=STATEFUL
      10:20:41,390 INFO [Ejb3AnnotationHandler] found EJB3: ejbName=InfondsQueryBean, class=eu.cleversoft.infonds2.business.InfondsQueryBean, type=STATELESS
      10:20:41,453 INFO [Ejb3AnnotationHandler] found EJB3: ejbName=InfondsSecurityBean, class=eu.cleversoft.infonds2.business.InfondsSecurityBean, type=STATEFUL
      10:20:41,453 INFO [Ejb3Deployment] EJB3 deployment time took: 328
      10:20:41,468 INFO [EJB3Deployer] Deployed: file:/D:/server/jboss-4.0.4RC1/server/default/tmp/deploy/tmp8434infonds2server.ear-contents/beans.jar
      10:20:41,609 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:service=EJB3,ear=infonds2server.ear,jar=sessions.jar,name=InfondsErrorBean with dependencies:
      10:20:41,609 INFO [JmxKernelAbstraction] persistence.units:unitName=infonds2
      10:20:41,609 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:service=EJB3,ear=infonds2server.ear,jar=sessions.jar,name=InfondsLoginBean with dependencies:
      10:20:41,609 INFO [JmxKernelAbstraction] persistence.units:unitName=infonds2
      10:20:41,625 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:service=EJB3,ear=infonds2server.ear,jar=sessions.jar,name=InfondsPersistenceBean with dependencies:
      10:20:41,625 INFO [JmxKernelAbstraction] persistence.units:unitName=infonds2
      10:20:41,625 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:service=EJB3,ear=infonds2server.ear,jar=sessions.jar,name=InfondsQueryBean with dependencies:
      10:20:41,625 INFO [JmxKernelAbstraction] persistence.units:unitName=infonds2
      10:20:41,625 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:service=EJB3,ear=infonds2server.ear,jar=sessions.jar,name=InfondsSecurityBean with dependencies:
      10:20:41,625 INFO [JmxKernelAbstraction] persistence.units:unitName=infonds2
      10:20:41,640 INFO [EJB3Deployer] Deployed: file:/D:/server/jboss-4.0.4RC1/server/default/tmp/deploy/tmp8434infonds2server.ear-contents/sessions.jar
      10:20:41,656 INFO [EARDeployer] Started J2EE application: file:/D:/server/jboss-4.0.4RC1/server/default/deploy/infonds2server.ear
      

      So if i run this test in the client application, it throws this Exception:
      javax.naming.NameNotFoundException: infonds2 not bound
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
       at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
       at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
       at sun.rmi.transport.Transport$1.run(Unknown Source)
       at java.security.AccessController.doPrivileged(Native Method)
       at sun.rmi.transport.Transport.serviceCall(Unknown Source)
       at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
       at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
       at java.lang.Thread.run(Unknown Source)
       at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
       at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
       at sun.rmi.server.UnicastRef.invoke(Unknown Source)
       at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
       at javax.naming.InitialContext.lookup(Unknown Source)
       at eu.cleversoft.infonds2.servicelocator.ServiceLocator.getInfondsQuery(ServiceLocator.java:104)
       at eu.cleversoft.infonds2.ui.tools.databinding.Test.testUpdateInfondsPartner(Test.java:61)
       at eu.cleversoft.infonds2.ui.tools.databinding.Test.main(Test.java:26)
      Exception in thread "main" java.lang.NullPointerException
       at eu.cleversoft.infonds2.ui.tools.databinding.Test.testUpdateInfondsPartner(Test.java:61)
       at eu.cleversoft.infonds2.ui.tools.databinding.Test.main(Test.java:26)
      


      I have also testet for "return (IInfondsQuery) ctx.lookup(IInfondsQuery.class.getName());" and "return (IInfondsQuery) ctx.lookup("java:/infonds2/InfondsQueryBean/remote");", but have the same error.

      I find in the link(http://trailblazer.demo.jboss.com/EJB3Trail/background/deploy/index.html) of Trailbrazers & Demo about new jndi config for remote binding in JBossAS4.0.4 is perhaps not clearly, or perhaps i have a mistake. Thanks for your feedbacks!


        • 1. Re: Error with JNDI Remote Binding
          Juan Newbie

          sorry for my writing error in the begin of this post top:
          the jar structure of infonds2server.ear shoulb be like this:

          infonds2server.ear:
           |----META-INF
           |----application.xml
           |----jboss-app.xml
           |----sessions.jar
           |----beans.jar
           |----META-INF
           |----persistence.xml
          


          So my JNDI Remote Binding problem is still there, here is only my correct about my post writing error.

          • 2. Re: Error with JNDI Remote Binding
            Juan Newbie

            I have found my config errors in the new JBoss 4.0.4RC1:
            the shema of persistence.xml is changed:
            the new persistence.xml look like this:

            <persistence>
             <persistence-unit name="infonds2">
             <jta-data-source>java:/infonds2</jta-data-source>
             <properties>
             <property name="hibernate.hbm2ddl.auto"
             value="none"/>
             <property name="hibernate.dialect"
             value="org.hibernate.dialect.MySQLInnoDBDialect"/>
             </properties>
             </persistence-unit>
            </persistence>
            


            It runs now with deployment. Thanks.