Reputation: 153
I'm working on JavaBrains tutorial, and after I finished the lesson, I ran the app, but got an exception.
The Tomcat log:
SEVERE: Exception starting filter struts2 Caused by: Unable to load configuration. - action - file:/Users/jasonrodriguez/Java/apache-tomcat-7.0.47/wtpwebapps/TutorialFinder/WEB-INF/classes/struts.xml:8:83 Caused by: Action class [org.koushik.javabrains.action.TutorialAction] not found - action - file:/Users/jasonrodriguez/Java/apache-tomcat-7.0.47/wtpwebapps/TutorialFinder/WEB-INF/classes/struts.xml:8:83
I went back to check it, but my web.xml
has the correct filter mapping:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>TutorialFinder</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
My struts.xml
has a namespace, action name, and class attributes:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="default" namespace="/tutorials" extends="struts-default">
<action name="getTutorial" class="org.koushik.javabrains.action.TutorialAction">
<result name="success">/success.jsp</result>
<result name="failure">/error.jsp</result>
</action>
</package>
</struts>
and my library build path is correct, but when I run Tomcat it tells me that the resource is not available, and since I am a novice, I don't know how to troubleshoot it, since there are no red x marks anywhere in my project. I thought, perhaps there was a file out of place somewhere, but it looks straight to me:
Perhaps a fresh pair of eyes can catch something that I missed. I had a similar problem with this tutorial yesterday, and the solution was to provide the class reference that exist on the classpath in my action tag.
However, that tag is already looking correct, as far as I can tell. My goal is to get the business service I created, and executed.
Upvotes: 1
Views: 11278
Reputation: 99
I know its very awkward suggestion/solution but this worked for me i was missing struts-spring-plugin.jar in my shared lib directory. It was there in my classpath but not in shared lib.
Thanks
Upvotes: 0
Reputation: 1
You have written a wrong package name: org.kouhsik.javabrains.action.TutorialAction
should be org.koushik.javabrains.action.TutorialAction
. May be it's just a typo or you have used the refactoring tool to change the package name. In either way you should use it back or use the correct reference in the configuration to the action in the class tag. Another approach is to use convention plugin and create configuration via annotations. In this case you are free of writing references to actions or methods because you place an annotation right to the class or method you want to be configured.
Upvotes: 2