struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Prasann Grampurohit (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (WW-4825) NPE while using getText method from ActionSupport
Date Thu, 27 Jul 2017 10:03:00 GMT

    [ https://issues.apache.org/jira/browse/WW-4825?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16103027#comment-16103027
] 

Prasann Grampurohit commented on WW-4825:
-----------------------------------------

Hi [~sdutry],
Thank you for your reply. I notice that my action class is calling getText method from a class
level variable and that is why it is throwing NPE while creating the action class bean instance.

[~aleksandr-m] had mentioned that we cannot use getText from constructor.

This was working in Struts 2.3.3, but fails after upgrading to 2.5.12. Is there any alternative
if we want to use it at load of the class?

I have also posted it on StackOverflow now.

Thanks,
Prasann

> NPE while using getText method from ActionSupport
> -------------------------------------------------
>
>                 Key: WW-4825
>                 URL: https://issues.apache.org/jira/browse/WW-4825
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.5.12
>            Reporter: Prasann Grampurohit
>
> Hi,
> I am migrating a project from Struts 2.3.3 to Struts 2.5.12 and I see NullPointerException
when using the getText method from ActionSupport class.
> My action class extends ActionSupport class. I have package.properties file also packaged
in the war file.
> And in my action class I just use getText method to retrieve a property from package.properties
file.
> I see the below exception. Could you please help? Thank you.
> {code:java}
> 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
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message