开发者

threw an unexpected exception: java.lang.reflect.InvocationTargetException

I am working on GWT-Hibernate application, my application works perfectly on integrated GWT environment and even on external server tomcat. I need to deploy my application on JBoss V 6.0. I am able to successfully deploy my application on JBoss and able to run until on point of execution. At particular button click application threw an unexpected exception: java.lang.reflect.InvocationTargetException

Normally "java.lang.reflect.InvocationTargetException" occurs when java compiler finds 2 different classes with same name in 2 different packages. when you are importing both classes at a time and when you are trying to create object of that class it throws "java.lang.reflect.InvocationTargetException" exception.

Now I am not able to figure out where compiler is finds my two different class! Is there any method available so that I can know the exact location (i.e Physical path) where it finds the two different path, So that I can remove the bad one.

Any help would be appreciated.

Thanking You,

Regards,

EDIT :

ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/myProj]] (http-127.0.0.1-8080-4) Exception while dispatching incoming RPC call: com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public com.proj.client.beans.domain.common.transaction.Document com.proj.server.actions.configuration.DocumentAction.saveDocument(com.proj.client.beans.domain.common.transaction.Document,java.lang.Long)' threw an unexpected exception: java.lang.reflect.InvocationTargetException
    at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:378) [:]
    at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:361) [:]
    at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:329) [:]
    at com.googlcode.strut2gwtplugin.interceptor.GWTServlet.processCall(GWTServlet.java:138) [:]
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224) [:]
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62) [:]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [:1.0.0.Final]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [:1.0.0.Final]
    at com.googlcode.strut2gwtplugin.interceptor.GWTInterceptor.intercept(GWTInterceptor.java:49) [:]
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) [:]
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) [:]
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) [:]
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) [:]
    at com.proj.server.LoginInterceptor.intercept(LoginInterceptor.java:37) [:]
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) [:]
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) [:]
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) [:]
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) [:]
    at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50) [:]
    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504) [:]
    at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:422) [:]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.0.0.Final]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:6.0.0.Final]
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0.Final]
    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]
    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.Final]
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.0.0.Final]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.Final]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.Final]
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.Final]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.Final]
    at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.Final]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.Final]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.Final]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.0.0.Final]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.Final]
    at java.lang.Thread.run(Thread.java:662) [:1.6.0_23]
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_23]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_23]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_23]
    at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_23]
    at com.googlcode.strut2gwtplugin.interceptor.GWTServlet.processCall(GWTServlet.java:127) [:]
    ... 36 more
Caused by: java.lang.NullPoint开发者_JAVA技巧erException
    at com.proj.server.actions.configuration.DocumentAction.saveDocument(DocumentAction.java:161) [:]
    ... 41 more


InvocationTargetException doesn't in any way automatically imply two different classes with the same name in two different packages (in fact, I've got a hard time imagining how that situation could lead to that exception).

An InvocationTargetException is simply the result when a method invoked through reflection throws an exception on its own.

Do you have access to the stack trace? It should print both the location of the reflection call (near the top) and the actual exception thrown by the invoked code (near the bottom).


Try to deploy the code on jboss-5.0.0.GA

Hope it helps


The last bit of the stack trace looks relevant here:

Caused by: java.lang.NullPointerException
at com.proj.server.actions.configuration.DocumentAction.saveDocument(DocumentAction.java:161)

The exception that you're describing usually manifests as an IncompatibleClassChangeError or even more strangely as Foo.class != Foo.classwhen multiple ClassLoaders are involved.


As @Joachim's answer says, InvocationTargetException is thrown when a method that is called using Method.invoke(...) throws a checked exception. The actual exception is wrapped in an InvocationTargetException which is then thrown.

In this particular case, the stacktrace tells us that original exception was a NullPointerException thrown at "DocumentAction.java:161". Track down and fix the cause of that exception.


I don't see any evidence that this has anything to do with different versions of some class. I'd treat it as a normal NPE to start with, and try to figure where the null is coming from.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜