EJB stateless beans are not injected properly after migration to JBOSS 7.4 and Java11 - jboss

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.

Related

Spring 4 + hibernate & jpa 2.1 on weblogic 10.3.5

Will I be able to run Hibernate with JPA 2.1 on weblogic 10.3.5.
I have specified the below lines in weblogic-application.xml and packaged the jpa 2.1 API jar in the EAR along with other jars.
<wls:prefer-application-packages>
<wls:package-name>javax.persistence</wls:package-name>
</wls:prefer-application-packages>
Some how weblogic recognizes META-INF/persistence.xml and tries to automatically create persistence unit using Eclipse Link during application deployment/startup. This is where the weblogic classloader (parent of application class loader) is trying to load the persistence unit but failing with below exception.
java.lang.IllegalArgumentException: interface javax.persistence.EntityManagerFactory is not visible from class loader
Any help with this is very much appreciated.
Have you enabled JPA 2.1 on your Weblogic Instalation ?
If you refer to :
https://docs.oracle.com/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309
and
https://docs.oracle.com/middleware/1213/wls/EJBAD/using_toplink.htm#EJBAD1309
you will note that:
"Support for JPA 2.1 in WebLogic Server is provided as a patch because JPA 2.1 is part of the Java Platform, Enterprise Edition (Java EE) 7. Therefore, enabling JPA 2.1 support in the current release results in WebLogic Server not meeting all Java EE 6 compatibility requirements. To maintain Java EE 6 compatibility, the files required for JPA 2.1 support are not enabled by default, although they are included in a standard WebLogic Server installation."
Have a look #
How to Enable Java Persistence 2.0 for Weblogic 10.3.6
and
https://docs.oracle.com/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309

Deploying war file in Payara 4 with Ejb components dependencies

Can we deploy a war file in Payara 4 having #Ejb annotated components in it?
Yes, you can.
Any annotations that are part of any Java EE 7 specification are processed by Payara and should work.

Does Jboss 7.1 AS supports ejb 2.1?

it seems jboss AS 7.1 supports ejb 2.1.Our ejb 2.1 based application is deployed on jboss 5 AS. We are migrating it to jboss7.1. but i want to know what are the additional configurations required to run ejb 2.1 without any errors?
EJB2 is still supported in AS7.x, the issue might be that AS7 is a new implementation and some of the tuning options and configuations are not available for AS7 - especially the EntityBean CMP.
There are some added for EAP6 (based on AS7) you might download the unsupported version.
Wildfly (the successor of JBossAS) will not continue to support EJB2 EntityBeans because EJB3.2 declare it as optional.
Note EJB2 session beans are still supported but I recommend to upgrade it to EJB3 this should faily simple.
You might keep the EJB2 interfaces to provide an interface for EJB2 clients, but I expect effort for the client as well as the lookup Strings changed.
If the appliation should be kept for the future I would recommend to migrate to EJB3

Upgrading GlassFish 3.1.2.2 to use JPA 2.1

I am working with GlassFish 3.1.2.2 (I can not upgrade to 4 due to OS restrictions).
I'm interested in upgrading JPA 2.0 to JPA 2.1 GlassFish 3.1.2.2. How can I achieve this?
This is most likely not possible at all. JPA 2.1 is part of EE 7 and therefore not fully integrated with EE 6 GF 3.1.2.2.
Did you try just replacing the EclipseLink and JPA jar files in Glassfish?
It will probably work, but if you use managed persistence units they will not expose any JPA 2.1 API, you would need to unwrap the EntiyManager to access these.
I'm using Hibernate 4.3.8 (requires JPA 2.1) with Glassfish 3.1.2.2.
Note: I'm not using any services provided by glassfish. All the libraries I use are in the WEB-INF/lib.
1 - Override all JPA classes (package javax.persistence) in glassfish/modules/javax.persistence.jar with JPA 2.1 version. You should not replace the entire JAR, only override the classes. This JAR has an OSGI manifest and other classes that must remain there.
2 - Remove all javassist classes (package javasssist) from glassfish/modules/weld-osgi-bundle.jar. This solves a possible incompatibility if you are using Hibernate.

Jboss as7 ejb injection inside cdi beans

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