6 Replies Latest reply on Dec 12, 2013 4:04 AM by Juergen Weber

    Can't connect to Sun Naming Server from JBoss 7.2 webapp

    Jeff Chase Newbie

      Hi all,

       

      I'm on CentOS 6.4 and I'm running /usr/java/jdk1.7.0_25/bin/orbd -ORBInitialPort 4244 to connect to a back end application server via CORBA from a webapp on the same machine. This setup worked fine in JBoss AS 6.1.0 and on Tomcat, but I'm having issues in JBoss EAP 6.1.0 and JBoss AS 7.2.0.Final.

       

      When I execute this StartContext.java file from the command line, it works fine and echoes "Context created". I can then lookup my objects from the naming service as expected.

      package mypkg;

      import javax.naming.InitialContext;
      import javax.naming.Context;
      import java.util.Hashtable;

      public class StartContext
      {
        
      public static void main(String args[]){
            start
      ();
        
      };

        
      public static void start(){
           
      try{
              
      Hashtable htEnv = new Hashtable();
               htEnv
      .put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
               htEnv
      .put(Context.PROVIDER_URL, "iiop://localhost:4244");
              
      Context context = new InitialContext(htEnv);
              
      System.out.println("Context created");
           
      } catch(Exception e) {
               e
      .printStackTrace();
           
      }
        
      }
      }

       

      However, when I execute it using the following jsp then I can't connect to my name server.

      <!doctype html>
      <html>
        
      <head>
        
      <title>JSP Test</title>
        
      </head>
        
      <body>
        
      <%@ page import="mypkg.StartContext" %>
        
      <%
           
      StartContext.start();
        
      %>
        
      </body>
      </html>

       

       

      When I packaged it into a helloworld.war file deployed in JBoss with standalone.sh, I got the following exception:

       

      javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory com.sun.jndi.cosnaming.CNCtxFactory from classloader ModuleClassLoader for Module "deployment.helloworld.war:main" from Service Module Loader

       

       

       

      To fix that, I had to package java's rt.jar and resource.jar in my WEB-INF/lib (which I thought was overkill, but that's another question...). Then I'd get:

       

      java.lang.ClassNotFoundException: org.jacorb.orb.ORB from [Module "deployment.helloworld.war:main" from Service Module Loader]

       

       

      To fix that, I had to add these to standalone.sh (it wasn't sufficient to use System.setProperty from within the java class):

       

      -Dorg.omg.CORBA.ORBClass=com.sun.corba.se.internal.iiop.ORB
      -Dorg.omg.CORBA.ORBSingletonClass=com.sun.corba.se.internal.corba.ORBSingleton

       

       

      And now finally I'm stuck at this error which I can't seem to get past. I've tried using every combination of settings I can think of. Including a jndi.properties with my context factory and url seems to make things worse. Please help! What am I overlooking?

        • 1. Re: Can't connect to Sun Naming Server from JBoss 7.2 webapp
          Tomaz Cerar Master

          Hi,

           

          lets start from beginning

           

          When I packaged it into a helloworld.war file deployed in JBoss with standalone.sh, I got the following exception:

           

          javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory com.sun.jndi.cosnaming.CNCtxFactory from classloader ModuleClassLoader for Module "deployment.helloworld.war:main" from Service Module Loader

           

            To fix that, I had to package java's rt.jar and resource.jar in my WEB-INF/lib (which I thought was overkill, but that's another question...).

          Never ever bundle JDK's jars in your application that is beyond wrong.

           

          to fix your original problem open EAP_HOME/modules/system/layers/base/sun/jdk/main/module.xml

          and add

          <path name="com/sun/jndi/cosnaming"/>

           

          After you done that (without any jdk jars in your deployment)

          try again and post how it goes.

           

          also what configuration are you running? standalone.xml or standalone-full.xml?

           

           

          --

          tomaz

          1 of 1 people found this helpful
          • 2. Re: Can't connect to Sun Naming Server from JBoss 7.2 webapp
            Jeff Chase Newbie

            Thanks for your help Tomaz!

             

            I assume I'm using standalone.xml, but I didn't explicitly set it anywhere.

             

            I should note that I originally went down this road using a WEB-INF/jboss-deployment-structure.xml file - is that essentially the same approach?

             

            After removing the jars and adding that dependency, I ran into two more errors Caused by:

                 java.lang.ClassNotFoundException: com.sun.corba.se.impl.orb.ORBImpl from [Module "deployment.helloworld.war:main" from Service Module Loader]

             

            which I addressed by adding:

                <path name="com/sun/corba/se/impl/orb"/>

             

            and then:

                 java.util.MissingResourceException: Can't find com.sun.corba.se.impl.logging.LogStrings bundle

             

            which I addressed by adding:

                 <path name="com/sun/corba/se/impl/logging"/>

             

             

            So now I have the error:

             

            08:16:21,995 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/helloworld]] (MSC service thread 1-1) Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener: java.lang.NoClassDefFoundError: Could not initialize class javax.rmi.CORBA.Util

                at com.sun.corba.se.impl.orbutil.ORBUtility.getMaxStreamFormatVersion(ORBUtility.java:667) [rt.jar:1.7.0_25]

                at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.getStreamFormatVersionForThisRequest(CorbaMessageMediatorImpl.java:670) [rt.jar:1.7.0_25]

                at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.<init>(CorbaMessageMediatorImpl.java:186) [rt.jar:1.7.0_25]

                at com.sun.corba.se.impl.transport.CorbaContactInfoBase.createMessageMediator(CorbaContactInfoBase.java:130) [rt.jar:1.7.0_25]

                at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:236) [rt.jar:1.7.0_25]

                at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:136) [rt.jar:1.7.0_25]

                at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaClientDelegateImpl.java:229) [rt.jar:1.7.0_25]

                at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:130) [jacorb-2.3.1.jbossorg-1.jar:]

                at org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.java:69) [jacorb-2.3.1.jbossorg-1.jar:]

                at com.sun.jndi.cosnaming.CNCtx.setOrbAndRootContext(CNCtx.java:421) [rt.jar:1.7.0_25]

                at com.sun.jndi.cosnaming.CNCtx.initUsingIiopUrl(CNCtx.java:316) [rt.jar:1.7.0_25]

                at com.sun.jndi.cosnaming.CNCtx.initUsingUrl(CNCtx.java:282) [rt.jar:1.7.0_25]

                at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContext(CNCtx.java:250) [rt.jar:1.7.0_25]

                at com.sun.jndi.cosnaming.CNCtx.<init>(CNCtx.java:105) [rt.jar:1.7.0_25]

                at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContext(CNCtxFactory.java:49) [rt.jar:1.7.0_25]

                at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684) [rt.jar:1.7.0_25]

                at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307) [rt.jar:1.7.0_25]

                at javax.naming.InitialContext.init(InitialContext.java:242) [rt.jar:1.7.0_25]

                at javax.naming.InitialContext.<init>(InitialContext.java:192) [rt.jar:1.7.0_25]

                at com.sun.faces.config.WebConfiguration.processJndiEntries(WebConfiguration.java:687) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at com.sun.faces.config.WebConfiguration.<init>(WebConfiguration.java:134) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at com.sun.faces.config.WebConfiguration.getInstance(WebConfiguration.java:194) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:163) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]

                at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_25]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]

                at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]

             

             

            However, when I add:

                 <path name="javax/rmi/CORBA"/>

             

            It makes no difference (which is the point at which I gave up before and added rt.jar to my war ... )

             

            I also tried adding this to my MANIFEST.MF:

                 Dependencies: javax.rmi.CORBA

             

            But that also made no difference.

             

            Any suggestions on what to try next?

             

            Thanks!!

            -Jeff

            • 3. Re: Can't connect to Sun Naming Server from JBoss 7.2 webapp
              Jeff Chase Newbie

              Also I noticed that javax.rmi.CORBA is in jboss-rmi-api_1.0_spec-1.0.4.Final.jar, but I'm not sure if I should be trying to use that.

              I added Dependencies: javax.rmi.api to my MANIFEST.MF but that didn't change anything.

              -Jeff

              • 4. Re: Can't connect to Sun Naming Server from JBoss 7.2 webapp
                Jeff Chase Newbie

                I was able to connect by using this WEB-INF/jboss-deployment-structure.xml file:

                 

                <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">

                    <deployment>

                        <dependencies>

                            <system export="true">

                                <paths>

                                    <path name="com/sun/jndi/cosnaming"/>

                                    <path name="com/sun/corba/se/impl/orb"/>

                                    <path name="com/sun/corba/se/impl/logging"/>

                                    <path name="com/sun/corba/se/impl/javax/rmi/CORBA"/>

                                </paths>

                            </system>

                        </dependencies>

                    </deployment>

                </jboss-deployment-structure>

                 

                 

                Thanks for your help!

                -Jeff

                • 5. Re: Can't connect to Sun Naming Server from JBoss 7.2 webapp
                  Juergen Weber Newbie

                  This did not work for me with 7.2.1.

                  I added *every* package below com.sun.corba and org.omg

                  then it worked.

                   

                  Juergen

                  • 6. Re: Can't connect to Sun Naming Server from JBoss 7.2 webapp
                    Juergen Weber Newbie

                    And even with *every* package below com.sun.corba and org.omg
                    the sun orb is only accessible from a war or a standalone ejb, I could *not* make this work from within an *ear*

                     

                    Juergen