8 Replies Latest reply on Jul 27, 2002 7:25 PM by Ilya S

    Help with separated Tomcat - JBoss

    Tim Taler Newbie

      Hi there,
      I'm searching for hours the archives but it can't find a solution for the JNDI-Problem with running Tomcat and JBoss on two separated machines.

      I placed the file "jndi.properties" in almost every directory but everytime I try to lookup my ejb there is a Naming Exception:
      javax.naming.NameNotFoundException: Name Message is not bound in this Context

      Can anybody help me, because we couldn't use the bundle of both

        • 2. Re: Help with separated Tomcat - JBoss
          Tim Taler Newbie

          Hi,
          I copied the *.jar in tomcat/common/lib and
          the jndi.properties in tomcat/common/classes

          I also tried to set the properties hardcoded:
          Properties prop = new Properties();
          prop.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
          prop.setProperty("java.naming.provider.url","localhost:1099");
          prop.setProperty("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
          InitialContext initial = new InitialContext(prop);

          But I still have the problem that I receive a NamingException. It seems to me, that tomcat uses his own JNDI-Context and doesn't delegate it to JBoss

          What can I try next?

          • 3. Re: Help with separated Tomcat - JBoss
            Adrian Brock Master

            Did you read the above link about starting Tomcat
            with the -nonaming option?

            Regards,
            Adrian

            • 4. Re: Help with separated Tomcat - JBoss
              Tim Taler Newbie

              Ok, I tried the "-naming" option, but then Tomcat doesn't find any environment-ressource I had specified.
              I only want to add the JBoss jndi in Tomcat.

              • 5. Re: Help with separated Tomcat - JBoss
                Ron Jawanda Novice

                You have your URL wrong I think
                Shouldn't be localhost but the other machine name.
                ??
                Make sure 1099 is actually working when your bjoss starts.

                You don't need the jndi.properties there if you hard code it.
                I don't know about the "hard coded properties"
                but if they are replaced with Context.PROVIDER_URL and so on then this should work.
                Ping your other machine. nslookup from your other machine also telnet to port 1099 to see if there is any response. It that is all ok then I have no clue.
                Sorry

                • 6. Re: Help with separated Tomcat - JBoss
                  Rico Kahnert Newbie

                  Well,

                  I do have the same problem with the error message:
                  javax.naming.NameNotFoundException: Name Message is not bound in this Context
                  the problem is not that it cannot find the JNDI service.
                  The problem is that it ignores the values in jndi.properties.
                  So the client connects to the Tomcat JNDI service and that's what I do not want to happen. The parameters in the jndi.properties are correct and it's working fine if I run a test client doing exactly what the servlet in Tomcat is supposed to do.

                  At the moment I think it's a Tomcat problem.
                  Any ideas how to solve the problem without hardcoding the properties in the servlet?

                  Thanks

                  Rico

                  • 7. Re: Help with separated Tomcat - JBoss
                    eric eneroth Newbie

                    FINALLY!!!
                    I've been looking for the solution for two(!) days now. I didn't have the exact same setup I was using a orion and tomcat4.0.3. But as stated above the problem was in the tomcat, so it should work for J-Boss as well.
                    This is what I have done:
                    1) Put the jndi.properties in %tomcat_home%\common\classes
                    2) Put client-application.xml in %my_app%\classes\META-INF
                    3) Put all of MyEJB.class and MyEJBHome.class in %my_app%\classes
                    4) Put ejb.jar in %tomcat_home%\common\bin
                    5) Put the jar-file containing the ContextFactory class in %tomcat_home%\common\bin (for orion the jar file is jaas.jar)
                    6) startup.bat -noname

                    It worked for me anyway!

                    /Jerka

                    • 8. Re: Help with separated Tomcat - JBoss
                      Ilya S Newbie

                      I've tried the above. However, I keep getting a NullPointerException from the tomcat logger:

                      java.lang.NullPointerException
                      at java.io.Writer.write(Writer.java:126)
                      at java.io.PrintWriter.newLine(PrintWriter.java:254)
                      at java.io.PrintWriter.println(PrintWriter.java:405)
                      at java.io.PrintWriter.println(PrintWriter.java:516)
                      at org.apache.catalina.logger.LoggerBase.log(LoggerBase.java:262)
                      at org.apache.catalina.connector.http.HttpProcessor.log(HttpProcessor.ja
                      va:421)
                      at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.ja
                      va:1127)
                      at java.lang.Thread.run(Thread.java:536)

                      Code in the jsp:
                      Properties pts = new Properties();
                      pts.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
                      pts.setProperty("java.naming.provider.url", "localhost");
                      pts.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
                      System.setProperties(pts);
                      try{
                      InitialContext namingContext = new InitialContext();
                      Object ref = namingContext.lookup("java:comp/env/ejb/Project");
                      ProjectLocalHome home = (ProjectLocalHome)PortableRemoteObject.narrow(ref, ProjectLocalHome.class);
                      }catch(Exception e ){
                      e.printStackTrace();
                      }