3 Replies Latest reply on Dec 14, 2006 11:19 PM by Gavin King

    Injecting EJB3 into a POJO

    Jarkko Lietolahti Novice

      Hello,
      I don't quite recall this stuff correctly but is it possible to inject (either @In or @EJB) SFSB into a plain java class? Or is there just something wrong with the syntax?


      @Name("dragDropBean")
      @Scope(value = ScopeType.SESSION)
      public class DragDropBean implements Renderable {
      
       @In
       KohdeEditorBean kohdeEditor;
      
       // or
       @EJB
       KohdeEditorBean kohdeEditor;
      
      }
      
      @Name("kohdeEditor")
      @Stateful
      @Scope(value = ScopeType.SESSION)
      public class KohdeEditorBean extends StatefullBaseAction implements KohdeEditor {
      
      }
      




        • 1. Re: Injecting EJB3 into a POJO
          Jarkko Lietolahti Novice

          @In cause the stuff below:


          Caused by: java.lang.IllegalArgumentException: Could not set field value by reflection: DragDropBean.kohdeEditor on: fi.jab.jsf.icefaces.DragDropBean with value: class org.jboss.seam.intercept.Proxy$$EnhancerByCGLIB$$36c63494
          at org.jboss.seam.util.Reflections.set(Reflections.java:75)
          at org.jboss.seam.Component.setFieldValue(Component.java:1547)
          ... 105 more
          Caused by: java.lang.IllegalArgumentException: Can not set fi.tc.business.KohdeEditorBean field fi.jab.jsf.icefaces.DragDropBean.kohdeEditor to org.jboss.seam.intercept.Proxy$$EnhancerByCGLIB$$36c63494
          at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
          at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
          at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
          at java.lang.reflect.Field.set(Field.java:657)
          at org.jboss.seam.util.Reflections.set(Reflections.java:61)
          ... 106 more



          • 2. Re: Injecting EJB3 into a POJO
            Jarkko Lietolahti Novice

            Meant to say @In(create=true) causes that stuff.

            • 3. Re: Injecting EJB3 into a POJO
              Gavin King Master

              Definitely it is not possible using @EJB. It is possible using @In, but you must use the local interface type, not the bean class.