[jboss-user] [EJB3] - EJB3 over HTTP/HTTPS in AS6

Wen Cheng do-not-reply at jboss.com
Mon May 14 03:42:05 EDT 2012


Wen Cheng [https://community.jboss.org/people/chengwen] created the discussion

"EJB3 over HTTP/HTTPS in AS6"

To view the discussion, visit: https://community.jboss.org/message/735297#735297

--------------------------------------------------------------
Hello. 
These days I was trying to configure the ejb3 over http/https in AS 6.0.
I followed the artical:  https://community.jboss.org/docs/DOC-13276 https://community.jboss.org/wiki/EJB3OverHTTPHTTPSInJBossAS-5

The server and the client is not on the same machine.
My server IP is 10.26.13.206, and my client IP is 10.26.13.202.

the server code:

@Stateless
@Remote(UserManager.class)
@RemoteBindings({
      @RemoteBinding(clientBindUrl = "https://0.0.0.0:8443/servlet-invoker/SSLServerInvokerServlet",jndiBinding="EJBviahttps"),
      @RemoteBinding(clientBindUrl = "http://0.0.0.0:8080/servlet-invoker/ServerInvokerServlet",jndiBinding="EJBviahttp"),
      @RemoteBinding(clientBindUrl = "sslsocket://0.0.0.0:3843", jndiBinding="StatelessSSL"),
      @RemoteBinding(jndiBinding = "StatelessNormal")
     })
public class UserManagerBean implements UserManager{
         public void addUser(String user){
                   System.out.println("User name: " + user);                 
         }
}


the client code :


        System.setProperty("javax.net.ssl.trustStore", "D:/console.truststore");
        System.setProperty("javax.net.ssl.trustStorePassword", "mypassword");
        System.setProperty("org.jboss.security.ignoreHttpsHost", "true");
         
        Properties props = new Properties();
        props.put("java.naming.factory.initial", "org.jboss.naming.HttpNamingContextFactory");
        props.put("java.naming.provider.url", "http://10.26.13.206:8080/invoker/JNDIFactory");
        props.put("java.naming.factory.url.pkgs", "org.jboss.naming");
        
        Properties propsHttps = new Properties();
        propsHttps.put("java.naming.factory.initial", "org.jboss.naming.HttpNamingContextFactory");
        propsHttps.put("java.naming.provider.url", "https://10.26.13.206:8443/invoker/JNDIFactory");
        propsHttps.put("java.naming.factory.url.pkgs", "org.jboss.naming");
        
        try{
            InitialContext ctxhttp = new InitialContext(props);
            long t001=System.currentTimeMillis();
            UserManager umhttp = (UserManager)ctxhttp.lookup("EJBviahttp");
            umhttp.addUser("abc");
                 
            InitialContext ctxhttps = new InitialContext(propsHttps);
            UserManager umhttps = (UserManager)ctxhttps.lookup("EJBviahttps");
            umhttps.addUser("abc");
                       
        } catch (Exception e) {
            e.printStackTrace();
        }


When I run jboss with -b 10.26.13.206, the test code on the client works fine.
But if I run jboss with -b 0.0.0.0, I got the following exception:

javax.naming.CommunicationException: Operation failed [Root exception is java.rmi.ServerException: IOE; nested exception is: 
    java.net.ConnectException: Connection refused: connect]
    at org.jboss.naming.interceptors.ExceptionInterceptor.invoke(ExceptionInterceptor.java:65)
    at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:68)
    at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:74)
    at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:101)
    at $Proxy0.lookup(Unknown Source)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at com.pnft.test.UserManagerRemoteClient.main(UserManagerRemoteClient.java:37)
Caused by: java.rmi.ServerException: IOE; nested exception is: 
    java.net.ConnectException: Connection refused: connect
    at org.jboss.invocation.http.interfaces.HttpInvokerProxy.invoke(HttpInvokerProxy.java:133)
    at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:365)
    at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:197)
    at org.jboss.naming.interceptors.ExceptionInterceptor.invoke(ExceptionInterceptor.java:57)
    ... 8 more
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:193)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:529)
    at java.net.Socket.connect(Socket.java:478)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
    at sun.net.www.http.HttpClient.New(HttpClient.java:306)
    at sun.net.www.http.HttpClient.New(HttpClient.java:323)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:975)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:916)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:841)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1019)
    at org.jboss.invocation.http.interfaces.Util.invoke(Util.java:163)
    at org.jboss.invocation.http.interfaces.HttpInvokerProxy.invoke(HttpInvokerProxy.java:118)
    ... 11 more


I dont know why,  What happened? Is it means that "-b 0.0.0.0"  cannot be used here?
I really need to start jboss with "-b 0.0.0.0" because the real ip and "127.0.0.1" are both very useful in my project. 

Many thanks!
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/735297#735297]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120514/2cc924f7/attachment.html 


More information about the jboss-user mailing list