1 2 Previous Next 22 Replies Latest reply on Nov 27, 2003 5:10 AM by Ajay Amrite

    JBoss with Existing tomcat

    sys user Master

      Hello Everyone,
      This is my first post here and hopefully fruitfull one.I have installed JBoss without Tomcat version on my machine.I have already installed Tomcat few months back.Now I want to integrate JBoss with my existing Tomcat.Can some one please guide me in acheiving the same.I apprecaite your response.

        • 1. Re: JBoss with Existing tomcat
          mathewj Newbie

          I am in the same situation as you. I have Tomcat4.1 adn jBoss321. I want to keep my tomcat the way it is and move jBoss into Tomcat. Did a lot of research. Read many articles. What I find is that the though I am passing the correct parameter for the tomcat startup (set JAVA_OPTS=-Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory -Djava.naming.provider.url=localhost:1099 -Djava.naming.factory.url.pkgs=org.jnp.interfaces:org.jboss.naming)
          it still uses org.apache.naming*!

          So I am still stuck at the jndi. If you get it right, please let me know. I will do the same.

          thanks
          jm

          • 2. Re: JBoss with Existing tomcat
            sys user Master

            Sorry Buddy,
            I thought it is waste of time trying to figure it out what to do and just installed jboss/tomcat combination again.I have kept my old installation of tomcat as is and installed jboss/tomcat in a seperate directory.So far so good.
            If I get any ans I will post in this forum.
            All the best

            • 3. Re: JBoss with Existing tomcat
              Jon Barnett Master

              You also need to include the jboss-client classes in the directory. I'm looking at a very old archived copy of Tomcat 4.1.2 from our JBoss 2.4.6 days. The client jars would be installed in the shared lib of Tomcat 4.1.x. jbossall-client.jar would be a good start. Depending on what you are using from the JBoss infrastructure, you may need other JARs (from the client directory of the JBoss distribution).

              I would probably use explicit configuration of the Context when you do a JBoss JNDI search.

              e.g.

              String NCFACTORY = "org.jnp.interfaces.NamingContextFactory";
              String NPURL = "jnp://localhost:1099";
              String NPKGS = "org.jboss.naming:org.jnp.interfaces";
              String JNDIFACTORY = "java.naming.factory.initial";
              String JNDIURL = "java.naming.provider.url";
              String JNDIPKGS = "java.naming.factory.url.pkgs";
              Properties jndiProps = new Properties();
              jndiProps.setProperty(JNDIPKGS, NPKGS);
              jndiProps.setProperty(JNDIFACTORY, NCFACTORY);
              jndiProps.setProperty(JNDIURL, NPURL);
              Context jndiContext = new InitialContext(jndiProps);
              Objecxt reference = jndiContext.lookup("MyEJB");

              That should give you a general feel for what is required. I've hacked it out of our ReferenceFactory code, which does some other things like detect whether we are in a JBoss environment so we don't set the java.naming.provider.url property.

              You are much better of using the embedded Tomcat as the access is much faster. You also have better resource use in a shered VM.

              The only other thing is that your webapps will need are copies of classes that the EJBs manufacturer to transport to the clients, as well as the interface classes (home and remote).

              • 4. Re: JBoss with Existing tomcat
                Sophie Wilson Newbie

                Thanks for the help with this. I've spent the past couple of days trying to get an existing version of Tomcat talking to JBoss and have finally got it to work now.

                But could you please explain one thing to me? I'd already done everything you recommended but had the various JBoss client jars in my webapp /WEB-INF/lib directory instead of the Tomcat shared lib directory. When I moved them it suddenly started to work - why is that? These aren't necessarily common to all webapps I might deploy under this tomcat.

                • 5. Re: JBoss with Existing tomcat
                  Jon Barnett Master

                  A great question to which I have no real answer. I don't remember having any particular issues. I think we just chose the shared/lib because we didn't want to replicate across multiple WARs as this meant replication of code in memory - which seemed rather wasteful.

                  However, Tomcat's classloaders are pretty particular about the location of libraries. For example, to install Axis, you need to explicitly place saaj.jar and jaxrpc.jar in common/lib. It may be that the Java classes that the JBoss clients require cannot be 'seen' from the webapp classloader. I've seen this behaviour in other app servers such as Haht.

                  • 6. Re: JBoss with Existing tomcat
                    Le Van Huyen Newbie

                    I have do as jonlee said. But I still can't lookup my bean (I have copied all jar file in the jboss\client directory to tomcat's shared\lib dierectory).

                    My code as follow:

                    Properties p = new Properties();
                    p.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
                    p.setProperty("java.naming.provider.url", "jnp://localhost:1099");
                    p.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");

                    Context ctx = new InitialContext(p);
                    Object objref = ctx.lookup("myBean");
                    home = (myBeanHome)PortableRemoteObject.narrow(objref, myBeanHome.class);


                    But my program throw a remote exception at line: Object objref = ctx.lookup("myBean");.

                    Please help me

                    • 7. Re: JBoss with Existing tomcat
                      Jon Barnett Master

                      This is a different type of error. It means the remote system rejected the connection or request for some reason. You need to show the stacktrace if anyone is to figure out the problem.

                      • 8. Re: JBoss with Existing tomcat
                        Le Van Huyen Newbie

                        sorry jonlee, I don't understand the words "stacktrace".
                        Could you please continue help me?
                        Thanks a lot!

                        • 9. Re: JBoss with Existing tomcat
                          Jon Barnett Master

                          Java dumps a whole lot of information to output when an unhandled exception is thrown. Most of these are about where in the program the exception occurred, and ultimately the type of exception. This is the stacktrace. As there are a whole bunch of reasons a remote exception occurred, it is necessary for anyone diagnosing the problem to see this information. So you need to capture this information from screen and paste it here. If you are catching the exception, you can forcibly create a stacktrace with the following:
                          catch(Exception e)
                          {e.printStacktrace();}

                          • 10. Re: JBoss with Existing tomcat
                            Le Van Huyen Newbie

                            This is my information I have gotten from the tomcat screen when I catch the exception and printStacktrace as you had said:

                            javax.naming.CommunicationException [Root exception is java.rmi.ServerException:
                            RemoteException occurred in server thread; nested exception is:
                            java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
                            tion is:
                            java.net.MalformedURLException: no protocol: 4.1/shared/classes/]
                            javax.naming.CommunicationException. Root exception is java.rmi.ServerException
                            : RemoteException occurred in server thread; nested exception is:
                            java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
                            tion is:
                            java.net.MalformedURLException: no protocol: 4.1/shared/classes/
                            at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
                            at sun.rmi.transport.Transport$1.run(Transport.java:148)
                            at java.security.AccessController.doPrivileged(Native Method)
                            at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
                            at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
                            60)
                            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
                            .java:701)
                            at java.lang.Thread.run(Thread.java:536)
                            at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
                            RemoteCall.java:247)
                            at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
                            223)
                            at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
                            at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
                            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:484)
                            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:463)
                            at javax.naming.InitialContext.lookup(InitialContext.java:347)
                            at cdit.mtt.admin.bean.TransactionBean.(TransactionBean.java:32)
                            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

                            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
                            orAccessorImpl.java:39)
                            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
                            onstructorAccessorImpl.java:27)
                            at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
                            at java.lang.Class.newInstance0(Class.java:306)
                            at java.lang.Class.newInstance(Class.java:259)
                            at java.beans.Beans.instantiate(Beans.java:204)
                            at java.beans.Beans.instantiate(Beans.java:48)
                            at org.apache.jsp.Giaodich_jsp._jspService(Giaodich_jsp.java:50)
                            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
                            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
                            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
                            .java:210)
                            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
                            95)
                            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
                            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
                            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
                            icationFilterChain.java:247)
                            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
                            ilterChain.java:193)
                            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
                            alve.java:256)
                            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
                            t.invokeNext(StandardPipeline.java:643)
                            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
                            a:480)
                            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

                            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
                            alve.java:191)
                            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
                            t.invokeNext(StandardPipeline.java:643)
                            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
                            a:480)
                            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

                            at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
                            2415)
                            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
                            ava:180)
                            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
                            t.invokeNext(StandardPipeline.java:643)
                            at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
                            rValve.java:171)
                            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
                            t.invokeNext(StandardPipeline.java:641)
                            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
                            ava:172)
                            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
                            t.invokeNext(StandardPipeline.java:641)
                            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
                            a:480)
                            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

                            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
                            ve.java:174)
                            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
                            t.invokeNext(StandardPipeline.java:643)
                            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
                            a:480)
                            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

                            at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:22
                            3)
                            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
                            :594)
                            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
                            ssConnection(Http11Protocol.java:392)
                            at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
                            :565)
                            at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
                            ool.java:619)
                            at java.lang.Thread.run(Thread.java:536)
                            Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested ex
                            ception is:
                            java.net.MalformedURLException: no protocol: 4.1/shared/classes/
                            at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:249)
                            at sun.rmi.transport.Transport$1.run(Transport.java:148)
                            at java.security.AccessController.doPrivileged(Native Method)
                            at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
                            at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
                            60)
                            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
                            .java:701)
                            ... 1 more
                            Caused by: java.net.MalformedURLException: no protocol: 4.1/shared/classes/
                            at java.net.URL.(URL.java:579)
                            at java.net.URL.(URL.java:476)
                            at java.net.URL.(URL.java:425)
                            at sun.rmi.server.LoaderHandler.pathToURLs(LoaderHandler.java:743)
                            at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:159)
                            at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:631)
                            at org.jboss.system.JBossRMIClassLoader.loadClass(JBossRMIClassLoader.ja
                            va:74)
                            at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:257)
                            at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.jav
                            a:200)
                            at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:151
                            3)
                            at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
                            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
                            626)
                            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
                            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
                            at javax.naming.CompoundName.readObject(CompoundName.java:554)
                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
                            java:39)
                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
                            sorImpl.java:25)
                            at java.lang.reflect.Method.invoke(Method.java:324)
                            at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:824
                            )
                            at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1746)

                            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
                            646)
                            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
                            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
                            at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:297)
                            at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:246)
                            ... 6 more


                            please help me!

                            • 11. Re: JBoss with Existing tomcat
                              Jon Barnett Master

                              It looks like the remote server does not understand your client.

                              There are one of two problems.

                              1) Most likely you are using a different client library or libraries to those shipped with the JBoss version you are using. Use the client libraries that are supplied with your JBoss installation - these can occasionally change between releases.
                              2) If you are running in Windows, make sure that JBoss, Tomcat and your JDK are installed in directory paths that do not contain spaces. These directory paths break various things like RMI and JNDI.

                              Try those and see how you go.

                              • 12. Re: JBoss with Existing tomcat
                                Le Van Huyen Newbie

                                Thanks a lot! My program has runned properly.

                                • 13. Re: JBoss with Existing tomcat
                                  Le Van Huyen Newbie

                                  dear,
                                  I have another problem.

                                  My code is:
                                  Properties p = new Properties();
                                  p.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
                                  p.setProperty("java.naming.provider.url", "jnp://10.206.16.123:1099");
                                  p.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");

                                  Context ctx = new InitialContext(p);
                                  Object objref = ctx.lookup("TransactionSBean");
                                  home = (TransactionSHome)PortableRemoteObject.narrow(objref, TransactionSHome.class);


                                  I got an ClassCastException when execute the line:
                                  home = (TransactionSHome)PortableRemoteObject.narrow(objref, TransactionSHome.class);
                                  I had rechecked all my code, but I found no classcast problem. Then, I used the jboss3.0.6_tomcat4.1.18 to deploy with the same jar file, my program run properly.
                                  My tomcat's stacktrace shown:
                                  java.lang.ClassCastException
                                  at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Porta
                                  bleRemoteObject.java:293)
                                  at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
                                  at cdit.mtt.admin.bean.TransactionBean.(TransactionBean.java:34)
                                  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

                                  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
                                  orAccessorImpl.java:39)
                                  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
                                  onstructorAccessorImpl.java:27)
                                  at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
                                  at java.lang.Class.newInstance0(Class.java:306)
                                  at java.lang.Class.newInstance(Class.java:259)
                                  at java.beans.Beans.instantiate(Beans.java:204)
                                  at java.beans.Beans.instantiate(Beans.java:48)
                                  at org.apache.jsp.Giaodich_jsp._jspService(Giaodich_jsp.java:50)
                                  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
                                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
                                  at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
                                  .java:210)
                                  at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
                                  95)
                                  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
                                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
                                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
                                  icationFilterChain.java:247)
                                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
                                  ilterChain.java:193)
                                  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
                                  alve.java:256)
                                  at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
                                  t.invokeNext(StandardPipeline.java:643)
                                  at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
                                  a:480)
                                  at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

                                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
                                  alve.java:191)
                                  at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
                                  t.invokeNext(StandardPipeline.java:643)
                                  at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
                                  a:480)
                                  at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

                                  at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
                                  2415)
                                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
                                  ava:180)
                                  at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
                                  t.invokeNext(StandardPipeline.java:643)
                                  at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
                                  rValve.java:171)
                                  at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
                                  t.invokeNext(StandardPipeline.java:641)
                                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
                                  ava:172)
                                  at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
                                  t.invokeNext(StandardPipeline.java:641)
                                  at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
                                  a:480)
                                  at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

                                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
                                  ve.java:174)
                                  at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
                                  t.invokeNext(StandardPipeline.java:643)
                                  at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
                                  a:480)
                                  at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

                                  at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:22
                                  3)
                                  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
                                  :594)
                                  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
                                  ssConnection(Http11Protocol.java:392)
                                  at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
                                  :565)
                                  at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
                                  ool.java:619)
                                  at java.lang.Thread.run(Thread.java:536)


                                  could you please tell me why.

                                  • 14. Re: JBoss with Existing tomcat
                                    Jon Barnett Master

                                    The object reference you received from the JBoss JNDI could not be cast into the class you have on Tomcat. Check and make sure that the class in the JBoss environment (TransactionSHome.class) has the same UID as the class you use in the Tomcat environment. Ensure that you use the same compiler to build both the client and server versions of this class.

                                    1 2 Previous Next