frjaeger220 / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 0 forks source link

Xwork conversion causes a null pointer exception #278

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When I create a xwork-conversion.properties file in my Struts2 app, I start
getting a null pointer exceptions.  It looks like the cause is guice.

Here is the stack trace:
 java.lang.NullPointerException

com.google.inject.struts2.GuiceObjectFactory$ProvidedInterceptor.intercept(Guice
ObjectFactory.java:224)

com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvoc
ation.java:230)

com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvoc
ation.java:229)

com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.jav
a:456)

com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.j
ava:227)

org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:477)

org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:46
7)

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilt
erChain.java:235)

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.
java:206)

org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:2
33)

org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:1
91)

org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109
)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)

org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Pr
otocol.java:583)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    java.lang.Thread.run(Thread.java:619)

The same configuration works fine with spring.  I also did some searching
and it looks like others are having this problem and the only work around
is to use the ObjectFactory in jcatapult.

Original issue reported on code.google.com by a.rugg...@gmail.com on 27 Nov 2008 at 8:23

GoogleCodeExporter commented 9 years ago
In an attempt to port over the jcatapult implementation I'm still getting a null
pointer at:

com.google.inject.internal.ProviderMethodsModule on line 60

Original comment by a.rugg...@gmail.com on 27 Nov 2008 at 8:28

GoogleCodeExporter commented 9 years ago
If you could provide a test case, that'll make it possible to fix this.

Original comment by limpbizkit on 27 Nov 2008 at 9:47

GoogleCodeExporter commented 9 years ago
I'll see if I can work something up.

Original comment by a.rugg...@gmail.com on 28 Nov 2008 at 5:07

GoogleCodeExporter commented 9 years ago
After further investigation this is not a guice bug.  I can't tell if the issue 
is in
Struts or XWork.  Basically what's happening is the object factory is getting
initialized and then the buildBean is called for the type converters before the
configuration settings are set (like setModule).  So the user specified module 
will
not be set when the first buildBean is called.

I do not understand why this affects the Guice plugin since it initializes 
lazily. 
This does not affect spring, jcatpult since they do not get their configuration 
from
the struts constants.

Original comment by a.rugg...@gmail.com on 28 Nov 2008 at 7:03

GoogleCodeExporter commented 9 years ago

Original comment by limpbizkit on 28 Nov 2008 at 7:35

GoogleCodeExporter commented 9 years ago
Can anyone provide a link to the original bug of the causing project (struts or
xwork), which may provide a patch. This bug made me abandon Guice from struts 
project.

Original comment by bahri.ge...@gmail.com on 10 Feb 2010 at 12:58

GoogleCodeExporter commented 9 years ago
http://issues.apache.org/jira/browse/WW-2898

Original comment by a.rugg...@gmail.com on 10 Feb 2010 at 3:30

GoogleCodeExporter commented 9 years ago
Issue 611 has been merged into this issue.

Original comment by sberlin on 5 Mar 2011 at 2:50

GoogleCodeExporter commented 9 years ago
Since this issue is marked as "Invalid" and the Struts2 issue that you have 
linked to is marked as "Wont Fix", perhaps you guys could add some 
documentation to the Struts2 plug-in indicating that the use of custom type 
converters causes an issue.

Original comment by steven.b...@gmail.com on 5 Mar 2011 at 6:47

GoogleCodeExporter commented 9 years ago
Issue 619 has been merged into this issue.

Original comment by sberlin on 22 Mar 2011 at 10:20

GoogleCodeExporter commented 9 years ago
Here's a little patch that solves the issue in my environment.  I might be 
missing something, but it works for me.

It seems like the Struts2Factory could be refactored so that it doesn't rely on 
a particular order of method calls like it does now.  If struts calls 
buildInterceptor() before it calls buildBean() then this factory fails.  That 
seems like a very tight coupling to an undocumented and internal struts 
behavior.

I might tackle a refactoring once my current project is over.

Original comment by jeffgbut...@gmail.com on 23 Mar 2011 at 1:10

Attachments:

GoogleCodeExporter commented 9 years ago
This was marked as 'Invalid' on 2008, 2.5 years later a patch appears... 
perhaps reopening this issue could be explored?

Original comment by voytek.j...@gmail.com on 11 Jan 2012 at 8:38

GoogleCodeExporter commented 9 years ago
That patch seems to work. If nobody objects, could it be included in a future 
release? Despite the issue being "invalid".

Original comment by daniel.b...@gmail.com on 8 Jan 2013 at 2:59