8 Replies Latest reply on Oct 8, 2008 3:21 PM by jusyes

    Seam-Guice injection results in null pointer on POJO class that is not part of EJB or WAR

    jusyes

      using Sean guice combination inside jboss 430 works on class that is annotated as stateless EJB, but when EJB3 class calls helper class the Injection does not work.
      The other difference is the helper class is in another jar file which has empty seam.properties file so that seam can load it as component..


      Below is snippet of code where it fails with exception trace below.. any pointers why this would be...


      Thanks
      Justin



      @Name("externalClientImpl")
      @Guice("CCRTGuiceInjector")
      public class ExternalClientImpl implements ExternalClientInterface {
      
              @Inject @Named("gateway.UserId")
              private String userId;
      
              @Inject
              private GatewayAccessor gatewayAccessor;
      
              public Object processServiceRPC(Object obj, String serviceName, String bindingFileName, String expectedObjectName) throws Exception {
                      log.debug("is : " + userId);
                      log.debug("gatewayAccessor is : " + gatewayAccessor);
                      
                      Inputs inputs = gatewayAccessor.convertJavaObjToGatewayRPCFormat(obj, serviceName);





      2008-10-07 14:19:52,375 ERROR [com.ccrt.services.account.AccountServiceImpl] CCRTFatal retrieveAccountSummary Exception
      java.lang.NullPointerException
              at com.ccrt.external.ExternalClientImpl.processServiceRPC(ExternalClientImpl.java:62)
              at com.ccrt.services.account.AccountServiceImpl.retrieveAccountSummary(AccountServiceImpl.java:84)
              at com.ccrt.services.account.AccountServiceImpl.retrieveAccountSummary(AccountServiceImpl.java:72)
              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:585)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
              at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
              at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
              at org.jboss.labs.seam.guice.GuiceInterceptor.aroundInvoke(GuiceInterceptor.java:41)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:49)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
              at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
              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:585)
              at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
              at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
              at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:94)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
              at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:214)
              at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:184)
              at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:81)
              at $Proxy95.retrieveAccountSummary(Unknown Source)
              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:585)
              at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
              at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
              at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
              at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
              at org.javassist.tmp.java.lang.Object_$$_javassist_3.retrieveAccountSummary(Object_$$_javassist_3.java)
              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:585)
              at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:329)
              at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:274)
              at org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
              at org.jboss.el.parser.AstMethodSuffix.invoke(AstMethodSuffix.java:65)
              at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
              at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
              at org.jboss.seam.bpm.SeamExpressionEvaluator$1.evaluate(SeamExpressionEvaluator.java:97)
              at org.jboss.seam.bpm.SeamExpressionEvaluator.evaluate(SeamExpressionEvaluator.java:45)
              at org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator.evaluate(JbpmExpressionEvaluator.java:39)
              at org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator.evaluate(JbpmExpressionEvaluator.java:30)
              at org.jbpm.graph.def.Action.execute(Action.java:118)
              at org.jboss.seam.bpm.SeamUserCodeInterceptor.executeAction(SeamUserCodeInterceptor.java:70)
              at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:262)
              at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:220)
              at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:190)
              at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:174)
              at org.jbpm.graph.def.Transition.take(Transition.java:138)
              at org.jbpm.graph.def.Node.leave(Node.java:394)
              at org.jbpm.graph.exe.Token.signal(Token.java:195)
              at org.jbpm.graph.exe.Token.signal(Token.java:158)
              at org.jbpm.graph.exe.ProcessInstance.signal(ProcessInstance.java:283)
              at org.jboss.seam.pageflow.Pageflow.signal(Pageflow.java:485)
              at org.jboss.seam.pageflow.Pageflow.navigate(Pageflow.java:341)
              at org.jboss.seam.jsf.SeamNavigationHandler.handleNavigation(SeamNavigationHandler.java:40)
              at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:119)
              at javax.faces.component.UICommand.broadcast(UICommand.java:383)
              at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:184)
              at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:162)
              at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:350)
              at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
              at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
              at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
              at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
              at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
              at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
              at java.lang.Thread.run(Thread.java:595)
      "
      components.xml snippet
      
         <guice:injector name="CCRTGuiceInjector">
              <guice:modules>
                 <value>com.ccrt.guice.GuiceSetupModule</value>
              </guice:modules>
         </guice:injector>
      
      Below is snippet from class that is part of EJB and it works...
      @Stateless
      @Name("AccountService")
      @Guice("CCRTGuiceInjector")
      public class AccountServiceImpl implements AccountServiceInterface {
              private static Logger log = LoggerFactory.getLogger(AccountServiceImpl.class);
      
              @In FacesMessages facesMessages;
              
              @In(required=false,create=true,value="AccountBean")
              @Out(value="AccountBean",scope=ScopeType.SESSION)
          private Account account = new Account();
      
              @Inject @Named("gateway.UserId")
              private String userId;
              @Inject
              private GatewayAccessor gatewayAccessor;
              @Inject
              private GatewayAuthenticator gatewayAuthenticator;
      
                      
              public Account retrieveAccountSummary(){
                      log.debug("**********userId is : " + userId);
                      log.debug("**********gatewayAccessor is : " + gatewayAccessor);
                      log.debug("**********gatewayAuthenticator is : " + gatewayAuthenticator);
                      log.debug("**********gatewayAuthenticator.getToken is : " + gatewayAuthenticator.getToken());
      
      
      Thanks in advance


        • 1. Re: Seam-Guice injection results in null pointer on POJO class that is not part of EJB or WAR
          wrzep

          Hi Justin!


          Could you please be more specyfic? I can't tell which helper class you mean :)


          As far as I understand Guice injection doesn't work when you call a class that is in the another jar. Does it work in the same scenario when a class is in the same jar?


          Cheers,
          -Pawel

          • 2. Re: Seam-Guice injection results in null pointer on POJO class that is not part of EJB or WAR
            jusyes

            Hi pawel -


            Hope the below makes it easier, it is working across jar's from EJB class but not from POJO within same jar OR different jar.


            Scenario 1(works) : foo.java is stateless EJB ( part of xyzEJB.jar) this references injected class temperature.java from 123POJO.jar
            code snippet:


            @Stateless
            @Name("AccountService")
            @Guice("CCRTGuiceInjector")
            public class AccountServiceImpl implements AccountServiceInterface {
            
                    private static Logger log = LoggerFactory.getLogger(AccountServiceImpl.class);
            
                    @In FacesMessages facesMessages;
                    
                    @In(required=false,create=true,value="AccountBean")
                    @Out(value="AccountBean",scope=ScopeType.SESSION)
                private Account account = new Account();
            
                    @Inject @Named("gateway.UserId")
                    private String userId;
                    public Account retrieveAccountSummary(){
                            log.debug("**********userId is : " + userId);
            
            Output:
            2008-10-07 16:02:16,968 DEBUG [com.ccrt.services.account.AccountServiceImpl] **********userId is : jyesudasan
            2008-10-07 16:02:16,968 DEBUG [com.ccrt.services.account.AccountServiceImpl] **********gatewayAccessor is : com.ccrt.util.gateway.GatewayAccessorImpl@c4f67b
            2008-10-07 16:02:16,968 DEBUG [com.ccrt.services.account.AccountServiceImpl] **********gatewayAuthenticator is : com.ccrt.auth.GatewayAuthenticatorImpl@1124642
            



            Scenario 2( does not work): bar.java is POJO (part of xyzEJB.jar) this references injected class temperature.java from 123POJO.jar
            code snippet:


            @Guice("CCRTGuiceInjector")
            @Name("testGuiceClassLoaderIssue")
            public class TestGuiceClassLoaderIssue {
                    
                    private static Logger log = LoggerFactory.getLogger(TestGuiceClassLoaderIssue.class);
            
                    @Inject @Named("gateway.UserId")
                    private String userId;
                    @Inject
                    private GatewayAuthenticator gatewayAuthenticator;      
                    @Inject
                    private GatewayAccessor gatewayAccessor;        
                    
                    public void processServiceRPC(){
                            log.debug("++++++++userId is : " + userId);
                            log.debug("++++++++gatewayAccessor is : " + gatewayAccessor);
                            log.debug("++++++++gatewayAuthenticator is : " + gatewayAuthenticator);
            
            Output:
            2008-10-07 16:02:18,687 DEBUG [test.guice.TestGuiceClassLoaderIssue] ++++++++userId is : null
            2008-10-07 16:02:18,687 DEBUG [test.guice.TestGuiceClassLoaderIssue] ++++++++gatewayAccessor is : null
            2008-10-07 16:02:18,687 DEBUG [test.guice.TestGuiceClassLoaderIssue] ++++++++gatewayAuthenticator is : null
            



            Scenario 3( does not work): foo.java is stateless EJB ( part of xyzEJB.jar), invokes fooHelper.java (part of 123POJO.jar) this references injected class temperature.java from 123POJO.jar


            snippet and output same as Scenario 2

            • 3. Re: Seam-Guice injection results in null pointer on POJO class that is not part of EJB or WAR
              jusyes

              just realized in earlier reply for scenario1 i did not copy couple of lines it is same as scenario 2.. just fyi below here if needed



              @Stateless
              @Name("AccountService")
              @Guice("CCRTGuiceInjector")
              public class AccountServiceImpl implements AccountServiceInterface {
              
                      private static Logger log = LoggerFactory.getLogger(AccountServiceImpl.class);
              
                      @In FacesMessages facesMessages;
                      
                      @In(required=false,create=true,value="AccountBean")
                      @Out(value="AccountBean",scope=ScopeType.SESSION)
                  private Account account = new Account();
              
                      @Inject @Named("gateway.UserId")
                      private String userId;
                      @Inject
                      private GatewayAccessor gatewayAccessor;
                      @Inject
                      private GatewayAuthenticator gatewayAuthenticator;
              
                      public Account retrieveAccountSummary(){
                              log.debug("**********userId is : " + userId);
                              log.debug("**********gatewayAccessor is : " + gatewayAccessor);
                              log.debug("**********gatewayAuthenticator is : " + gatewayAuthenticator);
              
              Output:
              2008-10-07 16:02:16,968 DEBUG [com.ccrt.services.account.AccountServiceImpl] **********userId is : jyesudasan
              2008-10-07 16:02:16,968 DEBUG [com.ccrt.services.account.AccountServiceImpl] **********gatewayAccessor is : com.ccrt.util.gateway.GatewayAccessorImpl@c4f67b
              2008-10-07 16:02:16,968 DEBUG [com.ccrt.services.account.AccountServiceImpl] **********gatewayAuthenticator is : com.ccrt.auth.GatewayAuthenticatorImpl@1124642


              • 4. Re: Seam-Guice injection results in null pointer on POJO class that is not part of EJB or WAR
                wrzep

                Could you please show a code you use to call testGuiceClassLoaderIssue.processServiceRPC() (scenario 2)?


                Does @In (not @Inject) works fine there?


                -Pawel

                • 5. Re: Seam-Guice injection results in null pointer on POJO class that is not part of EJB or WAR
                  jusyes

                  sure... The only reason i have it in EJB class was test to see if there was something different in injection.
                  ideally all this injection stuff is for utility/helper classes to deal with weather to execute Webservice or RMI, what Authenitcation mechanism to use and read property files for development and production. But it seemed to be bizzare it works from EJB and not POJO


                  TestGuiceClassLoaderIssue testGuiceClassLoaderIssue = new TestGuiceClassLoaderIssue();
                  testGuiceClassLoaderIssue.processServiceRPC();
                  



                  GuiceSetupModule.java ( this is configured in components.xml)


                  package com.ccrt.guice;
                  
                  import java.net.URL;
                  import java.util.Properties;
                  
                  import com.ccrt.auth.GatewayAuthenticator;
                  import com.ccrt.auth.GatewayAuthenticatorImpl;
                  import com.ccrt.util.gateway.GatewayAccessor;
                  import com.ccrt.util.gateway.GatewayAccessorImpl;
                  import com.google.inject.AbstractModule;
                  import com.google.inject.Scopes;
                  import com.google.inject.name.Names;
                  public class GuiceSetupModule extends AbstractModule {
                          @Override
                          protected void configure() {
                                  System.out.println("GuiceSetupModule configure INVOKED");
                  
                                  bind(GatewayAccessor.class)             
                                  .to(GatewayAccessorImpl.class)
                                  .in(Scopes.SINGLETON);                                          
                                  bind(GatewayAuthenticator.class)                
                                  .to(GatewayAuthenticatorImpl.class)
                                  .in(Scopes.SINGLETON);          
                                  Properties properties = loadProperties();               
                                  Names.bindProperties(binder(), properties);
                            }                     
                  
                          
                  }






                  • 6. Re: Seam-Guice injection results in null pointer on POJO class that is not part of EJB or WAR
                    wrzep

                    Jus Yes wrote on Oct 07, 2008 23:07:


                    TestGuiceClassLoaderIssue testGuiceClassLoaderIssue = new TestGuiceClassLoaderIssue();
                    testGuiceClassLoaderIssue.processServiceRPC();
                    



                    Well, you call testGuiceClassLoaderIssue as a normal class, not as a Seam component. Seam can't proxy a request, so obviously annotations and interceptors don't work. @In would't work as well :)


                    You have to obtain a reference to the testGuiceClassLoaderIssue component either @Injecting it or by lookup calling TestGuiceClassLoaderIssue testGuiceClassLoaderIssue = (TestGuiceClassLoaderIssue) Component.getInstance("testGuiceClassLoaderIssue").


                    This has nothing to do with differences between POJO and EJB3. I guess you called EJB3 component correctly and that is why it worked.


                    Let me know if this solves your issue :)


                    -Pawel

                    • 7. Re: Seam-Guice injection results in null pointer on POJO class that is not part of EJB or WAR
                      jusyes

                      Thanks, makes sense .. missed that in terms of trying to write quick test within jar file.
                      I changed the TestGuiceClassLoaderIssue to use Guice injection and it works, hence the scenario that does not work now is Scenario3.
                      Scenario3 is using Guice injection but the classes are in different jar, which coincides with your earlier comment that Guice Injection does not work on class in different jar, can you point me to where you came across this. trying to understand rationale and then might post on Guice forum to see if its resolved in 2.0 or any plans for that..


                      Thanks for your help Pawel...

                      • 8. Re: Seam-Guice injection results in null pointer on POJO class that is not part of EJB or WAR
                        jusyes

                        scenario 3 works as well across different jar, had new inside one of the methods.. did not realize i had not refactored that piece to use Guice Injection...


                        Thanks for all help... Have one more question for you had also posted in Guice Forum, what is best approach to bootstrap guice to make it available in EJB tier outside of seam invocation...