You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "nathan.vel" <th...@nttdata.com> on 2014/09/04 08:41:27 UTC

Null Pointer Exception during Struts-2 with Struts-1 Plugin

Hi Techies,

             I'm integrating my existing Struts1 application with Struts2
using the plugin,

My web.xml,

        <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>*.nav</url-pattern>
        </filter-mapping>


and it contains struts1 configuration as well,

  <servlet>
 <servlet-name>action</servlet-name>
       
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<load-on-startup>1</load-on-startup>
    </servlet>

So if the URL ending with xxx.nav which takes me to Struts.xml file resides
in the classes folder,

My Struts.xml file,

<?xml version="1.0" encoding="UTF-8" ?> 
<!DOCTYPE struts PUBLIC &quot;-//Apache Software Foundation//DTD Struts 
            Configuration 2.3//EN&quot; 
&quot;http://struts.apache.org/dtds/struts-2.3.dtd&quot;>
<struts>

	<constant name="struts.devMode" value="true" />
	<constant name="struts.action.extension" value=",nav" />

	<package name="sample" namespace="/" extends="struts1-default">
		
		<interceptors>
			<interceptor name="makeReservationForm"
class="com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor">
				com.formcomponent.ReservationFormBean
				makeReservationForm
				 session
			</interceptor>
			
			<interceptor-stack name="sample-example">
				<interceptor-ref name="staticParams"/> 
				<interceptor-ref name="makeReservationForm"/>
				<interceptor-ref name="modelDriven"/>
				<interceptor-ref name="basicStack"/>
			</interceptor-stack>
	  
		</interceptors>

		<default-interceptor-ref name="sample-example"/>
		
		<action name="ReservationInitializeStart"
class="org.apache.struts2.s1.Struts1Action">
			com.actions.ReservationInitializeAction
			<interceptor-ref name="sample-example"></interceptor-ref>  
			<result name="SUCCESSFUL">reservation_stay.jsp</result>
			<result name="FAILURE">welcome.jsp</result>
		</action>
	
	</package>

</struts> 

While hitting with the URL
http://localhost:90/Application/ReservationInitializeStart.nav, am facing
null pointer exception as below,

 Struts has detected an unhandled exception:
Messages: 	
File: 	org/apache/struts2/s1/Struts1Action.java
Line number: 	113
Stacktraces
java.lang.NullPointerException

    org.apache.struts2.s1.Struts1Action.execute(Struts1Action.java:113)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:592)
   
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)
   
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)
   
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)
   
org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)
   
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
   
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
   
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
   
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)
   
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
   
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
   
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)
   
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
   
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
   
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
   
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
   
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
   
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
   
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
   
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)

I'm using the below jar files,

struts-1.1-rc2-b1
struts2-core-2.3.16.3
struts2-struts1-plugin-2.1.2
struts-core-1.3.5


Please help me out to resolve this issue. Thanks in advance !!


--
Regards,

Nathan.




--
View this message in context: http://struts.1045723.n5.nabble.com/Null-Pointer-Exception-during-Struts-2-with-Struts-1-Plugin-tp5716608.html
Sent from the Struts - Dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Null Pointer Exception during Struts-2 with Struts-1 Plugin

Posted by Ken McWilliams <ke...@gmail.com>.
My guess would be exactly as stated in your action in the execute method of
file "Struts1Action.java" there is a null pointer exception on line 113.
So did you assert that the objects used on that line are indeed not null?
You could post the code for that method here but it isn't likely a fault of
Struts,a comment pointing out line 113 would be great.


On Thu, Sep 4, 2014 at 12:41 AM, nathan.vel <
thangavel.loganathan@nttdata.com> wrote:

> Hi Techies,
>
>              I'm integrating my existing Struts1 application with Struts2
> using the plugin,
>
> My web.xml,
>
>         <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>*.nav</url-pattern>
>         </filter-mapping>
>
>
> and it contains struts1 configuration as well,
>
>   <servlet>
>  <servlet-name>action</servlet-name>
>
> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
> <load-on-startup>1</load-on-startup>
>     </servlet>
>
> So if the URL ending with xxx.nav which takes me to Struts.xml file resides
> in the classes folder,
>
> My Struts.xml file,
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE struts PUBLIC &quot;-//Apache Software Foundation//DTD Struts
>             Configuration 2.3//EN&quot;
> &quot;http://struts.apache.org/dtds/struts-2.3.dtd&quot;>
> <struts>
>
>         <constant name="struts.devMode" value="true" />
>         <constant name="struts.action.extension" value=",nav" />
>
>         <package name="sample" namespace="/" extends="struts1-default">
>
>                 <interceptors>
>                         <interceptor name="makeReservationForm"
> class="com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor">
>                                 com.formcomponent.ReservationFormBean
>                                 makeReservationForm
>                                  session
>                         </interceptor>
>
>                         <interceptor-stack name="sample-example">
>                                 <interceptor-ref name="staticParams"/>
>                                 <interceptor-ref
> name="makeReservationForm"/>
>                                 <interceptor-ref name="modelDriven"/>
>                                 <interceptor-ref name="basicStack"/>
>                         </interceptor-stack>
>
>                 </interceptors>
>
>                 <default-interceptor-ref name="sample-example"/>
>
>                 <action name="ReservationInitializeStart"
> class="org.apache.struts2.s1.Struts1Action">
>                         com.actions.ReservationInitializeAction
>                         <interceptor-ref
> name="sample-example"></interceptor-ref>
>                         <result
> name="SUCCESSFUL">reservation_stay.jsp</result>
>                         <result name="FAILURE">welcome.jsp</result>
>                 </action>
>
>         </package>
>
> </struts>
>
> While hitting with the URL
> http://localhost:90/Application/ReservationInitializeStart.nav, am facing
> null pointer exception as below,
>
>  Struts has detected an unhandled exception:
> Messages:
> File:   org/apache/struts2/s1/Struts1Action.java
> Line number:    113
> Stacktraces
> java.lang.NullPointerException
>
>     org.apache.struts2.s1.Struts1Action.execute(Struts1Action.java:113)
>     sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>     java.lang.reflect.Method.invoke(Method.java:592)
>
>
> com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)
>
>
> com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)
>
>
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)
>
>
> org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)
>
>
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
>
>
> com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
>
>
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
>
>
> com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)
>
>
> com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
>
>
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
>
>
> com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)
>
>
> com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
>
>
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
>
>
> org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
>
>
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
>
>
> org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
>
>
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
>
>
> com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
>
>
> com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
>
> I'm using the below jar files,
>
> struts-1.1-rc2-b1
> struts2-core-2.3.16.3
> struts2-struts1-plugin-2.1.2
> struts-core-1.3.5
>
>
> Please help me out to resolve this issue. Thanks in advance !!
>
>
> --
> Regards,
>
> Nathan.
>
>
>
>
> --
> View this message in context:
> http://struts.1045723.n5.nabble.com/Null-Pointer-Exception-during-Struts-2-with-Struts-1-Plugin-tp5716608.html
> Sent from the Struts - Dev mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

Re: Null Pointer Exception during Struts-2 with Struts-1 Plugin

Posted by Dave Newton <da...@gmail.com>.
On Thu, Sep 4, 2014 at 2:41 AM, nathan.vel <thangavel.loganathan@nttdata.com
> wrote:

> struts-1.1-rc2-b1
> struts2-core-2.3.16.3
> struts2-struts1-plugin-2.1.2
> struts-core-1.3.5
>

That's a... peculiar mix of essentially random libraries.

Have you considered using:

1) Matching S2 libs, and
2) A single S1 implementation?


-- 
e: davelnewton@gmail.com
m: 908-380-8699
s: davelnewton_skype
t: @dave_newton <https://twitter.com/dave_newton>
b: Bucky Bits <http://buckybits.blogspot.com/>
g: davelnewton <https://github.com/davelnewton>
so: Dave Newton <http://stackoverflow.com/users/438992/dave-newton>