13 Replies Latest reply on Nov 12, 2006 11:17 PM by philipwu

    IllegalArgumentException

      I'm getting the following error when changing persistence.xml in my development directory, before running ant to copy the containing JAR to my deploy directory.

      If I stop and restart the server, then it works just fine! So this must have something to do with hot deploy not liking me changing the persistence.xml file. (I'm changing the persistence.xml file before I deploy, not in the deploy dir itself).

      What's the problem here, and how do I fix it so that I don't have to keep restarting the server?

      Thanks.


      run.client:
       [java] Exception in thread "main" javax.ejb.EJBException: java.lang.IllegalArgumentException: Wrong target. class com.titan.travelagent.TravelAgentBean for public void com.titan.travelagent.TravelAgentBean.createCabin(com.titan.domain.Cabin)
       [java] at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
       [java] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
       [java] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:227)
       [java] at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
       [java] at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
       [java] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
       [java] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
       [java] at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
       [java] at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:398)
       [java] at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
       [java] Caused by: java.lang.IllegalArgumentException: Wrong target. class com.titan.travelagent.TravelAgentBean for public void com.titan.travelagent.TravelAgentBean.createCabin(com.titan.domain.Cabin)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.handleErrors(MethodInvocation.java:141)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:116)
       [java] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       [java] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
       [java] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:227)
       [java] at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
       [java] at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
       [java] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
       [java] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
       [java] at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
       [java] at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:398)
       [java] at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
       [java] at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:190)
       [java] at org.jboss.remoting.Client.invoke(Client.java:525)
       [java] at org.jboss.remoting.Client.invoke(Client.java:488)
       [java] at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:55)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:78)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       [java] at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
       [java] at $Proxy0.createCabin(Unknown Source)
       [java] at com.titan.clients.Client.main(Client.java:30)


        • 1. Re: IllegalArgumentException
          peterj

          This could be a timing issue with the hot deployer attempting to deploy things when not everything is updated/deployed yet. In that case, the best thing to do it to gather the necessary files in a temporary location on the same partition as JBoss, and then move the files to the deploy directory.

          • 2. Re: IllegalArgumentException

            If I manually delete the EJB JAR from the deploy directory, something weird happens. The TravelAgentBean/remote goes away when I refresh the list() operation of service=JNDIView, but TravelAgentBean itself does not!

            That seems like it might be causing the error above, which seems to want the new version of the TravelAgentBean but is somehow getting caught up with the old version that isn't being "released".

            Is there any way to force some kind of flush or refresh of JNDI to test if this is the case?

            What might be causing TravelAgentBean to remain when I delete the EJB JAR containing it? (Though TravelAgentBean/remote does go away.)

            • 3. Re: IllegalArgumentException
              peterj

              I don't think that is the cause of the problem. In your example, TravelAgentBean is a context, which is analogous to a directory on a file system. For example, when you delete /somedir/somefile.txt, the file goes away but the directory, somedir, remains. Not sure if the JNDI spec has anything to say about removing the context when the last name in that context is removed. Though you might think that the name of the EJB is TraveAgentBean/remote, it really isn't. It's name is "remote", within the context "TravelAgentBean".

              • 4. Re: IllegalArgumentException

                In general, how am I able to tell whether an entry is a context or an actual name? There must be a way...

                • 5. Re: IllegalArgumentException
                  peterj

                  There are a couple of ways.

                  First, if there is a multi-part name, only the last part could be an object name that references and object (it might be a context), the rest are all contexts.

                  Second, you could query JNDI and examine the object type returned.

                  Third, you could use jndiView to see the entire JNDI tree, and it tells you what everything is. (http://wiki.jboss.org/wiki/Wiki.jsp?page=DisplayTheJDNITreeWithTheJMXConsole)

                  • 6. Re: IllegalArgumentException

                    Looking at the JNDIView, I figure that if something has the following in brackets after the entry, then it is a context:

                    - javax.naming.Context
                    - org.jnp.interfaces.NamingContext

                    Then I saw that NamingContext extends Context. So my question is whether only things that are Context or subclasses are contexts (EVERYTHING ELSE is therefore a name)?

                    The next question I have is javax.naming.Context is an interface, but it's listed in the JNDIView as:

                    (class: javax.naming.Context)

                    Why for some entries is the class listed (org.jnp.interfaces.NamingContext) and for others the interface is listed (javax.naming.Context)? This inconsistency leads me to some confusion...

                    Thanks.

                    • 7. Re: IllegalArgumentException

                      Now the problem is occuring for changes to things other than the persistence.xml file. Now, changes to the classes results in the above error, which is solved by a restart of the server.

                      What is causing this?

                      What does "Wrong target" even mean?

                      Please help, I'll waste an unreal amount of time in server restarts rather than actually learning JBoss if I don't solve this!

                      • 8. Re: IllegalArgumentException

                        Some new information to help in the diagnosis of this problem:

                        I've discovered that the same problem occurs when a working JAR is deleted and re-deployed (using Ant) with the EXACT SAME JAR!

                        I noticed that prior to deleting the JAR, the deployed TravelAgentBean (the session bean for which the error message is complaining of "Wrong target") in the JNDIView shows the following:

                        | +- remote (proxy: $Proxy92 implements interface com.titan.travelagent.TravelAgentRemote,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)

                        After deleting and redeploying, the proxy value changes to a different number:

                        From $Proxy92 to $Proxy50, or any other two digits at the end. I suspect this is causing the problem. Please explain whether I am on the right track, and how I can solve this (if even possible).

                        Thank you. I really appreciate any moments you could spend helping me on this.

                        • 9. Re: IllegalArgumentException
                          boby

                          I have the same problem since I installed the last jboss version (4.0.5GA). When I deploy myapplication, the methods signature modification are not take account when the methods parameters are my objects.

                          I have this error : java.lang.IllegalArgumentException: Wrong target...

                          This problem may resolve when I stop/start the server.

                          Have you find the solution ??

                          Regards.
                          J. Bordeau

                          • 10. Re: IllegalArgumentException
                            boby

                            It is odd, because this problem occurs only when I call the method in remoting. In fact, I think there is a problem with the object in local and the object on the server. The server thinks that it is not the same objects.

                            Im gonna look at the serialVersion uid.

                            • 11. Re: IllegalArgumentException
                              heinrich

                              Hi,

                              i ran into the same problem. Is there already an JIRA entry for that?

                              • 12. Re: IllegalArgumentException
                                nerbrate

                                Hi,

                                I have the same problem with jboss 4.0.4.GA and EJB3.

                                When I redeploy my ejb, I get:
                                javax.ejb.EJBException: java.lang.IllegalArgumentException: Wrong target...
                                when invoking any method with instances of my own classes as parameters. A restart of the server fixes the problem.

                                I have an EJB3 with an EJB2.1 compatible remote homeinterface (using the @RemoteHome(MyBeanHome.class) annotation). I have tried several ways to access the ejb: Through an AXIS 1.4 webservice as front, a small javaclient and using JBossWS as front. The strange thing is that all attempts fail except invoking it through the JBossWS webservice. Even after a redeploy, when all fail using the javaclient and through axis, I can still invoke all methods through JBossWS.

                                After I restart the server, everything works perfectly.

                                My Bean:

                                @WebService(
                                 name="TestService",
                                 serviceName="TestServiceService",
                                 targetNamespace="http://test.myhome.org/testservice")
                                @SOAPBinding(
                                 style=Style.DOCUMENT,
                                 use=Use.LITERAL,
                                 parameterStyle=ParameterStyle.WRAPPED)
                                @Stateless(name="TestService")
                                @Remote
                                @RemoteHome(TestServiceHome.class)
                                @RemoteBinding(jndiBinding = "ejb/TestService")
                                public class TestServiceSessionBean implements TestService {
                                
                                 @WebMethod
                                 public MyResponse myMethod(MyParameters params) {
                                
                                 }
                                }
                                


                                I have tried different versions of EJB3 with no luck (RC7 & RC9).

                                Regards
                                Frode

                                • 13. Re: IllegalArgumentException
                                  philipwu

                                  have u guys solved this one? I'm having the same problem with 4.0.5GA

                                  Thanx