Unable to load configuration file in Java
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.
Jason Rodriguez
Former JS dev for the swoosh, now changed to project management and studying in Korea
Updated on June 04, 2022Comments
-
Jason Rodriguez almost 2 years
I am working on a JavaBrains tutorial and after I finished the lesson, Tomcat says :
SEVERE: Exception starting filter struts2
Also :
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 and 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 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, executed.
-
Jason Rodriguez over 10 yearsI made the change and there are no visible errors now but when I compile and run the app it says
Unable to load configuration. - bean - jar:file:/Users/jasonrodriguez/Java/apache-tomcat-7.0.47/wtpwebapps/TutorialFinder/WEB-INF/lib/struts2-gxp-plugin-2.3.15.3.jar!/struts-plugin.xml:8:162
but my library path is connected tolib
like it is supposed to and I have the whole library of jars. Am I missing something? -
Lukasz Lenart over 10 yearsAs I commented in other question - remove it.
-
Roman C over 10 years@JasonRodriguez In each struts2 plugin there's a
struts-plugin.xml
and even it's not related to your question I will suggest you as per Lukasz Lenart said to remove it from classpath configuration and deployment artifacts. Because you are probably not use GXPs in your project that plugin is useless and it prevents you from bootstrap because it requires additional references on classpath related to GXP that are absent or you don't use them.