1 Reply Latest reply on Dec 14, 2010 5:03 PM by Ron Sigal

    Jboss 4.2.3.GA Configuration for client to call ejb

    David Chokhonelidze Newbie

      Hello,


      I am using following environment in my project:

      • JBoss AS 4.2.3.GA
      • JBoss ejb 2.x (but on 3 is the same problem i have)
      • Swing for client


      Server and client are running on different machines in local network. The main problem is that server needs specific configuration to connect from client to that machine and call ejbs remotelly. I have some workarounds that works:

       

      1. In run.bat file i added following string:set JAVA_OPTS=%JAVA_OPTS% -Djava.rmi.server.hostname=IP Where jboss runs                                                                                                                                      -Djava.rmi.server.useLocalHostname=false
      2. In jboss-service.xml i configured this : <!––<attribute name="clientConnectAddress">IP Where jboss runs</attribute>––>


      After this configuration everything works. I also start jboss with parameter -b 0.0.0.0,but this does not help. From Swing client without configuration when i try to lookup ejb with this properties :
      InitialContext jndi=fina2.Main.getJndiContext();
      Object ref = jndi.lookup("fina2/i18n/LanguageSession");
                              Properties p=new Properties();

                              p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.NamingContextFactory");
      p.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      p.setProperty(Context.PROVIDER_URL, "jnp://IP Where jboss runs:1099");

                              InitialContext jndi=new InitialContext(props);

       

       

      Object ref = jndi.lookup("....");


      The following exception is thrown:
      javax.naming.CommunicationException: Could not obtain connection to any of these urls: IP Where jboss runs and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server IP Where jboss runs:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server IP Where jboss runs:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]]
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1562)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
      at javax.naming.InitialContext.lookup(Unknown Source)
      at fina2.login.LoginFrame.loadLanguageList(LoginFrame.java:127)
      at fina2.login.LoginFrame.languagesPopupMenuWillBecomeVisible(LoginFrame.java:426)
      at fina2.login.LoginFrame$5.popupMenuWillBecomeVisible(LoginFrame.java:233)
      at javax.swing.JComboBox.firePopupMenuWillBecomeVisible(Unknown Source)
      at javax.swing.plaf.basic.BasicComboPopup.firePopupMenuWillBecomeVisible(Unknown Source)
      at javax.swing.JPopupMenu.setVisible(Unknown Source)
      at javax.swing.JPopupMenu.show(Unknown Source)
      at javax.swing.plaf.basic.BasicComboPopup.show(Unknown Source)
      at javax.swing.plaf.basic.BasicComboPopup.togglePopup(Unknown Source)
      at javax.swing.plaf.basic.BasicComboPopup$Handler.mousePressed(Unknown Source)
      at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
      at java.awt.Component.processMouseEvent(Unknown Source)
      at javax.swing.JComponent.processMouseEvent(Unknown Source)
      at java.awt.Component.processEvent(Unknown Source)
      at java.awt.Container.processEvent(Unknown Source)
      at java.awt.Component.dispatchEventImpl(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Window.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.EventQueue.dispatchEvent(Unknown Source)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.run(Unknown Source)
      Caused by: javax.naming.CommunicationException: Failed to connect to server IP Where jboss runs:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server IP Where jboss runs:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:274)
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1533)
      ... 34 more
      Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server IP Where jboss runs:1099 [Root exception is java.net.ConnectException: Connection refused: connect]
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:248)
      ... 35 more
      Caused by: java.net.ConnectException: Connection refused: connect
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(Unknown Source)
      at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
      at java.net.PlainSocketImpl.connect(Unknown Source)
      at java.net.SocksSocketImpl.connect(Unknown Source)
      at java.net.Socket.connect(Unknown Source)
      at java.net.Socket.connect(Unknown Source)
      at java.net.Socket.<init>(Unknown Source)
      at java.net.Socket.<init>(Unknown Source)
      at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:84)
      at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:77)
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:244)
      ... 35 more

      It worked fine on Jboss 4.0.5 without configuration.

      Can anyone tell me  some kind of workaround so that to not to configure ip address ? ,because its not good that for every machine i manually change ips.