10 Replies Latest reply on Nov 24, 2016 9:32 AM by Sreenath Reddy

    Error while invoking Stateless EJB from Plain Java code on WildFly 8.2.0

    Sreenath Reddy Novice

      Hi All,

       

      I am working on invoking EJB from plain java from past few days, I came across with defferent exceptions, I tried the maximum ways available in forums, the below is my code snippet.

       

      final Properties properties = new Properties();

      properties.put("endpoint.name", "client-endpoint");

      properties

      .put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED",

      "false");

      properties

      .put("remote.connection.x1.connect.options.org.xnio.Options.SSL_STARTTLS",

      "true");

      properties.put("remote.connections", "default");

      properties.put("remote.connection.default.host", "127.0.0.1");

      properties.put("remote.connection.default.port", "8080");

      properties

      .put("remote.connection.default.connect.options.org.xnio.Option.SASL_POLICY_NOANONYMOUS",

      "false");

      properties.put("remote.connection.default.username", "ejb");

      properties.put("remote.connection.default.password", "ejb");

      context = new InitialContext(properties);

      name = "ejb:project-ear/project-ejb//AppDataProviderBean!com.project.action.AppDataProvider";

      final AppDataProvider bean = (AppDataProvider) context

      .lookup(name);

      bean.loadAllList();


      The above logic will call while starting the server, I am getting the below exception when calling bean.loadAllList();


      20:54:28,616 INFO  [org.jboss.ejb.client] (MSC service thread 1-2) JBoss EJB Client version 2.0.1.Final

      20:54:32,248 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./project: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./project: Failed to start service

        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_11]

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_11]

        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_11]

      Caused by: java.lang.RuntimeException: org.jboss.seam.InstantiationException: Could not instantiate Seam component: ApplicationScopeData

        at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:222)

        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:87)

        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)

        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]

        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]

        ... 3 more

      Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: ApplicationScopeData

        at org.jboss.seam.Component.newInstance(Component.java:2208)

        at org.jboss.seam.contexts.Contexts.startup(Contexts.java:343)

        at org.jboss.seam.contexts.Contexts.startup(Contexts.java:317)

        at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:143)

        at org.jboss.seam.init.Initialization.init(Initialization.java:813)

        at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:36)

        at com.project.session.SessionListener.contextInitialized(SessionListener.java:58)

        at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173)

        at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:193)

        ... 7 more

      Caused by: java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:project-ear, moduleName:project-ejb, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@1364a0d7

        at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:749)

        at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:116)

        at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:186)

        at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:253)

        at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:198)

        at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:181)

        at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:144)

        at com.sun.proxy.$Proxy236.loadLanguageAllList(Unknown Source)

        at com.project.session.LocalEJBLookup.lookup(LocalEJBLookup.java:169)

        at com.project.session.LocalEJBLookup.lookup(LocalEJBLookup.java:73)

        at com.project.session.LocalEJBLookup.getAppDropdownProvider(LocalEJBLookup.java:340)

        at com.project.action.ApplicationScopeData.loadInitialEntities(ApplicationScopeData.java:50)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_11]

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_11]

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_11]

        at java.lang.reflect.Method.invoke(Method.java:483) [rt.jar:1.8.0_11]

        at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)

        at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)

        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)

        at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)

        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

        at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)

        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

        at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)

        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.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:196)

        at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:114)

        at com.project.action.ApplicationScopeData$$_javassist_seam_2.loadInitialEntities(ApplicationScopeData$$_javassist_seam_2.java)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_11]

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_11]

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_11]

        at java.lang.reflect.Method.invoke(Method.java:483) [rt.jar:1.8.0_11]

        at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)

        at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)

        at org.jboss.seam.Component.callComponentMethod(Component.java:2313)

        at org.jboss.seam.Component.callCreateMethod(Component.java:2236)

        at org.jboss.seam.Component.newInstance(Component.java:2196)

        ... 15 more

       

      Please let me know if I am missing anything, I tried maximum possible cases. Is there any extra configuration I need to do?

        • 1. Re: Error while invoking Stateless EJB from Plain Java code on WildFly 8.2.0
          Tomaz Cerar Master

          what exactly are you trying to do?

          access EJB that from same deployment?

           

          or you have EJBs on remote server?

          • 2. Re: Error while invoking Stateless EJB from Plain Java code on WildFly 8.2.0
            Sreenath Reddy Novice

            Hi Tomaz,

             

            I am accessing the EJB from same deployment

            • 3. Re: Error while invoking Stateless EJB from Plain Java code on WildFly 8.2.0
              Tomaz Cerar Master

              then you don't need any remote lookup.

               

              just do JNDI lookup

               

              InitialContext ic = new InitialContext()

              MyEJB ejb = (MyEJB)ic.lookup("name-under-which-ejb-is-bound");

               

              ...

              ..

              ic.close();

               

              and that is about it. the lookup name is what you see in log when deploying app, you get all the names under which ejb is bound to jndi.

              • 4. Re: Error while invoking Stateless EJB from Plain Java code on WildFly 8.2.0
                Sreenath Reddy Novice

                I saw the below lines while starting the server and tried all the below

                 

                java:global/project-ear/project-ejb/AppDataProviderBean!com.project.AppDataProvider
                java:app/project-ejb/AppDataProviderBean!com.project.AppDataProvider
                java:module/AppDataProviderBean!com.project.AppDataProvider
                java:jboss/exported/project-ear/project-ejb/AppDataProviderBean!com.project.AppDataProvider
                java:global/project-ear/project-ejb/AppDataProviderBean
                java:app/project-ejb/AppDataProviderBean
                java:module/AppDataProviderBean

                 

                Still I am facing the issue.

                 

                 

                 

                @Name("ApplicationScopeData")

                @Scope(APPLICATION)

                @Startup

                public class ApplicationScopeData {

                  private static final Logger logger = Logger

                  .getLogger(ApplicationScopeData.class);

                  @In(create = true, required = false, value = "AppProviderBean")

                  @Autowired

                  private AppProvider provider;

                 

                 

                  @Create

                  public void loadInitialEntities() {

                 

                  provider.loadAllList();

                 

                }

                 

                 

                 

                 

                @Stateless

                @JndiName(value = "java:app/project-ejb/AppProviderBean")

                @Name("AppDataProviderBean")

                public class AppDataProviderBean implements AppDataProvider {

                  public static Logger logger = Logger

                  .getLogger(AppDataProviderBean.class);

                 

                 

                  @PersistenceContext(unitName = "project")

                  private EntityManager entityManager;

                 

                  @SuppressWarnings("unchecked")

                  public List<UserDetail> loadAllList() {

                  final String query = "select o from UserDetail o order by o.userName";

                  final List<UserDetail> results = entityManager.createQuery(query)

                  .getResultList();

                  return results;

                  }

                }

                 

                getting the same exception...

                • 5. Re: Error while invoking Stateless EJB from Plain Java code on WildFly 8.2.0
                  Sreenath Reddy Novice

                  I am using jdk1.8.0_11, will it be a problem. As per my knowledge WildFly8.2.0 supports jdk1.8.0.11

                  • 6. Re: Error while invoking Stateless EJB from Plain Java code on WildFly 8.2.0
                    Sreenath Reddy Novice

                    In all the cases I am getting the above exception, I observed that before this exception, I have seen the below warning.

                     

                    00:51:40,456 WARN  [org.jboss.seam.security.permission.PersistentPermissionResolver] (MSC service thread 1-2) no permission store available - please install a PermissionStore with the name 'org.jboss.seam.security.jpaPermissionStore' if persistent permissions are required.

                     

                    Is there any problem with the above warning.

                    • 7. Re: Error while invoking Stateless EJB from Plain Java code on WildFly 8.2.0
                      Wolfgang Mayer Master

                      The 'No EJB receiver available for handling' message indicates that you did not set the 'jboss.naming.client.ejb.context'

                       

                      Did you check the example in the documentation? EJB invocations from a remote client using JNDI - WildFly 8 - Project Documentation Editor

                      But this little program is also working fin in my environment:

                       

                      public class TestRemoteClient {

                          public static void main(String[] args) {

                              if (args.length < 2)

                              {

                                  System.err.println ("2 integer values expected");

                                  System.exit(99);

                               }

                              int val1 = parseInt(args [0]);

                              int val2 = parseInt(args [1]);

                             

                              Properties props = new Properties();

                       

                              final String bean = "TestRemoteJNDI/TestRemoteJNDI-ejb/CalculateBean!ejb.CalculateBeanRemote";

                       

                              CalculateBeanRemote cal;

                              System.out.println("Testing with: " + bean);

                              final String password = "appuser123";

                             

                              props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

                              props.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");

                              props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

                              props.put(Context.SECURITY_PRINCIPAL, "guest");

                              props.put(Context.SECURITY_CREDENTIALS, "guest");

                       

                              // to avoid: java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available

                              props.put("jboss.naming.client.ejb.context", true);

                              try {

                                  final Context context = new InitialContext(props);

                                  cal = (CalculateBeanRemote) context

                                          .lookup(bean);

                                  System.out.println("Lookup complete");

                       

                                  System.out.println(val1 + " + " + val2 + " = " + cal.add(val1, val2));

                                  // context.close();   // throws: java.util.concurrent.RejectedExecutionException

                              } catch (NamingException e) {

                                  e.printStackTrace();

                              }

                          }

                      }

                      • 8. Re: Error while invoking Stateless EJB from Plain Java code on WildFly 8.2.0
                        Sreenath Reddy Novice

                        Hi Wolfgang,

                         

                        As per Tomaz in the earlier comment, if we are accessing from same deployment the details is not required, directly we can get by using

                        InitialContext ic=new InitialContext();

                        ic.lookUp("JNDI NAme")

                        I verified the same using the small project and I am able to lookup the issue, but when we come to my project it is not working.

                         

                        I am migrating my application from As 5.1.0 to WildFly 8.2.0, Is there any other configuration changes required for wildFly 8.2.0???

                        • 9. Re: Error while invoking Stateless EJB from Plain Java code on WildFly 8.2.0
                          Wolfgang Mayer Master

                          The 'no permission store available' message refers to Seam. Please refer to the Seam documentation (Seam - Contextual Components) for details on implementing the PersistentPermissionResolver.

                          • 10. Re: Error while invoking Stateless EJB from Plain Java code on WildFly 8.2.0
                            Sreenath Reddy Novice

                            The issue is because of the incompatible hibernate version. The issue occurs if we use hibernate version less than 4.x. After upgrading to 4.2.0 the application is running smoothly.