3 Replies Latest reply on Mar 11, 2009 11:45 AM by peterj

    look up jndi problem

      I have communication ( may be JNDI ?) problems even by testing the simplest EJB program
      My Ejb Bean:

      @Stateless(name = "Test1")
      public class Test1 implements Test1Remote {
      
       /**
       * Default constructor.
       */
       public Test1() {
       // TODO Auto-generated constructor stub
       }
      
       public String echo (String str){
       System.out.println("Test1:echo str ="+str);
       return str;
       }


      My Remote:

      @Remote
      public interface Test1Remote {
      
       public String echo (String str);
      
      }


      My Client:

      public class Main {
       public static void main(String[] args) {
       try {
       InitialContext ctx = CmsEjbUtil.getInitialCotext();
       Test1Remote dao = (Test1Remote) ctx.lookup("Test1/remote");
       String str =dao.echo("Hello World");
       System.out.println(str);
       } catch (NamingException e) {
      
       e.printStackTrace();
       }
      
       }


      CmsEjbUtil.getInitialCotext() :

       public static InitialContext getInitialCotext() throws NamingException {
       Hashtable props = new Hashtable<String, String>();
       props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
       props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
       props.put("java.naming.provider.url", "jnp://localhost:1099");
       return new InitialContext(props);
       }


      but when I run client I get the following stack trace:
      javax.naming.CommunicationException: Could not obtain connection to any of these urls: 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/0:0:0:0:0:0:0:1:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost/0:0:0:0:0:0:0:1:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]]
       at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1725)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:689)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:682)
       at javax.naming.InitialContext.lookup(Unknown Source)
       at Main.main(Main.java:14)
      Caused by: javax.naming.CommunicationException: Failed to connect to server localhost/0:0:0:0:0:0:0:1:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost/0:0:0:0:0:0:0:1:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]
       at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:331)
       at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1696)
       ... 4 more
      Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server localhost/0:0:0:0:0:0:0:1:1099 [Root exception is java.net.ConnectException: Connection refused: connect]
       at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:301)
       ... 5 more
      Caused by: java.net.ConnectException: Connection refused: connect
       at java.net.PlainSocketImpl.socketConnect(Native Method)
       at java.net.PlainSocketImpl.doConnect(Unknown Source)
       at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
       at java.net.PlainSocketImpl.connect(Unknown Source)
       at java.net.SocksSocketImpl.connect(Unknown Source)
       at java.net.Socket.connect(Unknown Source)
       at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:97)
       at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:82)
       at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:297)
       ... 5 more


      When my server don't get any request from client.

      While boot of jboss 5.0.1 I got some errors that first error that I've got is:

      12:22:42,206 DEBUG [ProfileServiceBootstrap] Failed to build ManagedDeployment for: AbstractKernelDeployment@18ddc48{name=file:/C:/AS/jboss-5.0.1.GA/server/default/conf/bootstrap/vfs.xml installed=true beanFactories=[AbstractBeanMetaData@12bbe6b{name=VFSCache bean=null properties=[realCache, permanentRoots] constructor=AbstractConstructorMetaData@1347124{parameters=[null] factoryClass=org.jboss.virtual.spi.cache.VFSCacheFactory factoryMethod=getInstance} autowireCandidate=true start=AbstractLifecycleMetaData@1f02b85{ whenRequired=ControllerState@e28a61{Start} parameters= }}, AbstractBeanMetaData@146ee9c{name=VfsNamesExceptionHandler bean=org.jboss.virtual.plugins.context.helpers.NamesExceptionHandler properties= constructor=AbstractConstructorMetaData@1db52c8{parameters=[java.lang.String]} autowireCandidate=true}]}
      org.jboss.deployers.spi.DeploymentException: Error deploying: file:/C:/AS/jboss-5.0.1.GA/server/default/conf/bootstrap/vfs.xml
       at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)
       at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataFactoryVisitor.deploy(BeanMetaDataFactoryVisitor.java:136)
       at org.jboss.system.server.profileservice.ProfileServiceBootstrap.initBootstrapMDs(ProfileServiceBootstrap.java:453)
       at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:199)
       at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:405)
       at org.jboss.Main.boot(Main.java:209)
       at org.jboss.Main$1.run(Main.java:547)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.IllegalStateException: ClassLoader has not been set
       at org.jboss.deployers.structure.spi.helpers.AbstractDeploymentUnit.getClassLoader(AbstractDeploymentUnit.java:152)
       at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataFactoryVisitor.addBeanComponent(BeanMetaDataFactoryVisitor.java:60)
       at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataFactoryVisitor.deploy(BeanMetaDataFactoryVisitor.java:126)
       ... 6 more


      Could it be the prooblems stems from my OS Vista? Please help.





        • 1. Re: look up jndi problem

          My jdk 1.5, jboss 5.0.1, OS Vista

          • 2. Re: look up jndi problem

            I found what causes the problem. My computer stopped because some reason understand localhost so where I've changed it to 127.0.0.1 it worked fine.

            props.setProperty("java.naming.provider.url", "jnp://127.0.0.1:1099");


            • 3. Re: look up jndi problem
              peterj

              The name 'localhost' should always map to '127.0.0.1'. If it doesn't, most likely your hosts file is incorrect. Look in c:\windows\system32\drivers\etc\hosts. On my Vista box I have these entries (the first is for IPv4, the second for IPv6):

              127.0.0.1 localhost
              ::1 localhost