javax.naming.CommunicationException - help
chuckharris Aug 9, 2004 7:37 PMI have been going though the sun ejb tutorial and have run into an intermitant problem.
The Converter example (stateless) deploys fine and runs without error unless I hit it with
multiple client requests. I threaded the client to simulate multiple concurrent client
requests. If I run the client, it will generate some variation of the following logging on the
client but only occasionally. I can run the client from different command prompts at the same
time and both will run without error. Occasionally, it fails and there is no pattern to it.
The error will generate if run from the same machine or remotely.
If i run the client to make 1000 requests (see main below), it does not fail even if running in
two windows. The os is win2k, jboss 3.2.5 and Java is 1.4.2._04. Is there a setting in
ejb-jar.xml or jboss.xml that I need to include or change? Or other? Thanks. I posted a me
too on http://www.jboss.org/index.html?module=bb&op=viewtopic&t=52342. It looks like we are
both experiencing a similar issue.
snipit from the client:
public static void main(String[] args) { boolean b = false; if (b) { for (int i=0;i<1000;i++) { ConverterClient cc = new ConverterClient(); cc.run(); } } else { for (int i=0;i<14;i++) { ConverterClient cc = new ConverterClient(); cc.execute(); } } } public void execute() { Thread t = new Thread(this); t.start(); } public void run() { try { Hashtable properties = new Hashtable(); properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); properties.put(Context.PROVIDER_URL,"jnp://myip:1099"); properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interface"); //properties.put(Context.BATCHSIZE,"1000"); //properties.put("jnp.socketFactory","org.jnp.interfaces.TimedSocketFactory"); //properties.put("jnp.timeout","0"); Context initial = new InitialContext(properties); Object objref = initial.lookup("aRemote"); ConverterHome home = (ConverterHome)PortableRemoteObject.narrow(objref, ConverterHome.class); Converter currencyConverter = home.create(); BigDecimal param = new BigDecimal ("100.00"); BigDecimal amount = currencyConverter.dollarToYen(param); System.out.println(amount); amount = currencyConverter.yenToEuro(param); System.out.println(amount); currencyConverter.remove(); home.remove(currencyConverter.getHandle()); initial.close(); } catch (Exception ex) { System.err.println("Caught an unexpected exception!"); ex.printStackTrace(); } }
Logging:
log4j:WARN No appenders could be found for logger (org.jnp.interfaces.NamingContext).
log4j:WARN Please initialize the log4j system properly.
12160.00
0.77
12160.00
0.77
12160.00
12160.00
12160.00
0.77
0.77
12160.00
12160.00
12160.00
0.77
0.77
0.77
12160.00
12160.00
12160.00
0.77
0.77
12160.00
0.77
0.77
0.77
Caught an unexpected exception!
javax.naming.CommunicationException: Receive timed out [Root exception is
java.net.SocketTimeoutException: Receive
timed out]
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1119)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1196)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:516)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:509)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at ejb.stateless.ConverterClient.run(Unknown Source)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.net.SocketTimeoutException: Receive timed out
at java.net.PlainDatagramSocketImpl.peekData(Native Method)
at java.net.DatagramSocket.receive(DatagramSocket.java:661)
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1089)
... 6 more
Caught an unexpected exception!
javax.naming.CommunicationException: Receive timed out [Root exception is
java.net.SocketTimeoutException: Receive
timed out]
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1119)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1196)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:516)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:509)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at ejb.stateless.ConverterClient.run(Unknown Source)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.net.SocketTimeoutException: Receive timed out
at java.net.PlainDatagramSocketImpl.peekData(Native Method)
at java.net.DatagramSocket.receive(DatagramSocket.java:661)
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1089)
... 6 more
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'> <ejb-jar> <display-name>aRemote</display-name> <enterprise-beans> <session> <description>A test ejb</description> <display-name>aRemote</display-name> <ejb-name>aRemote</ejb-name> <home>stateless.ConverterHome</home> <remote>ejb.stateless.Converter</remote> <ejb-class>ejb.stateless.ConverterBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> <security-identity> <description/> <use-caller-identity/> </security-identity> </session> </enterprise-beans> <assembly-descriptor> <container-transaction> <method> <ejb-name>aRemote</ejb-name> <method-name>*</method-name> </method> <trans-attribute>Supports</trans-attribute> </container-transaction> </assembly-descriptor> </ejb-jar>
<?xml version="1.0"?> <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd"> <!-- Version: $Id: jboss.xml,v 1.6.2.4 2003/07/29 00:06:20 sreich Exp $ --> <jboss> <enterprise-beans> <session> <ejb-name>aRemote</ejb-name> </session> </enterprise-beans> </jboss>