Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-191

provide informative exception when attempt is made to invoke EJB from test in standalone mode

XMLWordPrintable

    • Medium

      My understanding is that I cannot invoke a method on an EJB session bean unless I am using incontainer mode (@IntegrationTest). Otherwise I get the following exception, assuming a method signature of HotelSearch#isPreviousPageAvailable().

      java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.jboss.webbeans.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:97)
      at org.jboss.seam.examples.booking.action.HotelSearch_$$javassist_1.isPreviousPageAvailable(HotelSearch$$_javassist_1.java)
      at org.jboss.seam.examples.booking.action.FooTest.testCallMethodOnSessionBean(FooTest.java:20)
      Caused by: java.lang.NullPointerException
      at org.jboss.webbeans.util.Reflections.lookupMethod(Reflections.java:514)
      at org.jboss.webbeans.util.Reflections.lookupMethod(Reflections.java:496)
      at org.jboss.webbeans.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:136)
      at org.jboss.seam.examples.booking.action.HotelSearch_$$javassist_0.isPreviousPageAvailable(HotelSearch$$_javassist_0.java)
      ... 43 more

      It might helpful to turn this NullPointerException into an IllegalStateException to make it clear that it's not possible to do such a call in standalone mode.

              pmuiratbleepbleep Pete Muir (Inactive)
              dan.j.allen Dan Allen (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: