5 Replies Latest reply on Jan 12, 2010 11:16 AM by sarko86

    [beginner] Deploying a ear file under JBoss AS 5


      Hi everybody, I hope I'm in the right section!

       

      I developed a very basic "web service" (Hello world) following this tutorial. With Ant I generate the jar, war and ear files. Then I try to upload the ear using the Jboss Administration section but it gives error:

       

      Failed to create Resource example2.ear - cause: java.lang.Exception:Failed to remove deployment [vfszip:/C:/Programmi/jBoss/server/default/deploy/example2.ear/] after start failure. -> java.lang.RuntimeException:java.io.IOException: Failed to delete: DelegatingHandler@9044862[path=example2.ear context=file:/C:/Programmi/jBoss/server/default/deploy/ real=file:/C:/Programmi/jBoss/server/default/deploy/example2.ear] -> java.io.IOException:Failed to delete: DelegatingHandler@9044862[path=example2.ear context=file:/C:/Programmi/jBoss/server/default/deploy/ real=file:/C:/Programmi/jBoss/server/default/deploy/example2.ear]

       

      I tried with the war file only and I had the same issue. I also tried to copy the war/ear file into the deploy/ default's subfolder and this still throws exception in the console. I then checked whether the file is correct and it should be, for I managed to run it properly under tomcat (the war file, I mean).

       

      Can someone help me understading this issue? In attachment you find the ear file.

      Thank you so much!

        • 1. Re: [beginner] Deploying a ear file under JBoss AS 5
          peterj

          You are using the root package which is not a good idea. Try assigning a package name to your class. Also, it might help to post the source for the class.

           

          You should be able to deploy the WAR file by iteslf; you do not have to put it into an EAR.

           

          Try deploying the WAR after JBoss AS is started. What deployment information is display?

           

          You are not, by any chance, doing this within Eclipse (or NetBeans) are you? Wait, I see you are using the Admin Console. Instead, try copying the WAR to server/xxx/deploy manually and see what happens.

          • 2. Re: [beginner] Deploying a ear file under JBoss AS 5

            Hi and thank you for your kind reply!

             

            So, in the console the following error is displayed:


            *** DEPLOYMENTS IN ERROR: Name -> Error

            vfszip:/C:/Programmi/jBoss/server/default/deploy/example2.ear/ -> org.jboss.depl
            oyers.spi.DeploymentException: Error creating managed object for vfszip:/C:/Prog
            rammi/jBoss/server/default/deploy/example2.ear/example2.war/

             

            DEPLOYMENTS IN ERROR:
            Deployment "vfszip:/C:/Programmi/jBoss/server/default/deploy/example2.ear/" is
            in error due to the following reason(s): org.xml.sax.SAXException: The content
            of element type "servlet-mapping" must match "(servlet-name,url-pattern)". @ vfs
            zip:/C:/Programmi/jBoss/server/default/deploy/example2.ear/example2.war/WEB-INF/
            web.xml[16,21]
            at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(Dep
            loyersImpl.java:993)

             

            Ok, I know default package is discouraged, but it was just a test. I don't really think this is the an error cause (but I may be wrong )

            No, I don't use Eclipse, at least for the first projects. I want to understand step-by-step how the whole thing works. The only strange thing I did was to modify the listening port from 8080 to 8070 (in order to avoid conflicts with Tomcat).

             

            And, as I wrote, I developed it also in the manal way after JBoss started but nothing to do, always the same error. Well, all the configuration files are contained in the .ear I attached. Anyway, the class reads:

             

            import java.io.*;

            import java.text.*;

            import java.util.*;

            import javax.servlet.*;

            import javax.servlet.http.*;

            public class HelloWorld extends HttpServlet {

            public void service(HttpServletRequest request,
            HttpServletResponse       response) throws  IOException, ServletException{
                 response.setContentType("text/html");
                 PrintWriter out = response.getWriter();
                 out.println("<html>");
                 out.println("<head>");
                 out.println("<title>Hello World Servlet!</title>");
                 out.println("</head>");
                 out.println("<body>");
                 out.println("<p align=\"center\"><font size=\"5\" color=\"#000080\">Hello World!</font></p>");
                 out.println("<p align=\"center\"><a href=\"javascript:history.back()\">Go to Home</a></p>");
                 out.println("</body>");
                 out.println("</html>");
                }
            }

             

            From the error message it seems there is an error in web.xml but I don't really understand this magic code. I have knowledge of servlets but I don't know the hidden mechanisms behind JBoss deployment so I wouldn't know where to modify the file.

             

            <?xml version="1.0" encoding="ISO-8859-1"?>

             

            <!DOCTYPE web-app
                PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
                "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

             

            <web-app>
                    <servlet>
                            <servlet-name>HelloWorld</servlet-name>
                            <servlet-class>HelloWorld</servlet-class>
                    </servlet>

             

                    <servlet-mapping>
                      <url-pattern>/servlet/HelloWorld</url-pattern>
                      <servlet-name>HelloWorld</servlet-name>
                    </servlet-mapping>

             

            </web-app>

             

            Hope this will make the problem clearer...

            Thank you again!


            • 3. Re: [beginner] Deploying a ear file under JBoss AS 5
              Ok, I installed JBoss version 4.2 an it works perfectly. I now read the summary of the main differences between 4.2 and 5 (EE compliant) but I still can't understand why my code is not working on JBoss 5.
              • 4. Re: [beginner] Deploying a ear file under JBoss AS 5
                peterj

                This extra error message helps:

                 

                sarko86 wrote:

                 

                The content
                of element type "servlet-mapping" must match "(servlet-name,url-pattern)". @ vfs
                zip:/C:/Programmi/jBoss/server/default/deploy/example2.ear/example2.war/WEB-INF/
                web.xml[16,21]

                JBoss AS 5 is striucter whne it comes to following the web.xml file layout thatn what AS 4.x was. The issue is that you have the servlet-name and url-pattern in the wriong order; it should be:

                 

                 <servlet-mapping>
                    <servlet-name>HelloWorld</servlet-name>
                    <url-pattern>/servlet/HelloWorld</url-pattern>
                 </servlet-mapping>
                • 5. Re: [beginner] Deploying a ear file under JBoss AS 5
                  Thank you very much, that was it!