OrientDB JCA Resource Injection
shelltux Nov 25, 2014 3:12 PMHi everybody,
because it is my first post here I will give a short introduction to myself :-)
My name is Markus and I am truly new to J2EE programming and WildFly. I got some experience with plain and good old java as well as with Spring.
I'm trying to get a working OrientDB-JCA-Connector, downloaded from: Orient - OPS4J Orient - OPS4J Wiki
I deployed the adapter as stated in the "Installation on WildFly" chapter.
What I am trying is that a simple Primefaces-JSF with a backing bean has en EJB injected and that EJB has a @Resource-lookup for the OrientDB-JCA.
My backing bean looks like this
@ManagedBean @RequestScoped public class TestBean { protected Logger log = Logger.getLogger(this.getClass()); @EJB private TestEJB ejb; /** * */ public TestBean() { log.info("TestBean constructed"); } public String getSomeString() { return(ejb.getSomeString()); } }
The TestEJB looks like:
@Named @Stateless public class TestEJB { protected Logger log = Logger.getLogger(this.getClass()); @Resource(lookup = "java:/orient/ConnectionFactory") private OrientDatabaseConnection omc; private String someString = null; public TestEJB() { log.info("TestEJB constructed"); this.someString = "Ein Test"; } public String getSomeString() { return(this.someString); } }
The simple injection of the EJB into the backing bean works as desired (if I comment that @Resource-Part everything works fine).
While the Wildfly 8.x server is starting I can the following message
20:52:32,859 INFO [org.jboss.as.connector.deployment] (MSC service thread 1-9) JBAS010401: Bound JCA ConnectionFactory [java:/orient/ConnectionFactory]
For me it looks like that the ConnectionFactory is known be the container.
If I then open the JSF the following stacktrace occurs:
Caused by: java.lang.IllegalArgumentException: Can not set org.ops4j.orient.adapter.api.OrientDatabaseConnection field de.verleihmalwas.ejb.orientdb.TestEJB.omc to org.ops4j.orient.adapter.impl.OrientDatabaseConnectionFactoryImpl at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164) [rt.jar:1.7.0_72] at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168) [rt.jar:1.7.0_72] at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) [rt.jar:1.7.0_72] at java.lang.reflect.Field.set(Field.java:741) [rt.jar:1.7.0_72] at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:108) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:28) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) at org.jboss.as.weld.injection.WeldInterceptorInjectionInterceptor.processInvocation(WeldInterceptorInjectionInterceptor.java:56) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final] at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) at org.jboss.as.weld.ejb.Jsr299BindingsCreateInterceptor.processInvocation(Jsr299BindingsCreateInterceptor.java:93) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final] at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:273) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final] ... 118 more
Does anyone have an idea that I am doing wrong?
Thanks and regards
Markus