我正在将一个项目从Struts 2.3.3迁移到Struts 2.5.12,在使用ActionSupport
类中的GetText
方法时,我看到了NullPointerException
。
我的action类扩展了ActionSupport
类。我有package.properties文件也打包在war文件中。
我的action类看起来像:
public class MyAction extends ActionSupport {
private List<String> months = new ArrayList<>(
Arrays.asList(getText("date.month.default"), "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"));
}
date.month.default=MM
ERROR DefaultDispatcherErrorHandler Exception occurred during processing request: Unable to instantiate Action, entryAction, defined for 'entry' in namespace '/'Error creating bean with name 'entryAction' defined in "/D:/Software/JBossEAP/jboss-eap-7.0/bin/content/Member.war/WEB-INF/classes/my/company/member/web/action/entry/spring-context.xml": Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [my.company.member.web.action.entry.EntryAction]: Constructor threw exception; nested exception is java.lang.NullPointerException
Unable to instantiate Action, entryAction, defined for 'entry' in namespace '/'Error creating bean with name 'entryAction' defined in "/D:/Software/JBossEAP/jboss-eap-7.0/bin/content/Member.war/WEB-INF/classes/my/company/member/web/action/entry/spring-context.xml": Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [my.company.member.web.action.entry.EntryAction]: Constructor threw exception; nested exception is java.lang.NullPointerException - action - vfs:/D:/Software/JBossEAP/jboss-eap-7.0/bin/content/Member.war/WEB-INF/classes/struts-default.xml:133:44
at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:318)
at com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399)
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:204)
at org.apache.struts2.factory.StrutsActionProxy.prepare(StrutsActionProxy.java:62)
at org.apache.struts2.factory.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:567)
at org.apache.struts2.dispatcher.ExecuteOperations.executeAction(ExecuteOperations.java:81)
at org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:143)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:285)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:264)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:175)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:792)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entryAction' defined in "/D:/Software/JBossEAP/jboss-eap-7.0/bin/content/Member.war/WEB-INF/classes/my/company/member/web/action/entry/spring-context.xml": Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [my.company.member.web.action.entry.EntryAction]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
at com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:159)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:172)
at com.opensymphony.xwork2.factory.DefaultActionFactory.buildAction(DefaultActionFactory.java:22)
at com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:137)
at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:299)
... 37 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [my.company.member.web.action.entry.EntryAction]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958)
... 48 more
Caused by: java.lang.NullPointerException
at com.opensymphony.xwork2.ActionSupport.getTextProvider(ActionSupport.java:278)
at com.opensymphony.xwork2.ActionSupport.getText(ActionSupport.java:83)
at my.company.member.web.action.MyAction.<init>(MyAction.java:95)
at my.company.member.web.action.entry.EntryAction.<init>(EntryAction.java:22)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
... 50 more
以下jar文件添加到WAR文件中的WEB-INF/lib中:
classworlds-1.1.jar
com.springsource.org.aopalliance-1.0.0.jar
commons-betwixt-0.8.jar
commons-chain-1.2.jar
commons-digester-1.8.jar
commons-fileupload-1.2.1.jar
commons-httpclient-3.1.jar
commons-io-2.4.jar
commons-lang3-3.6.jar
commons-validator-1.3.1.jar
freemarker-2.3.23.jar
gson-2.1.jar
httpclient-4.3-beta1.jar
httpcore-4.2.2.jar
javassist-3.18.0-ga.jar
jaxrpc-api-1.1.jar
jcifs-1.3.17.jar
log4j-api-2.8.2.jar
ognl-3.1.12.jar
oro-2.0.8.jar
serializer-2.7.1.jar
spring-aop-3.0.5.release.jar
-asm-3.0.5.release.jar
spring-beans-3.0.5.release.jar
spring-context-support-3.0.5.release.jar
spring-core-3.0.5.release.jar
spring-expression-3.0.5.release.jar
spring-jdbc-3.0.5.release.jar
spring-jms-3.0.5.release.jar
spring-orm-3.0.5.release.jar
spring-remoting-2.0.8.jar
spring-tx-3.0.5.release.jar
spring-web-3.0.5.release.jar
struts2-core-2.5.12.jar
struts2-spring-plugin-2.5.12.jar
struts2-spring-plugin-2.5.12.jar
struts2-tiles-plugin-2.5.12.jar
tiles-api-3.0.7.jar
tiles-autotag-core-runtime-1.2.jar
tiles-core-3.0.7.jar
tiles-ele-3.0.7.jar
tiles-freemarker-3.0.7.jar
tiles-ognl-3.0.7.jar
tiles-request-api-1.0.6.jar
tiles-request-freemarker-1.0.6.jar
tiles-request-jsp-1.0.6.jar
tiles-servlet-1.0.6.jar
tiles-template-3.0.7.jar
wsdl4j-1.5.1.jar
xml-apis-1.3.02.jar
不应使用名为struts-default.xml
的文件。这是一个默认加载的配置文件。应用程序的默认配置文件名为struts.xml
。
重命名此文件
struts-default.xml
至
struts.xml
我遵循了如何在PHP中使用gettext加载语言的说明? 我创建了./locale/pl_PL/LC_MESSAGES/default.po文件: 我已使用以下命令生成mo文件: 我有这样的代码: 但我有未翻译的文本,输出是: 我也尝试在区域设置的末尾使用斜杠,但没有帮助。 发生了什么?如何使用gettext翻译文本?我正在GNU/Linux上运行Apache2中的php。我使用的是slim和tw
我对java“I get this error”不熟悉,找不到适合getText(String)方法JTextComponent的方法。getText(int,int)不适用(实际参数列表和形式参数列表长度不同)方法JTextComponent。getText()不适用 (Alt Enter显示提示)“当我试图运行我的程序时。请帮助。我做错了什么?
问题内容: 我从没想过,只有我使用了返回一个字符数组的方法,并且看到该方法已被 弃用 。但是现在我想,为什么 不赞成使用 此方法? Java文档说明: 不推荐使用 。 从Java 2 Platform v1.2开始,由取代。 获取由组件表示的文本的一部分。如果length为0,则返回一个空字符串。 出于安全原因,不建议使用此方法。请改用该方法。 但是那些 安全原因是 什么?有什么想法吗? 先感谢您
问题内容: 我浏览了文档,但找不到使用Spring 3.0使用@Async带注释的方法时,是否有办法为生成的异步操作指定超时。 有没有办法做到这一点?我认为这在触发异步计算时非常重要。 问题答案: 注释不提供超时,因为超时应由函数的调用者而不是函数本身决定。 我假设您是在-annotated方法上引用超时,该方法返回结果。此类方法应返回的实例,并且on 方法用于指定超时。 例如 然后
本文向大家介绍C++中Boost.Chrono时间库的使用方法,包括了C++中Boost.Chrono时间库的使用方法的使用技巧和注意事项,需要的朋友参考一下 前言 大家应该都有所体会,时钟这个东西在程序中扮演者重要的角色,在系统编程的时候睡眠、带超时的等待、带超时的条件变量、带超时的锁都会用到,但是往往对特定系统依赖性很大,感觉即使不考虑系统的跨平台性,如果能使用一个稳定的接口,同时如果能够方便
这是我的代码:- 我已经仔细检查了所有的身份验证参数。 将主文件夹中的文件保存为状态。py后运行python状态。py出现以下错误:- 请帮帮我