1 Reply Latest reply on May 21, 2007 7:46 AM by kbird

    javax.naming.CommunicationException: Could not obtain connec

    kbird

      hi call i was trying a sample program ejb3,

      i am using the database mysql, ejb 3 deployed to jboss 4.0.4

      but in jboss cmd, i got some thing like this as well.

      -----------------------------------------------------------

      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
      ObjectName: jboss:service=Naming
      State: FAILED
      Reason: java.rmi.server.ExportException:
      Port already in use: 1098; nested exception is:
      java.net.BindException: Address already in use: JVM_Bind
      I Depend On:
      jboss.system:service=ThreadPool
      Depends On Me:
      jboss.ws:service=WebServiceClientDeployer
      jboss.ws.eventing:service=SubscriptionManager
      jboss.mq:service=DestinationManager
      jboss.mq:service=Invoker
      jboss.mq:service=InvocationLayer,type=UIL
      jboss.mq:service=InvocationLayer,type=UILXA
      jboss.mq:service=InvocationLayer,type=UIL2,alias=UIL2ConnectionFactory
      jboss.mq:service=InvocationLayer,type=UIL2XA,alias=UIL2XAConnectionFactory
      jboss.jms:alias=QueueConnectionFactory
      jboss.jms:alias=TopicConnectionFactory
      jboss.jmx:type=adaptor,name=Invoker,protocol=jrmp,service=proxyFactory
      jboss.jmx:alias=jmx/rmi/RMIAdaptor
      jboss:service=TransactionManager

      ObjectName: jboss.jca:service=RARDeployment,name='jboss-local-jdbc.rar'
      State: NOTYETINSTALLED
      Depends On Me:
      jboss.jca:service=ManagedConnectionFactory,name=DefaultDS
      jboss.jca:service=ManagedConnectionFactory,name=MySqlDS

      ObjectName: jboss.jca:service=RARDeployment,name='jms-ra.rar'
      State: NOTYETINSTALLED
      Depends On Me:
      jboss.jca:service=ManagedConnectionFactory,name=JmsXA

      -----------------------------------------------------------



      my client code,

      ---------------------------

      Properties prop = new Properties();
      prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      prop.put(Context.PROVIDER_URL, "localhost:1099");

      Context initial;
      try {
      initial = new InitialContext(prop);
      Calculator beanRemote = (Calculator)initial.lookup("EJB3Sample/EntityCalculator");
      beanRemote.addFund("abc",0.1);
      beanRemote.addFund("Blaze",0.2);
      beanRemote.addFund("Apocalips",0.05);
      beanRemote.addInvestor("El DeCarcia",25,55);
      beanRemote.addInvestor("Marlon Brandes",20,60);

      for (int i = 1; i < 4; i++) {
      beanRemote.calculate(i,4-i,i*100*0.8);
      }

      beanRemote.getRecords();
      } catch (NamingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      }


      ---------------------------

      when i tried to run the code, i got the following error, Can any one tell me whats going wrong


      ----------------------------------------------------------------

      [java] 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:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]]
      [java] at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1414)
      [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:594)
      [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
      [java] at javax.naming.InitialContext.lookup(Unknown Source)
      [java] at test.com.samples.entity.basic.Client.main(Unknown Source)
      [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [java] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      [java] at java.lang.reflect.Method.invoke(Unknown Source)
      [java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:202)
      [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:134)
      [java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:710)
      [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:178)
      [java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:84)
      [java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
      [java] at org.apache.tools.ant.Task.perform(Task.java:364)
      [java] at org.apache.tools.ant.Target.execute(Target.java:341)
      [java] at org.apache.tools.ant.Target.performTasks(Target.java:369)
      [java] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
      [java] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
      [java] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
      [java] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
      [java] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
      [java] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
      [java] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
      [java] 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]]
      [java] at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:269)
      [java] at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1385)
      [java] ... 24 more
      [java] Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]
      [java] at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:243)
      [java] ... 25 more
      [java] Caused by: java.net.ConnectException: Connection refused: connect
      [java] at java.net.PlainSocketImpl.socketConnect(Native Method)
      [java] at java.net.PlainSocketImpl.doConnect(Unknown Source)
      [java] at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
      [java] at java.net.PlainSocketImpl.connect(Unknown Source)
      [java] at java.net.SocksSocketImpl.connect(Unknown Source)
      [java] at java.net.Socket.connect(Unknown Source)
      [java] at java.net.Socket.connect(Unknown Source)
      [java] at java.net.Socket.(Unknown Source)
      [java] at java.net.Socket.(Unknown Source)
      [java] at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:84)
      [java] at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:77)
      [java] at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:239)
      [java] ... 25 more

      -------------------------------------------------------

        • 1. Re: javax.naming.CommunicationException: Could not obtain co
          kbird

          well, i tried the netstat to see if the port of running already or listening already and i tried to kill it if it were, but the it was not.

          then, searching the in the other forums suggested that this porblem could be a of java update. well when i restarted the machine it got working(sort of a strange prob though!!!!!!)

          until this same error comes again to me.....