使用struts和spring开发时遇到Unable to load configuration. - action - |Caused by: Action

本文解决在使用Struts2框架时遇到的启动报错问题,包括Action类未找到错误,并提供了解决方案及所需导入的jar包。通过检查struts.xml配置文件与Spring的applicationContext.xml文件,确保项目的正确性。若错误仍然存在,可能是因为缺少关键的jar包,如struts2-spring-plugin-2.0.11.1.jar、commons-fileupload-1.2.1.jar和commons-io-1.3.2.jar。本文详细解释了如何定位问题并解决。

 

原文地址: http://www.cnblogs.com/dongritengfei/archive/2009/12/08/1619030.html

 

报错如下:

严重: Exception starting filter struts2
Unable to load configuration. - action - file:/D:/workspace/Ecplipse/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/GoogleMapFWZJW/WEB-INF/classes/struts.xml:7:38
 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
 at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:360)
 at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:403)

。。。。。。。

Caused by: Action class [login] not found - action - file:/D:/workspace/Ecplipse/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/GoogleMapFWZJW/WEB-INF/classes/struts.xml:7:38
 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:405)
 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:355)
 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:460)

。。。。。。。

 

对应的struts.xml文件如下:

<struts>
    <package name="example" namespace="" extends="struts-default">
        <action name="Login" class="login">
            <result>/loginResult.jsp</result>
            <result name="input">/login.jsp</result>
        </action>
    </package>
</struts>

其中的class=“login”的login对应spring的applicationContext.xml里的id为login的bean。

如果你的struts.xml和applicationContext.xml都配置正确,还报以上的错误,那么可以判断你的项目缺少jar包:struts2-spring-plugin-2.0.11.1.jarcommons-fileupload-1.2.1.jarcommons-io-1.3.2.jar

导入这些jar包就行了,这些jar可以在struts-2.1.6的lib下找到。

 

s -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dnacos.home=/home/nacos -jar /home/nacos/target/nacos-server.jar --spring.config.additional-location=file:/home/nacos/conf/ --spring.config.name=application --logging.config=/home/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288 ,--. ,--.'| ,--,: : | Nacos 2.2.1 ,`--.'`| ' : ,---. Running in stand alone mode, All function modules | : : | | ' ,'\ .--.--. Port: 8848 : | \ | : ,--.--. ,---. / / | / / ' Pid: 1 | : ' '; | / \ / \. ; ,. :| : /`./ Console: http://172.17.0.3:8848/nacos/index.html ' ' ;. ;.--. .-. | / / '' | |: :| : ;_ | | | \ | \__\/: . .. ' / ' | .; : \ \ `. https://nacos.io ' : | ; .' ," .--.; |' ; :__| : | `----. \ | | '`--' / / ,. |' | '.'|\ \ / / /`--' / ' : | ; : .' \ : : `----' '--'. / ; |.' | , .-./\ \ / `--'---' '---' `--`---' `----' 2025-08-15 14:11:05,741 INFO Tomcat initialized with port(s): 8848 (http) 2025-08-15 14:11:05,981 INFO Root WebApplicationContext: initialization completed in 7890 ms 2025-08-15 14:11:06,124 ERROR Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'authFilterRegistration' defined in class path resource [com/alibaba/nacos/core/auth/AuthConfig.class]: Unsatisfied dependency expressed through method 'authFilterRegistration' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authFilter' defined in class path resource [com/alibaba/nacos/core/auth/AuthConfig.class]: Unsatisfied dependency expressed through method 'authFilter' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authConfigs': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'NACOS_AUTH_IDENTITY_KEY' in value "${NACOS_AUTH_IDENTITY_KEY}" 2025-08-15 14:11:06,249 WARN Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat 2025-08-15 14:11:06,269 INFO Nacos Log files: /home/nacos/logs 2025-08-15 14:11:06,269 INFO Nacos Log files: /home/nacos/conf 2025-08-15 14:11:06,269 INFO Nacos Log files: /home/nacos/data 2025-08-15 14:11:06,280 ERROR Startup errors : org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:163) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:745) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:423) at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1317) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) at com.alibaba.nacos.Nacos.main(Nacos.java:35) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:467) Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:142) at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104) at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:479) at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:211) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:182) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160) ... 16 common frames omitted Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authFilterRegistration' defined in class path resource [com/alibaba/nacos/core/auth/AuthConfig.class]: Unsatisfied dependency expressed through method 'authFilterRegistration' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authFilter' defined in class path resource [com/alibaba/nacos/core/auth/AuthConfig.class]: Unsatisfied dependency expressed through method 'authFilter' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authConfigs': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'NACOS_AUTH_IDENTITY_KEY' in value "${NACOS_AUTH_IDENTITY_KEY}" at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541) at org.springframework.beans.factory.support.AbstractAutowireCapabl
08-16
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值