I am experiencing a strange problem: I can not execute any business methods on my ejb 3.0 stateless session bean. Looking up the remote interface is no problem but any executed remote method leads to a CannotConnectException.
Here is my client side code:
public void testRemoteMethod()
Properties properties = new Properties();
context = new InitialContext(properties);
RemoteFacade beanRemote = (RemoteFacade)context.lookup("ejb/RemoteFacade");
catch (Exception e)
I get the following exception:
org.jboss.remoting.CannotConnectException: Can not get connection to server. Problem establishing socket connection.
at $Proxy0.runTournament(Unknown Source)
System: Windows XP 5.1 (SP2), JBoss 4.0.4 GA, with EJB 3.0 extension (out of the box installation with provided installer).
Any help appreciated!
First, the standard JBoss JNDI port is 1099, not 1299. Di you change the port number? The error you are getting is that noone is listening on port 1299.
Second, remove the euqual sign from the value of the second property setting:
Third, you cannot cast a remote interface directly, use PortableRemoteObject.narrow.
Object obj = context.lookup("ejb/RemoteFacade");
RemoteFacade beanRemote = (RemoteFacade)PortableRemoteObject.narrow(obj, RemoteFacade.class);
Thanks for your answer. When going through my initial poste I noticed that i forgot to mention the JVM used. Both server and client are running on the same JVM version (1.5.0_06-b05).
Now to the results of your suggestions.
Our server is listing on Port 1299 (we do not use the default config). As we can perform the lookup of the remote object without getting an exception the server is listening on this port.
I tried "java.naming.factory.url.pkgs" with and without equal sign, but it had no effect whatsorever.
I inserted PortableRemoteObject.narrow but still the call on the remote method fails.
As I see it there must be another problem. It could be related to RMI or even on a lower level as the error message states "Problem establishing socket connection".
Another reason could be that we are using the wrong libraries. Currently we are using the following libraries (all provided with JBoss 4.0.4GA):
Any further help is greatly appreciated :-)
Do you have a firewall? What operating system are you using?
In the standard JBoss installation, the port 1099 and 1098 are required for RMI. Perhaps port 1098 (or its equivalent, if you changed the port) is blocked.
Other ports to consider are 4444 and 4445. I know I had to open those also, but can't recall if that was necessary only for accessing MBeans, or for EJBs also.
I am on Windows 5.1 (XP with SP2). I somehow have the same feeling as you: it looks like as if the internal windoze firewall is blocking my calls.
I had try on another machine and there I had absolutely no problems.
Therefore I will examine my firewall a bit closer. Funy enough that my JBoss 4.0.3 SP1 runs without any hassle.
I forgot to mention that the 4.0.3SP1 instance is running on other ports (default +100, means 8180, 1199 1198, etc). Therefore the ports 1298, 1299, etc are not taken by this instance.
I finally find out what the problem is:
It is a damned annoying bug in JBoss. JBoss version 4.0.4GA RC8 can't handle different ports settings other the ports-default.
The bug will be fixed in RC9. See http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3969990#3969990 if you want to know more.
....and you're not using @Service? That's what the issue you've linked to involves.
If you find me on this AIM screen name you can send me your EJB. I'll see if it's related to that same issue, and if so, send you a patched EJB3 JAR for 4.0.4GA that corrects the JBoss bug until Bill-n-co release EJB3 RC9.
I'd like to apologize for my late answer due to my vacation last week.
And yes I do not use @Service. Just @Remote in the remote interface and @Stateless in the bean.
AS RC9 is out I gonna have another try. I come back when I know more.
With updating to EJB3.0 RC9 our problem has been solved. JBoss handles the ports settings correctly now and we can run it with others then just ports-default.
I truly hope the guys from JBoss make it this time to keep the faulty code out and not merge it in again in a later release....
PS: and thanks for RC9 ;-)