File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes struts of ear package has problem in jboss, but the war file runs well in tomcat. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts of ear package has problem in jboss, but the war file runs well in tomcat. " Watch "struts of ear package has problem in jboss, but the war file runs well in tomcat. " New topic
Author

struts of ear package has problem in jboss, but the war file runs well in tomcat.

Pak Hong Man
Greenhorn

Joined: Feb 17, 2011
Posts: 5

Dear experts,

I have a question about struts, ear package in jboss.

Problem:

I use ant to build and make war file and ear file package. I want to put ear in jboss to deploy my application. However, the following error occurs.

I put the war file into tomcat server, it runs well. The entry url is http://localhost:8080/javaBean

jboss log:
2011-02-18 11:39:58,640 ERROR [org.apache.struts.util.RequestUtils] (http-127.0.0.1-8080-1) Error creating form bean of class com.visualbuilder.struts.beans.User
java.lang.NullPointerException
at org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:289)
at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:259)
at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:213)
at org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:526)
at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:503)
at org.apache.jsp.index_jsp._jspx_meth_html_005fform_005f0(index_jsp.java:133)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:89)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)
2011-02-18 11:39:58,640 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/javaBean].[jsp]] (http-127.0.0.1-8080-1) Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: Exception creating bean of class com.visualbuilder.struts.beans.User under form name loginForm
at org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:536)
at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:503)
at org.apache.jsp.index_jsp._jspx_meth_html_005fform_005f0(index_jsp.java:133)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:89)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)

The application.xml in ear file package.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">

<application>
<display-name>One-stop Shop System</display-name>
<module>
<web>
<web-uri>javaBean.war</web-uri>
<context-root>/javaBean</context-root>
</web>
</module>
</application>



My ant script to make ear after war:

<?xml version="1.0"?>

<project name="javaBean" default="main" basedir="../">

<!-- DEPLOY DIR -->
<property name="deploydir" value="${basedir}/deploy" />

<!-- PROJECT ROOT -->
<property name="project.root" value="${basedir}" />

<property environment="currentenv" />
<property name="rootdir" value="../" />


<property name="java.lib" value="${project.root}/WebContent/WEB-INF/lib" />
<property name="jboss.lib" value="c:\jboss-5.0.1.GA\lib" />
<property name="java.jre" value="c:\Program Files\Java\jre6\lib" />
<property name="jboss.srv.lib" value="c:\eclipse\configuration\org.eclipse.osgi\bundles\164\1\.cp\lib\jboss" />

<property name="project.name" value="javaBean" />
<property name="release.no" value="1.0" />
<property name="vendor.name" value="hp" />


<!-- CLASSPATH -->
<path id="class.path">
<pathelement path="${currentenv.CLASSPATH}"/>
</path>

<!-- STRUTS -->
<property name="struts.path" value="${basedir}/WebContent/lib"/>

<!-- ANT ROOT -->
<property name="ant.root" value="${basedir}/ant" />

<!-- CLEAN -->
<target name = "clean">
<echo message="Removing old directory structure... ${project.root}/deploy" />
<delete dir="${project.root}/deploy" />
<delete dir="${project.root}/build" />
<delete dir="${project.root}/war" />
</target>

<!-- MAKE DEPLOY DIR -->
<target name = "mkDeployDir">
<echo message = "Making deploy directorys... ${project.root}/deploy and ${project.root}/deploy/web" />
<mkdir dir="${project.root}/deploy" />
<mkdir dir="${project.root}/deploy/web" />
<mkdir dir="${project.root}/build" />
<mkdir dir="${project.root}/war" />
</target>

<!-- COPY WEB CONTENT -->
<target name = "copyWebContent">
<echo message="Copying web archieves... from ${project.root}/WebContent to ${project.root}/deploy/web" />
<copy todir="${project.root}/deploy/web" overwrite="true">
<fileset dir="${project.root}/WebContent" >
<include name="**" />
</fileset>
</copy>
<echo message="Copying web archieves... from ${project.root}/build to ${project.root}/deploy/web" />
<copy todir="${project.root}/deploy/web/WEB-INF/classes" overwrite="true">
<fileset dir="${project.root}/build/" >
<include name="**" />
</fileset>
</copy>

</target>

<path id="master-classpath">
<fileset dir="${java.lib}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${jboss.lib}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${jboss.srv.lib}">
<include name="**/*.jar" />
</fileset>


</path>

<!-- COMPILE ALL JAVA SOURCE IN A PACKAGE -->
<target name = "compileProject">
<javac destdir="${project.root}/build" failonerror="true" includeantruntime="false">
<src path="${project.root}/src" />

<classpath refid="master-classpath"/>
</javac>
</target>

<!-- MAKE WAR -->
<target name="make-war" >
<tstamp>
<format property="TODAY" pattern="MM/dd/yyyy hh:mm aa" locale="en" />
</tstamp>
<jar jarfile="${project.root}/war/${project.name}.war">
<manifest>
<attribute name="Built-By" value="${user.name}" />
<attribute name="Module-Name" value="${project.name}" />
<attribute name="Version" value="${release.no}" />
<attribute name="Vendor" value="${vendor.name}" />
<attribute name="Date" value="${TODAY}" />

<section name="${project.name}">
</section>
</manifest>
<fileset dir="${project.root}/deploy/web" includes="*, **/*" />
</jar>
</target>

<!-- MAKE EAR -->
<target name="make-ear">
<tstamp>
<format property="TODAY" pattern="d-MMMM-yyyy hh:mm aa" locale="en"/>
</tstamp>
<copy overwrite="yes" verbose="yes" file="scripts/application-src.xml" tofile="scripts/application.xml" />
<replace file="scripts/application.xml">
<replacefilter token="@app.contextPath@" value="${project.name}" />
<replacefilter token="@war.file_name@" value="${project.name}.war" />
</replace>

<ear destfile="${project.root}/${project.name}.ear" basedir="${project.root}/war" appxml="scripts/application.xml" >
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Application-Name" value="${project.name}"/>
<attribute name="Version" value="${release.no}"/>
<attribute name="Vendor" value="${vendor.name}" />
<attribute name="Date" value="${TODAY}"/>
</manifest>
</ear>

</target>


<echo message="pulling in property files"/>
<property file="axis_client.properties"/>

<echo message="calling the web services generation ant task: axis_client"/>

<target name="main" >
<echo message="basedir: ${basedir} ${line.separator}struts.path: ${struts.path} ${line.separator}project.root: ${project.root}" />
</target>

<target name = "deploy">
<mkdir dir="${project.root}/deploy"/>
</target>



<!-- j2ee -->
<path id="j2ee.class.path">
<pathelement path="${j2ee.home.path}/${j2ee.library.name}"/>
</path>

</project>


The com.visualbuilder.struts.beans.User package source is just a View Object as follows:
/**
*
*/
package com.visualbuilder.struts.beans;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
* This is the User class that represents a USER in the USERS table in the database
*
* @author VisualBuilder
*
*/
public class User extends ActionForm{
private String userId = "";
private String firstName = "";
private String lastName = "";
private int age = 0;
private String email = "";
private String password = "";

public User(String userId) {
super();
this.userId = userId;
}
public User(){
super();
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public ActionErrors validate(
ActionMapping mapping, HttpServletRequest request ) {

ActionErrors errors = new ActionErrors();
if( getUserId().length()<1 ) {
errors.add("name",new ActionMessage("null.check","User ID"));
}
if(getEmail().length()>0)
{
//Yes! user entered email address. validate it
if(!getEmail().matches("^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$")){
errors.add("name",new ActionMessage("email.invalid"));
}
}
return errors;
}
}




The entry url is http://localhost:8080/javaBean


Regards,

Man Pak Hong, Dave (Analyst Programmer)

manpakhong@hotmail.com
manpakhong

Pak Hong Man
Greenhorn

Joined: Feb 17, 2011
Posts: 5

I fixed the problem eventually.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">

<application>
<display-name>One-stop Shop System</display-name>
<module>
<web>
<web-uri>javaBean.war</web-uri>
<context-root>/javaBean</context-root> <---------------- change to <context-root>javaBean</context-root>
</web>
</module>
</application>

Man Pak Hong, Dave
manpakhong
manpakhong@hotmail.com
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: struts of ear package has problem in jboss, but the war file runs well in tomcat.