1 Reply Latest reply on Mar 11, 2009 8:14 AM by iisrail

    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:

      Code:
      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() :

      Code:

      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:
      Code:
      javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:109
      9 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exce
      ption is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.Communi
      cationException: 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 [Roo
      t 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 loca
      lhost/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:

      Code:
      12:22:42,206 DEBUG [ProfileServiceBootstrap] Failed to build ManagedDeployment for: AbstractKernelDe
      ployment@18ddc48{name=file:/C:/AS/jboss-5.0.1.GA/server/default/conf/bootstrap/vfs.xml installed=tru
      e beanFactories=[AbstractBeanMetaData@12bbe6b{name=VFSCache bean=null properties=[realCache, permane
      ntRoots] constructor=AbstractConstructorMetaData@1347124{parameters=[null] factoryClass=org.jboss.vi
      rtual.spi.cache.VFSCacheFactory factoryMethod=getInstance} autowireCandidate=true start=AbstractLife
      cycleMetaData@1f02b85{ whenRequired=ControllerState@e28a61{Start} parameters= }}, AbstractBeanMetaDa
      ta@146ee9c{name=VfsNamesExceptionHandler bean=org.jboss.virtual.plugins.context.helpers.NamesExcepti
      onHandler 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/defa
      ult/conf/bootstrap/vfs.xml
       at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.jav
      a:49)
       at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataFactoryVisitor.deploy(BeanMetaDataFactoryVis
      itor.java:136)
       at org.jboss.system.server.profileservice.ProfileServiceBootstrap.initBootstrapMDs(ProfileServiceBo
      otstrap.java:453)
       at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.jav
      a: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(AbstractDeployme
      ntUnit.java:152)
       at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataFactoryVisitor.addBeanComponent(BeanMetaData
      FactoryVisitor.java:60)
       at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataFactoryVisitor.deploy(BeanMetaDataFactoryVis
      itor.java:126)
       ... 6 more


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



        • 1. 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");