3 Replies Latest reply on Nov 10, 2009 6:56 AM by wolfgangknauf

    java.lang.reflect.UndeclaredThrowableException

    pi4630

      Hi all,

      I'm beginning ejb3.0.

      I have the following stuff inside a JAR, I deploy on my JBoss 4.0.4-GA:
      FooBarBean.java - a stateless session bean
      FooBarException.java - an extension of Exception
      FooBarRemote.java - the remote interface

      A method in FooBarRemote throws FooBarException.
      FooBarBean implements FooBarRemote (and thus throws the FooBarException).

      I have a FooBarClient.java that connects to JBoss via jnp and looks up JNDI to get the right bean and uses its method.

      I start the JBoss server, create a Remote debug config inside eclipse where I enter the project folder, connection type is standard (socket attach), host is localhost and port is 8000 (I have configured eclipse to bypass proxy for localhost). I launch the remote debug and it is fine.
      When I run the client, I am able to debug up to the point where I pass FooBarBean an invalid parameter, for which I except to see the FooBarException printed on the console.
      Some thing like
      input is i=-1

      if ( i<0){
      throw new FooBarException("Here some msg").
      

      But I get the above java.lang.reflect.UndeclaredThrowableException on a proxy0 back caused by java.lang.ClassNotFoundException.

      I've double checked: the client invokes the correct bean and the method call is made between try catch, catching FooBarException (the client would syserrprint the FooBarException to the console). If the input is valid, everything is fine.
      I'm not sure how I should interpret this error: Does it mean that JBoss is unaware of the FooBarException class in runtime? It looks like the reference can't be matched back to the client.

      Any hints?
      Thanks in advance,
      ~pasquale

        • 1. Re: java.lang.reflect.UndeclaredThrowableException
          wolfgangknauf

          Hi,

          is the "FooBarException" class available for the client? Which classes does the client jar contain?

          Best regards

          Wolfgang

          • 2. Re: java.lang.reflect.UndeclaredThrowableException
            pi4630

            The client is not in a JAR, I'm launching it from a project inside eclipse. The FooBarException on the client is resolved by using import statement (from another package, i.e. the server package that gets jarred and deployed, which is located in the same project).

            I'm studying the book "Enterprise JavaBeans 3.0 mit Eclipse und JBoss" by Uwe Rozanski, published by MITP; there he uses a JDK ver. 5, JBoss-4.0.4 GA on Windows xp.
            I use Java 6 SDK, JBoss 4.0.4-GA on ubuntu. I have recreated the environment as published in the book using SUN's virtualbox and my demo works there, so it seems the problem may be connected to different versions I'm using.
            Still, I'd like to know what is causing this bug...

            thanks!

            • 3. Re: java.lang.reflect.UndeclaredThrowableException
              wolfgangknauf

              Hi,

              is the class for "FooBarException" in the same version present in client and server, and also compiled with the same java version? Do you se the same JBoss version for server and client?

              I would advice not to combine JBoss 4.0.4 and Java 1.6. Better use a 5.1 JBoss and 1.6, or use 4.0.4 and Java 1.5. Java 1.6 support might not be working for this old JBoss version.

              Best regards

              Wolfgang