You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by David Blevins <da...@visi.com> on 2007/07/10 21:25:07 UTC
Connection Exception cleanup
Still working on the deploy tooling and finding tons of things that
need to be cleaned. Here's a good one. Can you guess what this means?
If you executed this code on a server that wasn't started or was
using a different port than you expected:
Properties p = new Properties();
p.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.RemoteInitialContextFactory");
p.setProperty(Context.PROVIDER_URL, "ejbd://localhost:4201");
InitialContext initialContext = new InitialContext(p);
Object o = initialContext.lookup("z");
.. you'd get this exception. Pretty terrible.
<before>
WARNING: Cannot access server(s): localhost:4201 Exception:
java.io.IOException: Cannot access server: localhost:4201 Exception:
java.net.ConnectException : Connection refused
at org.apache.openejb.client.SocketConnectionFactory
$SocketConnection.open(SocketConnectionFactory.java:54)
at org.apache.openejb.client.SocketConnectionFactory.getConnection
(SocketConnectionFactory.java:34)
at org.apache.openejb.client.ConnectionManager.getConnection
(ConnectionManager.java:43)
at org.apache.openejb.client.Client.processRequest(Client.java:60)
at org.apache.openejb.client.Client.request(Client.java:40)
at org.apache.openejb.client.JNDIContext.request(JNDIContext.java:72)
at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:195)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.acme.MySuperApp.main(MySuperApp.java:23)
Error closing connection with server: null
Exception in thread "main" javax.naming.NamingException: Cannot
lookup /z: Received error: Error while communicating with server: ;
nested exception is:
java.rmi.RemoteException: Cannot access servers: Server #0: ejbd://
localhost:4201 [Root exception is java.rmi.RemoteException: Error
while communicating with server: ; nested exception is:
java.rmi.RemoteException: Cannot access servers: Server #0: ejbd://
localhost:4201]
at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:197)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.acme.MySuperApp.main(MySuperApp.java:23)
Caused by: java.rmi.RemoteException: Error while communicating with
server: ; nested exception is:
java.rmi.RemoteException: Cannot access servers: Server #0: ejbd://
localhost:4201
at org.apache.openejb.client.Client.processRequest(Client.java:169)
at org.apache.openejb.client.Client.request(Client.java:40)
at org.apache.openejb.client.JNDIContext.request(JNDIContext.java:72)
at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:195)
... 2 more
Caused by: java.rmi.RemoteException: Cannot access servers: Server
#0: ejbd://localhost:4201
at org.apache.openejb.client.Client.processRequest(Client.java:75)
... 5 more
</before>
So I've hammered on this quite a bit and now we have this :)
<after>
Exception in thread "main" javax.naming.ServiceUnavailableException:
Cannot lookup '/z'. [Root exception is java.net.ConnectException:
Cannot connect to server 'ejbd://localhost:4201'. Check that the
server is started and that the specified serverURL is correct.]
at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:201)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.acme.MySuperApp.main(MySuperApp.java:23)
Caused by: java.net.ConnectException: Cannot connect to server
'ejbd://localhost:4201'. Check that the server is started and that
the specified serverURL is correct.
at org.apache.openejb.client.SocketConnectionFactory
$SocketConnection.open(SocketConnectionFactory.java:55)
at org.apache.openejb.client.SocketConnectionFactory.getConnection
(SocketConnectionFactory.java:35)
at org.apache.openejb.client.ConnectionManager.getConnection
(ConnectionManager.java:43)
at org.apache.openejb.client.Client.processRequest(Client.java:60)
at org.apache.openejb.client.Client.request(Client.java:40)
at org.apache.openejb.client.JNDIContext.request(JNDIContext.java:74)
at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:197)
... 2 more
</after>
If you see something like this in the code, report it or fix it.
Hopefully we can get all common user-facing exceptions looking pretty
snappy and clear.
One down, who knows how many to go :)
-David
Re: Connection Exception cleanup
Posted by David Blevins <da...@visi.com>.
On Jul 10, 2007, at 1:21 PM, Jacek Laskowski wrote:
> On 7/10/07, David Blevins <da...@visi.com> wrote:
>
>> p.setProperty(Context.PROVIDER_URL, "ejbd://localhost:
>> 4201");
> ...
>> Exception in thread "main" javax.naming.ServiceUnavailableException:
>> Cannot lookup '/z'. [Root exception is java.net.ConnectException:
>> Cannot connect to server 'ejbd://localhost:4201'. Check that the
>> server is started and that the specified serverURL is correct.]
>
> It looks pretty. One question - why is it "serverURL" not
> "Context.PROVIDER_URL"?
The tricky part of that is the code that throws that exception is
used for more than just JNDI. It does all our EJB requests and
authentication requests too.
-David
Re: Connection Exception cleanup
Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 7/10/07, David Blevins <da...@visi.com> wrote:
> p.setProperty(Context.PROVIDER_URL, "ejbd://localhost:4201");
...
> Exception in thread "main" javax.naming.ServiceUnavailableException:
> Cannot lookup '/z'. [Root exception is java.net.ConnectException:
> Cannot connect to server 'ejbd://localhost:4201'. Check that the
> server is started and that the specified serverURL is correct.]
It looks pretty. One question - why is it "serverURL" not
"Context.PROVIDER_URL"?
Jacek
--
Jacek Laskowski
http://www.JacekLaskowski.pl