-
1. Re: [beginner] Deploying a ear file under JBoss AS 5
peterj Jan 9, 2010 3:13 PM (in response to sarko86)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
sarko86 Jan 10, 2010 4:01 AM (in response to peterj)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
sarko86 Jan 10, 2010 12:55 PM (in response to sarko86)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 Jan 11, 2010 10:02 AM (in response to sarko86)This extra error message helps:
sarko86 wrote:
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
sarko86 Jan 12, 2010 11:16 AM (in response to peterj)Thank you very much, that was it!