You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by bberken <bb...@mainstreamdata.com> on 2009/12/31 01:49:10 UTC

Struts 2.0 to 2.1 Migration problem

I've attempted to update our application from struts 2.0.6 to 2.1.6 (also
using tiles 2.0.6) and am running into problems - I have a global error
result defined as a jsp inside my WEB-INF dir:


 ....
/WEB-INF/jsp/Error.jsp



and rendering of this jsp (and any jsp inside my WEB-INF) is failing on any 
tags inside that jsp. I receive a nullpointerexception:

java.lang.NullPointerException

	at
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:49)

	at
org.apache.jsp.WEB_002dINF.jsp.Error_jsp._jspx_meth_s_005finclude_005f0(Error_jsp.java:143)


And debugging into ComponentTagSupport shows that the line:

Container container = Dispatcher.getInstance().getContainer();


is failing due to inability to obtain an instance of the Dispatcher. 


This all appears to work if I move the jsps out of WEB-INF and into my
normal webcontext directory.


Does anyone have any thoughts as to what I'm missing? This did all work
w/struts 2.0.6, and I've only made small modifications to my web.xml..
following this migration howto:
 
http://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html
http://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html 


thanks


-- 
View this message in context: http://old.nabble.com/Struts-2.0-to-2.1-Migration-problem-tp26974067p26974067.html
Sent from the Struts - User mailing list archive at Nabble.com.

Re: Struts 2.0 to 2.1 Migration problem

Posted by Dale Newfield <da...@newfield.org>.
OP wrote:
> 2.0.6 ... 2.1.6

Any reason you'd upgrade to an old version, and not the most recently 
released 2.1.8.1?

-Dale

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


Re: Struts 2.0 to 2.1 Migration problem

Posted by bberken <bb...@mainstreamdata.com>.
Thx Wes, 
I will play with your suggestions and see what I can get to work as well as
dig more info out of my log files.

As to what changed between struts 2.0.6 and 2.1.6 do you have any thoughts
as to why it would just stop working? 
You had mentioned some changes in the DispatcherFilter?



-- 
View this message in context: http://old.nabble.com/Struts-2.0-to-2.1-Migration-problem-tp26974067p26981332.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Struts 2.0 to 2.1 Migration problem

Posted by Wes Wannemacher <we...@wantii.com>.
On Thu, Dec 31, 2009 at 10:53 AM, bberken <bb...@mainstreamdata.com> wrote:

[snip]

>
>        <error-page>
>                <exception-type>java.lang.Exception</exception-type>
>                <location>/WEB-INF/jsp/Error.jsp</location>
>        </error-page>
>

[snip]

> struts.xml global-results:
>
>              <global-results>

...

>                        <result name="error" type="dispatcher">/WEB-INF/jsp/Error.jsp</result>
>

[snip]



My guess is that the exception is being caught by the Application
Server. If the dispatcher / filter isn't run against the request, the
Container will be unavailable. Topics similar to this have come up in
the past, but I can't remember the exact solution. There are a few
ways to view the "solution" to your problem. For one, if you want to
catch *all* errors and use the error-page in the web.xml, then don't
use any struts tags in there. This is my preferred method, simply
because the error could come from deep in the darkest trenches of the
framework (or another framework - i.e. Hibernate / Spring
filters/listeners). It's a bit of a chicken-and-egg problem. If you
want absolute certainty, then take the tags out of your error page.

Another approach is to create a graph of exception-mappings -

http://struts.apache.org/2.x/docs/exception-configuration.html

Which it looks like you have attempted to do. However, I don't think
using "Throwable" is enough. When you have the problem, do you see a
stack-trace in the application server console? There is bound to be
another exception that happens beforehand that is causing the "error"
result to be dispatched to... Basically, the NPE is a result of the
"error" result attempt, so what is the cause of the "error" result?
(hint, it isn't the NPE, it'll most likely be in your application
server logs).

Once you track that down, you can solve this particular problem, but
long-term, I don't think your exception-mapping will work 100% of the
time, you will find situations like this that are simply outside of
the scope of Struts to handle.

-Wes

-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

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


Re: Struts 2.0 to 2.1 Migration problem

Posted by bberken <bb...@mainstreamdata.com>.
"Can you post your web.xml, particularly the section that defines the
Struts filters? "

my web.xml:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
	version="2.4">
				
	<display-name>TestApp</display-name>
	<description>TestApp.</description>
	
	<welcome-file-list>
		<welcome-file>/pages/index.jsp</welcome-file>
	</welcome-file-list>
	
	<error-page>
		<exception-type>java.lang.Exception</exception-type>
		<location>/WEB-INF/jsp/Error.jsp</location>
	</error-page>
	
	<context-param>
		<description>This context parameter specifies the name and location 
		of the Spring root application context file.</description>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath*:applicationContext*.xml</param-value>
	</context-param>

	<context-param>
		<description>This context parameter specifies the name and location 
		of the Tiles Definitions file.</description>
		<param-name>org.apache.tiles.DEFINITIONS_CONFIG</param-name>
		<param-value>/WEB-INF/classes/tiles-defs.xml</param-value>
	</context-param>

     <session-config>
      <session-timeout>20</session-timeout> 
    </session-config>   
  
    <filter>
		<filter-name>encodingFilter</filter-name>
	
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>	
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>	
		<init-param>
			<param-name>forceEncoding</param-name>
			<param-value>true</param-value>
		</init-param>
	</filter>
	<filter>
		<filter-name>openSessionInViewFilter</filter-name>
	
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
	</filter>

	<filter>
		<filter-name>filterDispatcher</filter-name>
	
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
	</filter>

	<filter-mapping>
       <filter-name>encodingFilter</filter-name>
       <url-pattern>/*</url-pattern>
    </filter-mapping>
	
	<filter-mapping>
		<filter-name>openSessionInViewFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	
	<filter-mapping>
		<filter-name>filterDispatcher</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<listener>
    
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	<listener>
	
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
	</listener>
	

</web-app>

"Also, can you post the configuration of this
global error result?"

struts.xml global-results:

              <global-results>
		   <result name="accessDenied" type="dispatcher">accessDenied.jsp</result>
		    <result name="loginLimit"
type="dispatcher">loginLimitCheck.jsp</result>
		    <result name="loginExpiered"
type="dispatcher">loginExpiered.jsp</result>
		    <result name="loginDisabled"
type="dispatcher">loginDisabled.jsp</result>
		    <result name="loginIncorrect"
type="dispatcher">loginIncorrect.jsp</result>
		    <result name="notloggedin" type="dispatcher">/login.jsp</result>
		    <result name="notloggedintype2"
type="dispatcher">/logintemplate2.jsp</result>
			<result name="error" type="dispatcher">/WEB-INF/jsp/Error.jsp</result>
			<result name="success" type="redirectAction">default</result>
		</global-results>
	
		<global-exception-mappings>
			<exception-mapping exception="java.lang.Throwable" result="error"/> 
		</global-exception-mappings>


On Wed, Dec 30, 2009 at 7:49 PM, bberken <bb...@mainstreamdata.com>
wrote:
>
> I've attempted to update our application from struts 2.0.6 to 2.1.6 (also
> using tiles 2.0.6) and am running into problems - I have a global error
> result defined as a jsp inside my WEB-INF dir:
>
>
>  ....
> /WEB-INF/jsp/Error.jsp
>
>
>
> and rendering of this jsp (and any jsp inside my WEB-INF) is failing on
> any
> tags inside that jsp. I receive a nullpointerexception:
>
> java.lang.NullPointerException
>
>        at
> org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:49)
>
>        at
> org.apache.jsp.WEB_002dINF.jsp.Error_jsp._jspx_meth_s_005finclude_005f0(Error_jsp.java:143)
>
>
> And debugging into ComponentTagSupport shows that the line:
>
> Container container = Dispatcher.getInstance().getContainer();
>
>
> is failing due to inability to obtain an instance of the Dispatcher.
>
>
> This all appears to work if I move the jsps out of WEB-INF and into my
> normal webcontext directory.
>
>
> Does anyone have any thoughts as to what I'm missing? This did all work
> w/struts 2.0.6, and I've only made small modifications to my web.xml..
> following this migration howto:
>
> http://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html
> http://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html
>
>
> thanks
>
>
> --
> View this message in context:
> http://old.nabble.com/Struts-2.0-to-2.1-Migration-problem-tp26974067p26974067.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>



-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

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




-- 
View this message in context: http://old.nabble.com/Struts-2.0-to-2.1-Migration-problem-tp26974067p26979597.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Struts 2.0 to 2.1 Migration problem

Posted by Wes Wannemacher <we...@wantii.com>.
Hello,

Can you post your web.xml, particularly the section that defines the
Struts filters? Between 2.0 and 2.1, we broke the DispatcherFilter
into multiple filters. Also, can you post the configuration of this
global error result?

-Wes

On Wed, Dec 30, 2009 at 7:49 PM, bberken <bb...@mainstreamdata.com> wrote:
>
> I've attempted to update our application from struts 2.0.6 to 2.1.6 (also
> using tiles 2.0.6) and am running into problems - I have a global error
> result defined as a jsp inside my WEB-INF dir:
>
>
>  ....
> /WEB-INF/jsp/Error.jsp
>
>
>
> and rendering of this jsp (and any jsp inside my WEB-INF) is failing on any
> tags inside that jsp. I receive a nullpointerexception:
>
> java.lang.NullPointerException
>
>        at
> org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:49)
>
>        at
> org.apache.jsp.WEB_002dINF.jsp.Error_jsp._jspx_meth_s_005finclude_005f0(Error_jsp.java:143)
>
>
> And debugging into ComponentTagSupport shows that the line:
>
> Container container = Dispatcher.getInstance().getContainer();
>
>
> is failing due to inability to obtain an instance of the Dispatcher.
>
>
> This all appears to work if I move the jsps out of WEB-INF and into my
> normal webcontext directory.
>
>
> Does anyone have any thoughts as to what I'm missing? This did all work
> w/struts 2.0.6, and I've only made small modifications to my web.xml..
> following this migration howto:
>
> http://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html
> http://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html
>
>
> thanks
>
>
> --
> View this message in context: http://old.nabble.com/Struts-2.0-to-2.1-Migration-problem-tp26974067p26974067.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>



-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

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