Cannot access local stateless EJB interface from WAR (REST)
erik777 Aug 15, 2016 12:01 AMI've been trying for 4 hours to get injection or even an old fashioned initial context lookup to work. This is simple. I have a stateless session bean, and a WAR with rest services that needs to access it. The documentation on Wildfly is horrible, and I cannot find a single tutorial anywhere for this insanely simple use case.
From the war, I've tried all of these (commented) and more:
// java:global/jvestApp/jvestEJB/ejb/StringStore!net.openstandards.jvest.ejb.StringStoreLocal
// java:app/jvestEJB/ejb/StringStore!net.openstandards.jvest.ejb.StringStoreLocal
// java:module/ejb/StringStore!net.openstandards.jvest.ejb.StringStoreLocal
// java:global/jvestApp/jvestEJB/ejb/StringStore!net.openstandards.jvest.ejb.StringStoreRemote
// java:app/jvestEJB/ejb/StringStore!net.openstandards.jvest.ejb.StringStoreRemote
// java:module/ejb/StringStore!net.openstandards.jvest.ejb.StringStoreRemote
// java:jboss/exported/jvestApp/jvestEJB/ejb/StringStore!net.openstandards.jvest.ejb.StringStoreRemote
@EJB(lookup="java:global/jvestApp/jvestEJB/ejb/StringStore!net.openstandards.jvest.ejb.StringStoreLocal")
// @EJB(lookup="java:app/jvestEJB/ejb/StringStore!net.openstandards.jvest.ejb.StringStoreLocal")
// @EJB(lookup="ejb:jvestApp/jvestEJB/ejb/StringStore/StringStoreBean!net.openstandards.jvest.ejb.StringStoreLocal")
// @Inject
// @EJB(name="ejb/StringStore", mappedName="ejb/StringStore")
// @EJB(name="java:app/jvestEJB/ejb/StringStore!net.openstandards.jvest.ejb.StringStoreLocal")
// @EJB(name="ejb/StringStore")
// @EJB(lookup="java:comp/env/ejb/StringStore")
// @EJB
StringStoreLocal stringStore;
I've tried both local and remote. I either get a NULL, or get a deployment exception such as:
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type StringStoreLocal with qualifiers @Default
at injection point [UnbackedAnnotatedField] @Inject net.openstandards.jvest.rest.ServiceRest.stringStore
or
Caused by: org.jboss.weld.exceptions.DefinitionException: WELD-001517: The type of the resource producer field [[UnbackedAnnotatedField] @EJB net.openstandards.jvest.rest.ServiceRest.stringStore] does not match the resource type net.openstandards.jvest.ejb.StringStoreBean
or, when I either include a lookup or do an initial context lookup:
23:20:06,820 INFO [stdout] (AsyncAppender-ASYNC) java.lang.ClassCastException: net.openstandards.jvest.ejb.StringStoreLocal$$$view1 cannot be cast to net.openstandards.jvest.ejb.StringStoreLocal
Bean currently looks like:
@Stateless(name="ejb/StringStore", mappedName="ejb/StringStore" )
//@LocalBean
public class StringStoreBean implements StringStoreLocal, StringStoreRemote {
and local interface:
@Local
public interface StringStoreLocal {
If someone could just create a simple Wildfly 10 Hello world with a web REST using injection to access EJB stateless, that would be really nice.
Ironically, I've been using JBoss since version 2.2/2.4 in 2001 (OpenStandards.net was deployed using it in 2002), back when Marc Fluery was on the message boards a lot and, I believe, in college still. I've been doing web/EJB development since, primarily in WebSphere, doing TONS of REST/EJB development. I have never had a problem with InitialContext and used injection with JPA in WAS. I've done remoting to JBoss EJB's from both Swing clients and other J2EE platforms (WebSphere). I'm new to Wildfly, as I haven't developed for JBoss since probably 5. I
The Wildfly documentation does not give a single good example of the basic use case of a WAR and EJB module in a single EAR. Four hours of trial and error with no success is just insane.
Googling returns everything BUT this simple use case for Wildfly 10.