1 2 Previous Next 25 Replies Latest reply on May 22, 2006 4:47 AM by Sergio Figliolia

    JBOSS IDE tutorial

    Deon Horton Newbie

      I am having problems with the tutorial. I am getting exceptions when I click on the compute button in ComputeServlet page. I am getting:

      javax.servlet.ServletException: Lookup of java:/comp/env/ failed
      tutorial.web.ComputeServlet.init(ComputeServlet.java:64)
      org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      java.lang.Thread.run(Unknown Source)



      I have followed the tutorial very close and this is the only issue I am having. Even looking at the code and script it seems correct. Has anyone had this same problem? Are there any solution?

      Thanks

        • 1. Re: JBOSS IDE tutorial
          karthik karthik Newbie

          Same Dittoo with my Eclipse 3.02 + jdk1.4.2 + jboss4.2 + Eclipse plugin for
          Jboss


          Can some body help us out of this Problem

          • 2. Re: JBOSS IDE tutorial
            Darran Lofthouse Master

            Could you post your generated web.xml deployment descriptor and your ComputeServlet.java code.

            For both of these wrap them with [ code ] [ / code ] tags without the spaces and use the preview button to make sure that they display correctly.

            • 3. Re: JBOSS IDE tutorial
              karthik karthik Newbie

              Yes Shure

              Web.xml
              -----------------------------------------------------------------

              
              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
              <web-app >
              <distributable/>
              <servlet>
              <servlet-name>Compute</servlet-name>
              <display-name>Computation Servlet</display-name>
              <description>[CDATA[Servlet that compute Fibonacci suite]]</description>
              <servlet-class>tutorial.web.ComputeServlet</servlet-class>
              </servlet>
              <servlet-mapping>
              <servlet-name>Compute</servlet-name>
              <url-pattern>/Compute</url-pattern>
              </servlet-mapping>
              <ejb-ref >
              <description>[CDATA[Reference to the Fibo EJB]]</description>
              <ejb-ref-name>ejb/Fibo</ejb-ref-name>
              <ejb-ref-type>Session</ejb-ref-type>
              <home>tutorial.interfaces.FiboHome</home>
              <remote>tutorial.interfaces.Fibo</remote>
              </ejb-ref>
              </web-app>
              
              

              -----------------------------------------------------------------

              jboss-web.xml
              -----------------------------------------------------------------
              
              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">
              <jboss-web>
              <ejb-ref>
              <ejb-ref-name>ejb/Fibo</ejb-ref-name>
              <jndi-name>ejb/Fibo</jndi-name>
              </ejb-ref>
              </jboss-web>
              
              
              

              -----------------------------------------------------------------

              ComputeServlet.java
              -----------------------------------------------------------------
              
              package tutorial.web;
              
              import java.io.IOException;
              import java.io.PrintWriter;
              import javax.naming.Context;
              import javax.naming.InitialContext;
              import javax.rmi.PortableRemoteObject;
              import javax.servlet.ServletConfig;
              import javax.servlet.ServletException;
              import javax.servlet.http.HttpServlet;
              import javax.servlet.http.HttpServletRequest;
              import javax.servlet.http.HttpServletResponse;
              import tutorial.interfaces.Fibo;
              import tutorial.interfaces.FiboHome;
              
              public class ComputeServlet extends HttpServlet {
              private FiboHome home;
              public ComputeServlet() {
              super();
              }
              public void init(ServletConfig config) throws ServletException {
              try {
              Context context = new InitialContext();
              //Object ref = context.lookup("java:/comp/env/ejb/Fibo");
              Object ref = context.lookup("ejb/Fibo");
              
              home = (FiboHome) PortableRemoteObject.narrow(ref, FiboHome.class);
              } catch (Exception e) {
              throw new ServletException("Lookup of java:/comp/env/ failed");
              }
              }
              protected void doPost(HttpServletRequest request,
              HttpServletResponse response) throws ServletException, IOException {
              response.setContentType("text/html");
              PrintWriter out = response.getWriter();
              out.println("<html><head><title>");
              out.println("Fibonaci Computation");
              out.println("</title></head>");
              out.println("<body>");
              out.println("<h1>");
              out.println("Fibonaci Computation");
              out.println("</h1>");
              try {
              Fibo bean = home.create();
              int limit = 0;
              String value = request.getParameter("limit");
              if (value != null) {
              try {
              limit = Integer.parseInt(value);
              } catch (Exception e) {
              }
              }
              double[] result = bean.compute(limit);
              bean.remove();
              out.println("<p>");
              out.print("The ");
              out.print(limit);
              out.print(" first Fibonacci numbers ");
              for (int i = 0; i < result.length; i++) {
              out.println("<br>");
              out.println(i);
              out.println(" : ");
              out.println(result);
               }
               out.println("</p>");
               } catch (Exception e) {
               out.println(e.getMessage());
               e.printStackTrace(out);
               } finally {
               out.println("</body></html>");
               out.close();
               }
               }
               }
              
              

              -----------------------------------------------------------------

              I hope this is what ever u had asked for...


              thx in advance karthik

              • 4. Re: JBOSS IDE tutorial
                Darran Lofthouse Master

                Inside your servlet code you have commented out the lookup line and replaced it with one that just looks up "ejb/Fibo" - you should change that back to lookup "java:/comp/env/ejb/Fibo".

                Also where you catch the exception after the lookup you are hiding the cause of the error, you should add the caught exception as a second parameter to the new exception you are throwing: -

                throw new ServletException("A message",e);

                Can you try this out.

                I suspect that the exception that is being hidden may be a ClassCastException. A change has been made to JBoss 4.0.2 that means you should no longer package the -client.jar file in the war as you will get ClassCastExceptions.

                • 5. Re: JBOSS IDE tutorial
                  karthik karthik Newbie

                  Hi

                  I am a new Bee in this env....

                  >> I suspect that the exception that is being hidden may >> be a ClassCastException. A change has been made >> JBoss 4.0.2 that means you should no longer
                  >> package the -client.jar file in the war as you will get >> ClassCastExceptions.


                  What exactly do u mean by this and What steps of Tutorial should I skipp to achieve the Desired Results for sucessfull deployment.

                  Thx in advance

                  • 6. Re: JBOSS IDE tutorial
                    Darran Lofthouse Master

                    Replace the line: -

                    throw new ServletException("Lookup of java:/comp/env/ failed");


                    with: -

                    throw new ServletException("Lookup of java:/comp/env/ failed",e);


                    Skip the FiboEJB-client.jar creation, and when creating the war skip the steps where the -client.jar is added to the war.

                    • 7. Re: JBOSS IDE tutorial
                      J.W. Peng Newbie

                      I followed closely to the tutorial and had similar problem. Only the error message is different.

                      javax.servlet.ServletException: Lookup of java:/comp/env/ failed javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: ejb not bound]

                      It seems the either ejb not started or jndi did not pickup the ejb. What can go wrong?

                      Thanks.

                      • 8. Re: JBOSS IDE tutorial
                        karthik karthik Newbie

                        Hi

                        The Form started with the same Error u mentioned ,Me tried some hacking around...

                        I think Follow the steps said by darrnl....



                        Happy JBossing around......;)

                        • 9. Re: JBOSS IDE tutorial
                          Barry Williams Newbie

                          To fix the tutorial just skip pg 36 which adds the FiboEJB-client.jar to FiboWeb.war. After that it works fine in Jboss AS 4.0.2 .

                          • 10. Re: JBOSS IDE tutorial
                            jim stone Newbie

                            The url is really java:comp/env/ejb/ Notice that the slash is missing prior to comp.

                            • 11. Re: JBOSS IDE tutorial
                              steve reinders Newbie

                              I was having similar problems. I went over the tutorial in detail and found out the jboss-web.xml wasn't being "packaged" in the war.
                              The tutorial runs fine, as is. I haven't removed the -client.jar file from packaging as suggested.

                              • 12. Re: JBOSS IDE tutorial
                                Darran Lofthouse Master

                                Steve, which JBoss version are you currently using the tutorial against?

                                • 13. Re: JBOSS IDE tutorial
                                  Luciano Borges Newbie

                                  I try skip to add the client, and i got this error:

                                  type Exception report

                                  message

                                  description The server encountered an internal error () that prevented it from fulfilling this request.

                                  exception

                                  javax.servlet.ServletException: Lookup of java:/comp/env/ failed
                                  tutorial.web.ComputeServlet.init(ComputeServlet.java:46)
                                  org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
                                  org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
                                  org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
                                  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                                  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                                  org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
                                  org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
                                  org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                                  org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                                  java.lang.Thread.run(Thread.java:534)

                                  root cause

                                  javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: ejb not bound]
                                  org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1052)
                                  org.jnp.interfaces.NamingContext.lookup(NamingContext.java:685)
                                  org.jnp.interfaces.NamingContext.lookup(NamingContext.java:701)
                                  org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
                                  javax.naming.InitialContext.lookup(InitialContext.java:347)
                                  tutorial.web.ComputeServlet.init(ComputeServlet.java:43)
                                  org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
                                  org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
                                  org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
                                  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                                  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                                  org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
                                  org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
                                  org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                                  org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                                  java.lang.Thread.run(Thread.java:534)

                                  root cause

                                  javax.naming.NameNotFoundException: ejb not bound
                                  org.jnp.server.NamingServer.getBinding(NamingServer.java:491)
                                  org.jnp.server.NamingServer.getBinding(NamingServer.java:499)
                                  org.jnp.server.NamingServer.getObject(NamingServer.java:505)
                                  org.jnp.server.NamingServer.lookup(NamingServer.java:249)
                                  org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
                                  org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
                                  javax.naming.InitialContext.lookup(InitialContext.java:347)
                                  org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1046)
                                  org.jnp.interfaces.NamingContext.lookup(NamingContext.java:685)
                                  org.jnp.interfaces.NamingContext.lookup(NamingContext.java:701)
                                  org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
                                  javax.naming.InitialContext.lookup(InitialContext.java:347)
                                  tutorial.web.ComputeServlet.init(ComputeServlet.java:43)
                                  org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
                                  org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
                                  org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
                                  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                                  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                                  org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
                                  org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
                                  org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                                  org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                                  java.lang.Thread.run(Thread.java:534)

                                  • 14. Re: JBOSS IDE tutorial
                                    Manfred Allers Newbie

                                    reply-to-steverar

                                    I was having similar problems. I went over the tutorial in detail and found out the jboss-web.xml wasn't being "packaged" in the war.
                                    The tutorial runs fine, as is. I haven't removed the -client.jar file from packaging as suggested.

                                    The tutorial is ok - i suppose you just missed the jboss-web.xml during 'Packaging Configuration'.

                                    Removing the -client.jar helped for me too !

                                    Using : JBoss IDE Bundle 1.5 M3


                                    1 2 Previous Next