1 Reply Latest reply on Jul 21, 2013 5:27 AM by Wolf-Dieter Fink

    javax.naming.CommunicationException: Receive timed out

    Krzysztof Muller Newbie

      Hi I started book "enterprise javaBean 3.0" and I have some problems with exercise 4 somebody help me? I read a lot of pages and I didn't find clear answer ...

       

       

      package com.titan.clients;

      import java.util.Properties;

       

      import javax.naming.Context;

      import javax.naming.InitialContext;

      import javax.rmi.PortableRemoteObject;

       

      import com.titan.domain.Cabin;

      import com.titan.travelagent.TravelAgentRemote;

       

      public class Client {

       

              /**

               * @param args

               */

              public static void main(String[] args) {

                      try{

                              Context jndiContext=getInitialContext();

                              Object ref=jndiContext.lookup("TravelAgentBean/remote");

                              TravelAgentRemote dao=(TravelAgentRemote)PortableRemoteObject.narrow(ref, TravelAgentRemote.class);

                            

                              Cabin cabin_1=new Cabin();

                              cabin_1.setId(1);

                              cabin_1.setName("Master Suite");

                              cabin_1.setDeckLevel(1);

                              cabin_1.setShipId(1);

                              cabin_1.setBedCount(3);

                            

                              dao.createCabin(cabin_1);

                            

                              Cabin cabin_2=dao.findCabin(1);

                              System.out.println(cabin_2.getName());

                              System.out.println(cabin_2.getDeckLevel());

                              System.out.println(cabin_2.getShipId());

                              System.out.println(cabin_2.getBedCount());

                      }catch(javax.naming.NamingException ne){

                              ne.printStackTrace();

                      }

              }

       

              public static Context getInitialContext()throws javax.naming.NamingException{

                      Properties p=new Properties();

                      p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

                      p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");

                      p.put(Context.PROVIDER_URL, "jnp://localhost:1099");

       

                      return new javax.naming.InitialContext(p);

              }

      }

       

       

       

      Buildfile: C:\Users\lato\Workspace_all\Work3_JSF\ex04_1\build.xml

      prepare:

      complie:

          [javac] C:\Users\lato\Workspace_all\Work3_JSF\ex04_1\build.xml:69: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

          [javac] Compiling 4 source files to C:\Users\lato\Workspace_all\Work3_JSF\ex04_1\build\classes

      prepare:

      complie:

          [javac] C:\Users\lato\Workspace_all\Work3_JSF\ex04_1\build.xml:69: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

          [javac] Compiling 4 source files to C:\Users\lato\Workspace_all\Work3_JSF\ex04_1\build\classes

      package:

            [jar] Building jar: C:\Users\lato\Workspace_all\Work3_JSF\ex04_1\build\titan.jar

      deploy:

           [copy] Copying 1 file to G:\Praca-Java\jboss-as-7.1.1.Final\server\default\deploy

      run.client:

           [java] javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]

           [java]     at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1302)

           [java]     at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1382)

           [java]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:579)

           [java]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)

           [java]     at javax.naming.InitialContext.lookup(Unknown Source)

           [java]     at com.titan.clients.Client.main(Unknown Source)

           [java] Caused by: java.net.SocketTimeoutException: Receive timed out

           [java]     at java.net.PlainDatagramSocketImpl.receive0(Native Method)

           [java]     at java.net.PlainDatagramSocketImpl.receive(Unknown Source)

           [java]     at java.net.DatagramSocket.receive(Unknown Source)

           [java]     at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1272)

           [java]     ... 5 more

      BUILD SUCCESSFUL

      Total time: 9 seconds