The First Problem

I have come across this problem at 2 times this weekend. Since I came across it twice, I assume a high likelihood that others will as well. Hopefully the people of the future will be able to Google the stack trace and find this post. The problem is that after mucking around with my struts-config.xml file's hooks, I got this error when trying to visit a page:

javax.servlet.ServletException: java.lang.NullPointerException
	org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
	org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
	org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	com.philihp.weblabora.util.EntityManagerFilter.doFilter(EntityManagerFilter.java:32)

java.lang.NullPointerException
	org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:289)
	org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:357)
	org.apache.struts.chain.commands.CreateActionForm.execute(CreateActionForm.java:92)
	org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
	org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
	org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
	org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
	org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
	org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
	org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	com.philihp.weblabora.util.EntityManagerFilter.doFilter(EntityManagerFilter.java:32)

The problem was that the type of my form-bean couldn't be instantiated, because it didn't exist. My config looked like:


	
	

The problem was org.apache.struts.action.DynaValidatorForm does not exist (or wasn't found on the classpath). Instead, the correct line was


	
	

In another case, I typed "com.apache..." instead of "org.apache...".

The Second Problem

This problem's symptom was a stack trace like this:

java.lang.IllegalArgumentException: The path of an ForwardConfig cannot be null
	org.apache.struts.chain.commands.servlet.PerformForward.perform(PerformForward.java:70)
	org.apache.struts.chain.commands.AbstractPerformForward.execute(AbstractPerformForward.java:54)
	org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
	org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
	org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
	org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
	org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
	org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
	org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

The problem is that an Action with a ValidatorForm form was validating with errors, and didn't know where to send the client back to. This can happen if both the validate and input attributes of the Action are omitted. It can be remedied by setting validate="false" (if you don't want it to validate) or input="some path" (if you do want it to validate).

Struts needs to know where to send the user if there are errors in validation.