1 2 Previous Next 25 Replies Latest reply on May 15, 2008 2:04 PM by prps1234

    Remote Client to EJB 3.0 fail .. :( javax.naming.Communicati

    j0ke

      Hello i have want to try EJB 3.0 but i have problems.
      the problem is this i have EJB 3.0 like this :
      package beans;

      import javax.ejb.Stateless;

      @Stateless(name="SimpleSession")
      public class SimpleSessionBean implements SimpleSession {
      public SimpleSessionBean() {
      }

      public String sayHello(String name) {
      return "Hello "+name;
      }
      }

      package beans;

      import javax.ejb.Remote;

      @Remote
      public interface SimpleSession {
      public String sayHello(String name) ;
      }


      and i make test client for it .

      package client;

      import beans.SimpleSession;

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

      public class SimpleSessionClient {
      public static void main(String[] args) {
      InitialContext ctx;
      try {


      ctx = new InitialContext();
      ctx.addToEnvironment("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      ctx.addToEnvironment("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      ctx.addToEnvironment(Context.PROVIDER_URL,"jnp://localhost:1099");
      SimpleSession simpleSession
      = (SimpleSession) ctx.lookup(SimpleSession.class.getName());
      System.out.println(simpleSession.sayHello("EJB3"));
      } catch (NamingException e) {
      e.printStackTrace();
      }
      }
      }


      but when i delpoy the EJB and start the client i get :
      cannot find : org.jboss.naming:org.jnp.interfaces
      Nothink UNNORAML
      i add to the CLASSPATH everythink in jbossServer/client/*.jars
      when i start now i get :


      log4j:WARN No appenders could be found for logger (org.jnp.interfaces.NamingContext).
      log4j:WARN Please initialize the log4j system properly.
      javax.naming.CommunicationException: Could not obtain connection to any of these urls: jnp://localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]]
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1414)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:594)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at client.SimpleSessionClient.main(SimpleSessionClient.java:19)
      Caused by: javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:269)
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1385)
      ... 4 more
      Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:243)
      ... 5 more
      Caused by: java.net.ConnectException: Connection refused: connect
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:364)
      at java.net.Socket.connect(Socket.java:507)
      at java.net.Socket.connect(Socket.java:457)
      at java.net.Socket.(Socket.java:365)
      at java.net.Socket.(Socket.java:265)
      at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:84)
      at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:76)
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:239)
      ... 5 more
      Process exited with exit code 0.

      i try with just "localhost" and "jnp://localhost" but then the problem is the same.

        • 1. Re: Remote Client to EJB 3.0 fail .. :( javax.naming.Communi
          peterj

          Did you, by any chance, change the JNDI port?

          What operating system are you running on? Are you running a firewall and have your configured it properly?

          • 2. Re: Remote Client to EJB 3.0 fail .. :( javax.naming.Communi
            j0ke

            Windows XP SP2.
            No Firewall its off.
            JBoss 4.0.4 and 4.0.3 result is the same
            ejb3 enabled
            when i install FULL (ALL) installation of JBOss 4.0.4 EJB 2.1 works fine EJB 3.0 dont deploy i think that it search for descriptors then and the error then is no bound "EJbName" .
            But with ejb3 enable and EJB the problem is this i test it on 2 pc's result is the same am i wrong somewhere ?
            How can i change this port ?

            • 3. Re: Remote Client to EJB 3.0 fail .. :( javax.naming.Communi
              j0ke

              another strange problem
              when i deploy EJB3 with ejb3 enabled ( i mean installed jbos from installer.jar and check the EJB3 support ) . So.. when i open web-console i and go to ear of the EJB and click on it nothink happened .. i cant see the EJB name like when it is EJB 2.1 i cant see how match instances are created and etc.

              • 4. Re: Remote Client to EJB 3.0 fail .. :( javax.naming.Communi
                peterj

                Looking at the original post again, I see that you have a standalone client app from which you are attempting to look up the EJB. When you run that client app, are you providing the necessary jar files in the classpath? I thought I had a script file that ran an EJB3 client, but I cannot seem to find it (it's probably at home on my laptop). As a guess, include jbossall-client.jar, jboss-ejb3-client.jar and jboss-ejb3x.jar, all from the client directory, in your client's classpath.

                Also, look at the EJB3Trail: http://trailblazer.demo.jboss.com/EJB3Trail/

                • 5. Re: Remote Client to EJB 3.0 fail .. :( javax.naming.Communi
                  j0ke

                  i have included all the jboss\client jars to my classpath
                  becouse if i dont include them at that line :
                  ctx.addToEnvironment("java.naming.factory.url.pkgs",
                  "org.jboss.naming:org.jnp.interfaces");
                  it throws error cant find org.jboss.naming .. .etc.
                  btw i have installed JBoss AGAIN 4.0.4- PATCH 1.
                  now my web consoile dont work
                  but when i deploy the same EJB and run the SAME client i get :
                  javax.naming.NameNotFoundException: beans.SimpleSession not bound
                  witch is step forward but i dont know why the EJB is not delpoyed how can i check what EJBs are deployed and what not ?

                  • 6. Re: Remote Client to EJB 3.0 fail .. :( javax.naming.Communi
                    j0ke

                    the code is the same :
                    public static void main(String[] args) {

                    InitialContext ctx;
                    try {

                    ctx = new InitialContext();
                    ctx.addToEnvironment("java.naming.factory.initial",
                    "org.jnp.interfaces.NamingContextFactory");
                    ctx.addToEnvironment("java.naming.factory.url.pkgs",
                    "org.jboss.naming:org.jnp.interfaces");
                    ctx.addToEnvironment(Context.PROVIDER_URL, "jnp://localhost:1099");
                    SimpleSession simpleSession =
                    (SimpleSession)ctx.lookup(SimpleSession.class.getName());
                    System.out.println(simpleSession.sayHello("EJB3"));
                    } catch (NamingException e) {
                    e.printStackTrace();
                    }



                    stack :
                    javax.naming.NameNotFoundException: beans.SimpleSession 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:296)
                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja

                    when i try
                    java:comp/env/beans/SimpleSession for name not SimpleSession.class.getName() i get
                    javax.naming.NameNotFoundException: comp 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(NativeMethodAccessorImpl.java:39)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    at java.lang.reflect.Method.invoke(Method.java:585)
                    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
                    at sun.rmi.transport.Transport$1.run(Transport.java:153)
                    at java.security.AccessController.doPrivileged(Native Method)

                    • 7. Re: Remote Client to EJB 3.0 fail .. :( javax.naming.Communi
                      j0ke

                      I delpoy EAR file with EJB is there a chance JBOSS to expect (need) JAR instead of EAR ?

                      • 8. Re: Remote Client to EJB 3.0 fail .. :( javax.naming.Communi
                        peterj

                        Deploying an ear file is fine, that is how I usually deploy my ejbs. What are the contents of your ear file? Run "jar tf ear-file-name" and post the results. If the ear file contains a jar file (or a war file), repeat the "jar tf" for those files (you will have to unpack the ear first).

                        You can see what EJBs are deployed by looking at the console output., You should see something like this:

                        13:13:06,866 INFO [Ejb3Deployment] EJB3 deployment time took: 31
                        13:13:06,882 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=calc2-ejb-1.0.jar,name=StatefulCalculator,service=EJB3 with dependencies:
                        13:13:06,913 INFO [EJBContainer] STARTED EJB: peter.ejb3.calc2.StatefulCalculator ejbName: StatefulCalculator
                        13:13:06,960 INFO [EJB3Deployer] Deployed: file:/D:/apps/jboss-4.0.4.GA-src/build/output/jboss-4.0.4.GA-ejb3/server/default/deploy/calc2-ejb-1.0.jar
                        


                        Using jmx-console, and using JNDIView mbean to look at the global namespace, I see:

                        +- StatefulCalculator (class: org.jnp.interfaces.NamingContext)
                         | +- remote (class: java.lang.Object)
                         | +- remoteStatefulProxyFactory (proxy: $Proxy71 implements interface org.jboss.ejb3.ProxyFactory)






                        • 9. Re: Remote Client to EJB 3.0 fail .. :( javax.naming.Communi
                          j0ke

                          jar tf ear fail
                          META-INF/application.xml
                          SimpleSessionBean.jar
                          jar tf jar fail
                          beans/SimpleSession.class
                          beans/SimpleSessionBean.class
                          When i deploy i see :
                          23:28:12,296 INFO [EARDeployer] Undeploying J2EE application, destroy step: fil
                          e:/G:/jboss-4.0.4.GA/server/default/deploy/SimpleSessionBean.ear
                          23:28:12,296 INFO [EARDeployer] Undeployed J2EE application: file:/G:/jboss-4.0
                          .4.GA/server/default/deploy/SimpleSessionBean.ear
                          23:28:12,296 INFO [EARDeployer] Init J2EE application: file:/G:/jboss-4.0.4.GA/
                          server/default/deploy/SimpleSessionBean.ear
                          23:28:12,375 INFO [Ejb3Deployment] EJB3 deployment time took: 16
                          23:28:12,390 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=Simpl
                          eSessionBean.ear,jar=SimpleSessionBean.jar,name=SimpleSession,service=EJB3 with
                          dependencies:
                          23:28:12,406 INFO [EJBContainer] STARTED EJB: beans.SimpleSessionBean ejbName:
                          SimpleSession
                          23:28:12,421 INFO [EJB3Deployer] Deployed: file:/G:/jboss-4.0.4.GA/server/defau
                          lt/tmp/deploy/tmp25139SimpleSessionBean.ear-contents/SimpleSessionBean.jar
                          23:28:12,421 INFO [EARDeployer] Started J2EE application: file:/G:/jboss-4.0.4.
                          GA/server/default/deploy/SimpleSessionBean.ear


                          lol SOMETHINK STRANGE
                          in JMX console
                          i see SimpleSessionBean but in j2ee apps :
                          jboss.j2ee
                          ear=SimpleSessionBean.ear,jar=SimpleSessionBean.jar,name=SimpleSession,service=EJB3
                          module=SimpleSessionBean.jar,service=EJB3

                          • 10. Re: Remote Client to EJB 3.0 fail .. :( javax.naming.Communi
                            j0ke

                            yep and the problem comes from application.xml..
                            witch JDeveloper is generate
                            <?xml version = '1.0' encoding = 'windows-1251'?>
                            <application 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" version="1.4" xmlns="http://java.sun.com/xml/ns/j2ee">
                            <display-name>SimpleSessionBean</display-name>

                            SimpleSessionBean.jar



                            what must be contained in the ear fail with jar fail ? for EJB 3.0 ear.

                            • 11. Re: Remote Client to EJB 3.0 fail .. :( javax.naming.Communi
                              j0ke

                              yes and the problem comes from application.xml fail it contains :
                              <?xml version = '1.0' encoding = 'windows-1251'?>
                              <application 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" version="1.4" xmlns="http://java.sun.com/xml/ns/j2ee">
                              <display-name>SimpleSessionBean</display-name>

                              SimpleSessionBean.jar



                              what i must put in the ear file for EJB 3.0 EAR. ?

                              • 12. Re: Remote Client to EJB 3.0 fail .. :( javax.naming.Communi
                                peterj

                                The entry you found in the jmx-console was not for the EJB, but rather for the mbean that was automatically created for the EJB. To look at the JNDI namespace, in the jmx-console, click on the service=JNDIView entry under the jboss namespace, then click on the Invoke button under the list() operation.

                                According to the console output, you should use the name "SimpleSession" to look up the EJB.

                                • 13. Re: Remote Client to EJB 3.0 fail .. :( javax.naming.Communi
                                  j0ke

                                  I am at work and i have created new EJB
                                  and deloy it its 1:1 with beffore and JBoss version here is 4.0.4- patch 1
                                  The EJB is
                                  @Stateless(name="SimpleEJB")
                                  public class SimpleEJBBean implements SimpleEJB {
                                  public SimpleEJBBean() {
                                  }
                                  public String sayHello(String name) {
                                  return "Hello "+name;
                                  }
                                  }
                                  the EAR is the same with application.xml in it.
                                  and the JNDIView says this :
                                  listXML() invoke :
                                  4.0.3 EJB 3 deploy
                                  org.jnp.interfaces.NamingContext

                                  SimpleEJB
                                  org.jnp.interfaces.NamingContext

                                  remote
                                  $Proxy65


                                  but in my test client
                                  public class TestClient {
                                  public static void main(String [] args) {
                                  try {
                                  final Context context = getInitialContext();
                                  SimpleEJB sessEJBTest = (SimpleEJB)context.lookup("SimpleEJB");

                                  sessEJBTest.sayHello("exxx");
                                  } catch (Exception ex) {
                                  ex.printStackTrace();
                                  }
                                  }

                                  private static Context getInitialContext() throws NamingException {
                                  Hashtable environment = new Hashtable();
                                  environment.put(Context.INITIAL_CONTEXT_FACTORY,
                                  "org.jnp.interfaces.NamingContextFactory");
                                  environment.put(Context.URL_PKG_PREFIXES,
                                  "org.jboss.naming:org.jnp.interfaces");

                                  environment.put(Context.PROVIDER_URL, "jnp://localhost:1099");
                                  return new InitialContext(environment);
                                  }

                                  }
                                  result is the same :
                                  javax.naming.NameNotFoundException: SimpleEJB 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)

                                  • 14. Re: Remote Client to EJB 3.0 fail .. :( javax.naming.Communi
                                    j0ke

                                    how can i scan all contexts for the bean is there a subcontext or somehtink :(
                                    help pls.
                                    PeterJ your the only hope :)

                                    1 2 Previous Next