I have developed an ear application using ejb3.1, jsf2.0 and cdi enabled.
I have packaged my application as ear with ejb modules defining the session beans, ejbremote jar defining the remote session interfaces and the jpa entities, and the war application which includes dependency on ejbremote jar (for the remote interface lookup, and the jpa entities).
Scenario:
If i inject directly session beans defined in the ejb jar in any cdi bean, jboss fails to find the righ proxy to inject, and throws a ClassCastException EjbManagerRemote field of my cdi bean cannot be cast to com.sun.proxy.$Proxy78
However, with glassfish, this scenario works perfectly.
To circumvent the jboss problem, i have developed a session bean inside the war (something like a producer: actually intend to do this) file where i inject the session beans and then inject this local session bean into the cdi beans which give me the reference to the session beans.
My question is, why does jboss fail to inject the remote session beans, yet glassfish has no problem?
What am i missing in ejb and cdi bean injection?
Note: am injecting the beans using #EJB annotation.
Thanks
Related
Recently we migrated our application from Jboss 6 to JBoss 7.4 version.
I have a XXXFilter which implements javax.servlet.Filter. XXXFilter uses #Inject annotation to inject some EJB stateless beans. But the problem is the beans are not getting injected into XXXFilter. It's working fine in jboss 6 and jdk8 but NOT working after we migrated to jboss7.4 and jdk11.
Any ideas?
You need to use the #EJB annotation.
We have an application in JBOSS. The application has a jar which has an abstract class and the class uses EJB. One of the classes is extending that abstract class. The application works fine in JBOSS and it is a SOAP service application.
I need to migrate that application in TC server. I am putting a REST layer using Spring and Jersey on top of that application. I am unable to instantiate the class which extends the abstract class in JBOSS application. I did some research but could not get a right answer and not sure if EJB is supported in TC server. The error I am getting is
javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/ejb/EJBObject
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:420)
Thanks for the help.
Tomcat (which Spring TC server essentially is) is a pure servlet container, it does not have EJB support.
While Developing a Java EE Web app, I would like to know simple ways to access an stateless EJB object through Rest.
This project needs no Dynamic Web from Java, as Client side is fully javascript deployed, so communication is done only with Ajax calls.
As I've read one way would be to create 2 EJB one for functionality other to represent Web Service.
Is there a way to avoid the Web Service part? (avoid completely the WAR) Maybe with DI?
Java EE 6, EJB 3.1, Eclipse desired. I also believe the right application server would be Glassfish instead of Jboss, due to it's compatibility with EJB 3.0
No interesting in using JAX-WS
With EJB 3.1 you can actually publish a session bean as a JAX-RS web service, if you package your (properly annotated) session bean inside a WAR.
So, the simplest solution I can think of would be to create a WAR (a dynamic web app if you're using Eclipse) and create a JAX-RS annotated stateless session bean inside the web app. You don't need any EJB projects at all.
Not really. In Java EE 6 you can directly publish a Session Bean as a JAX-WS web service, but not as a JAX-RS web service. You're pretty much stuck with creating a WAR that hosts that JAX-RS services that front the EJBs themselves.
I'm working with JBossAS7.
My application has some OSGI modules and big non-OSGI part.
I tried lookup osgi services in non-osgi subsystem through JNDI but they are not present in JNDI context.
I found similar problem at JBOSS 7 - Osgi Bundles not present in JNDI TREE but I dont found any solution there. If JBoss team didn't implement this functionality yet, how can I resolve this problem now?
I tried adding my service to JNDI context manually but got an exception because JNDI context is read only(according to https://issues.jboss.org/browse/AS7-421)
It's not fully integrated yet (monitor JBOSGI-81 to check the status), however I think you can make this work by taking the Apache Aries JNDI OSGi bundles and deploying them in JBoss AS7.
To do this, deploy and start
The Aries JNDI bundle
The Aries Proxy bundle
The Aries Util bundle
The JNDI bundle will complain that it can't set some statics with the NamingManager, but you can ignore that as AS7 JNDI takes care of that.
With the bundles above installed you should be able to do
osgi:service/org.foo.SomeInterface
and
osgi:servicelist
type lookups... E.g. you could try the following to look up the Start Level Service which is registered by the framework:
osgi:service/org.osgi.service.startlevel.StartLevel
I just tried it with AS7 7.1.2 and it works for me...
One thing to note, if the entity you're looking up implements an interface defined in another AS7/MSC module or OSGi bundle, you need to ensure that the consumer has visibility to it if you want to be able to cast to this interface. In the OSGi world you can just import the package, but in an AS7 module (e.g. a war file) you can achieve this by adding a Dependencies manifest header.
I am using JNDI lookups to inject a remote EJB3 session bean inside my spring 3 controller. Since my web module will run in tomcat and the business layer app in a remote Jboss 6, this configuration was decided. For the development I still use only jboss and my web and ear both are deployed in the same jobss instance (jboss 6). Everything works well for me, but when I tried to debug, all the beans injected returns null, so when in debug view, a null pointer exception is thrown when the remote ejb session bean is invoked. Everything works fine in the run mode (non-debug).
I am using eclipse(Helios) and trying remote debugging
I have the jndi.properties file in my jboss/deploy with these settings
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=localhost:1099
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
any help on this issue...
thanks...
Since remote debugging did not work for me, I used the jboss plugin for eclipse to make the debug process work.