| Author |
Failed to connect to server localhost:1099, RemoteAccessException, SocketException
|
Vish Shukla
Ranch Hand
Joined: Oct 12, 2008
Posts: 100
|
|
Hi,
I have my web application deployed in Tomcat, I am trying call remote method of Session bean, deployed in JBoss. Here is my client code for lookup.
When the servlet for lookup runs, I get following stack trace.
javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: java.security.AccessControlException: access denied (java.net.SocketPermission localhost:1024- listen,resolve) [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is java.security.AccessControlException: access denied (java.net.SocketPermission localhost resolve)]]
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1727)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:680)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:673)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.nextenders.server.actions.common.Login.login(Login.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.googlcode.strut2gwtplugin.interceptor.GWTServlet.processCall(GWTServlet.java:127)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at com.googlcode.strut2gwtplugin.interceptor.GWTInterceptor.intercept(GWTInterceptor.java:49)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at com.nextenders.server.TestInterceptor.intercept(TestInterceptor.java:24)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:422)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:54)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:306)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:313)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:844)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:644)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:205)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
Caused by: javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is java.security.AccessControlException: access denied (java.net.SocketPermission localhost resolve)]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:311)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1698)
... 45 more
Caused by: java.security.AccessControlException: access denied (java.net.SocketPermission localhost resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:76)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getByName(Unknown Source)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:81)
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:277)
... 46 more
I am not sure which all jars of JBoss to add in the classpath. So is this issue related to adding jars in classpath?
Thanks in advance.
|
Thanks & Regards,
Vishal S Shukla (SCJP 93%, SCWCD 94%, SCBCD 100%)
|
 |
Vish Shukla
Ranch Hand
Joined: Oct 12, 2008
Posts: 100
|
|
I tried to isolate this issue and found that it occurs only when I do lookup from the Service layer of GWT. But the exceptions are there right behind me.... When I try to execute it in pure Servlet, I get ClassCastException: java.naming.Reference can not be cast to com.nt.HelloUserBean. For this ClassCastException I have posted separate thread .
For my current project, I need to use it in both the ways from GWT Service layer & from Servlet.
I would like to ask moderators whether its possible to make this thread appear in forum of GWT also?
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8143
|
|
Vish Shukla wrote:
I would like to ask moderators whether its possible to make this thread appear in forum of GWT also?
We can move it there, but at this point i am not sure it's specific to GWT.
Caused by: java.security.AccessControlException: access denied ( java.net.SocketPermission localhost resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:76)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getByName(Unknown Source)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:81)
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:277)
Looking at the exception stacktrace, it appears that the environment doesn't allow a localhost resolution. Is this EJB hosted in some outside organization? Or is this on your local machine?
By the way, you have typo in your code:
Notice the "=" sign.
|
[My Blog] [JavaRanch Journal]
|
 |
Vish Shukla
Ranch Hand
Joined: Oct 12, 2008
Posts: 100
|
|
Thanks for pointing it out. I removed "=" sign but still there is same issue. I found one more isolation. When I create war of this GWT project and put it in the same EJB container in which EJB is deployed, it works perfectly fine. But if I run in separate instance, even in the same machine, it doesn't work.
Is this EJB hosted in some outside organization? Or is this on your local machine?
EJB container and Web container are in same machine.
|
 |
Vish Shukla
Ranch Hand
Joined: Oct 12, 2008
Posts: 100
|
|
Couple of more isolations to this.
When the issue produced, I was using Eclipse 3.4 with GWT plugin which has inbuilt tomcat in it. I created Gwt project in net beans, in which I used different tomcat instance in which everything worked fine, without exception. So I guess problem is in either inbuilt tomcat which is used or runtime configuration that eclipse does.
I also tried to solve it by putting java.security.AllPermission in java.policy file of JRE. But it doesn't solve the problem. Here is the reference for this AccessControlException: Changin Java Policy
Please help... need to solve it urgently.
|
 |
Vish Shukla
Ranch Hand
Joined: Oct 12, 2008
Posts: 100
|
|
I am not getting any clue for what to do next. I would like to narrow down the issue. Can someone tell that whether its server side issue of client side issue.
Observations:
Same EJB method can be called using stande alone application. There is exception only if application is run from eclipse, with gwt's built-in tomcat. This tends to think that there is client specific issue.Other argument is that looking at exception, its all about permission/access rights for particular port in EJB container. Which tends to think that some configuration need to be changed in the JBoss server/server machine configuration(By the way server and client machines are same).
I am new to EJB, JNDI. And don't have any knowledge of java security. So can someone please help on which end the problem exists?
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8143
|
|
The problem lies here:
Vish Shukla wrote:
Same EJB method can be called using stande alone application. There is exception only if application is run from eclipse, with gwt's built-in tomcat. This tends to think that there is client specific issue.
Is the GWT built-in tomcat a plugin Eclipse? The Java security permissions don't seem to allow that call. You will have to look at the documentation or the plugin to see what needs to be done. I am moving this to the IDE forum now, so that someone there might be of more help.
|
 |
Vish Shukla
Ranch Hand
Joined: Oct 12, 2008
Posts: 100
|
|
Jaikiran,
I think we can get it solved in GWT forum. Can you favour me by putting one link of the thread in GWT forum also?
|
 |
Anand Kumar Singh
Greenhorn
Joined: Oct 18, 2007
Posts: 22
|
|
May be you are using different version client.jar in the Client end. take the jboss-client jar from the JBOSS_HOME/client/ and put it in your client's class path.
Also Instead of localhost use IP address
|
SCJP 5, SCWCD 5, SCBCD 5,
SCEA 5,
OCUP Fundamental,
OCUP Intermediate,
OCUP Advanced,
IBM Certified Solution Designer - Object Oriented Analysis and Design, vUML 2
|
 |
Vish Shukla
Ranch Hand
Joined: Oct 12, 2008
Posts: 100
|
|
Hi Anand,
I tried using different ip addresses. I read in one of the forum that Google app engine doesn't allow socket communication, JNDI etc. I disabled using Google app engine for client gwt project and it works perfectly fine. I am searching out to know that what all are consequences of disabling app engine.
Thanks to Jaikiran, Anand for helping me in solving this issue.
|
 |
 |
|
|
subject: Failed to connect to server localhost:1099, RemoteAccessException, SocketException
|
|
|