-
1. Re: We are attempting to expose our existing JavaEE SessionBeans as a REST interface and encountering some trouble. Most examples encourage us to put our EJBs into the REST .war but we want to retain the JavaEE functionalities and have them deployed as Se
jaikiran Sep 27, 2017 2:25 AM (in response to srinivasvittal)In its current form, it's very difficult to understand what you are asking. To make it easier, please paste the exact exception stacktrace that you are seeing and the snippet of the code where you are doing the lookup and invocation on the bean. Also which exact version of WildFly 11 is this?
-
2. Re: We are attempting to expose our existing JavaEE SessionBeans as a REST interface and encountering some trouble. Most examples encourage us to put our EJBs into the REST .war but we want to retain the JavaEE functionalities and have them deployed as Se
srinivasvittal Sep 28, 2017 9:38 AM (in response to jaikiran)This is WildFly 11.0.0. I need to know the exact way to expose the Beans as REST services. If I just mark the LocalInterface as @Local and try annotating the methods that this interface extends, pass in the path-param to look for the Local as mentioned above. I get a NameNotFoundException. I am pretty sure I am missing something very small. The code snippet looks exactly like the one I have given above. Please let me know if you need more info.
2017-09-27 16:58:54,635 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 165) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./rest: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./rest: java.lang.RuntimeException: java.lang.RuntimeException: javax.naming.NameNotFoundException: McsToteSessionBean/local -- service jboss.naming.context.java.McsToteSessionBean.local
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:84)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: javax.naming.NameNotFoundException: McsToteSessionBean/local -- service jboss.naming.context.java.McsToteSessionBean.local
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:241)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:99)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:81)
... 6 more
Caused by: java.lang.RuntimeException: javax.naming.NameNotFoundException: McsToteSessionBean/local -- service jboss.naming.context.java.McsToteSessionBean.local
at org.jboss.resteasy.plugins.server.resourcefactory.JndiResourceFactory.getScannableClass(JndiResourceFactory.java:62)
at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:172)
at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:160)
at org.jboss.resteasy.core.ResourceMethodRegistry.addJndiResource(ResourceMethodRegistry.java:127)
at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:428)
at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:258)
at org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap.contextInitialized(ResteasyBootstrap.java:28)
at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:205)
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:174)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:239)
... 8 more
Caused by: javax.naming.NameNotFoundException: McsToteSessionBean/local -- service jboss.naming.context.java.McsToteSessionBean.local
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:106)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:237)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at org.jboss.resteasy.plugins.server.resourcefactory.JndiResourceFactory.getScannableClass(JndiResourceFactory.java:57)
-
3. Re: We are attempting to expose our existing JavaEE SessionBeans as a REST interface and encountering some trouble. Most examples encourage us to put our EJBs into the REST .war but we want to retain the JavaEE functionalities and have them deployed as Se
walkerca Sep 28, 2017 1:06 PM (in response to srinivasvittal)Hi,
I separate the EJB from the RESTful service so that the EJB can be used in other contexts like scheduled jobs and in other EJBs. So, I'd break this apart so that you have the following classes
ExampleResource.java packed in example-rs.war
@Path("/example") class ExampleResource { @EJB private Example exampleEJB;
...Example.java packed in example-ejb.jar
interface Example {
...ExampleBean.java packaged in example-ejb.jar
@Stateless class ExampleBean implements Example {
...Put example-ejb.jar and example-rs.war in an example-ear.ear file with the modules defined in the application.xml
-
4. Re: We are attempting to expose our existing JavaEE SessionBeans as a REST interface and encountering some trouble. Most examples encourage us to put our EJBs into the REST .war but we want to retain the JavaEE functionalities and have them deployed as Se
srinivasvittal Sep 28, 2017 4:33 PM (in response to walkerca)I have mentioned this in my initial post that I took this approach and it works fine. But I want to integrate it without having extra classes as this would increase the code base and increases the maintenance burden of doing so. Please let me know if there is any way to do it. If there is none I would stick to this approach I already have. Thank you for the help.