How to access an EJB in an ear from a war? - ejb

I have two Projects deployed on the same weblogic server:
An ear archive with an EJB (#Local, #Stateless)
A war archive
I want to access the EJB from a class inside the war archive. Is this generally possible? How?

Interface needs #Remote
Stateless annotation of EJB class needs mappedName = "ejb/myEJB"
Lookup with "ejb.MyEJB#mypackage.MyEJBInterface"

Related

Can you deploy a message driven bean packaged as a EJB JAR on Weblogic?

Hi I am new to Weblogic and I am trying to figure out how to deploy a MDB properly. I have an EAR project that contains my Beans and config files, am I able to export that as a JAR and deploy that onto the Weblogic server?
EJB's can be deployed as JARs (see oracle docs section "Using Archived Files")
and the jar should contain the deployment descriptor xml / Annotations (e.g. #MessageDriven ) that configures the MDB.

EJBs are getting duplicated in weblogic 12c using EAR deployment from jdeveloper 12c

My project consists of 2 modules webapp + jar(ejb module), when I tried to run this app from jdeveloper 12c deployed to integrated weblogic server, the server is identifying all ejb beans as twice, one from war and other from jar. Any guess how this happens?
If your application is deployed as EAR, the EAR probably contains the EJB JARs within the WAR and the EAR.
If not, you are probably deploying the WAR with the EJB JARs inside AND the EJB JARs at the same time as multiple deployment.

EJB module - files

Can anyone explain me what are ibm-ejb-jar-bnd.xmi , ejb-jar.xml ,ibm-ejb-jar-ext.xmi and ibm_ejbext.properties. What are these files and what is configured in these files. What is the need of all these files in ejb project.
What does ibm-ejb-jar-bnd.xmi do and how it should be configured for message driven bean? Please let me know
ejb-jar.xml is the standard EJB deployment descriptor. It is where you declare which EJBs exist in your module.
ibm-ejb-jar-bnd.xmi is a file specific to WebSphere Application Server that contains binding information (where in JNDI should the EJB be bound, and where in JNDI should the EJB find the resources it uses). The ".xmi" file format is specific to EJB 2.1 and lower modules and has been replaced by the ibm-ejb-jar-bnd.xml file in EJB 3.0 and higher modules. The ".xmi" file format is in the XMI file format as generated by EMF and is barely documented (there is some basic information in the WAS_HOME/web directory of an installation, but you have to have some familiar with EMF to use it). Typically, the file is edited using RAD or modified during application deployment.
ibm-ejb-jar-ext.xmi is another file specific to WebSphere Application Server that contains various extensions to the specific (e.g., eager EJB initialization, stateful session timeouts, etc.). It is also only used for EJB 2.1 modules and lower and has been replaced by ibm-ejb-jar-ext.xml.
ibm_ejbext.properties is another file specific to WebSphere Application Server that is generated by EJB deploy and is not intended to be used by developers.
To manually configure ibm-ejb-jar-bnd.xmi, it's easiest to deploy the application, specify binding information, and then look at the result in PROFILE_HOME/config/cells/cell/applications/APP.ear/deployments/APP/META-INF/ibm-ejb-jar-bnd.xmi.

Why AEM as war file?

Adobe Experience Manager is downloadable in two format: either as a standalone jar File(which has Apache Felix as the OSGi Container, CRX as the repository, Apache Sling for content delivery and it's own Servlet Container which i believe is jetty nowadays).
and also as a war file. apart from the application server part, this war file has all the other elements and war is deployed on say WebSphere or Apache Tomcat.
i don't seem to understand what is advantage of having AEM as a .war file when a standalone jar will do the work.
Thanks
Some users want to use war files as that's what they are used to in their environments, but you are right that the runnable jar does the job just fine, with a simpler environment.
with a war file, we can deploy it to EJB server like Jboss

Deploying remote EJB and Web application

I have successfully deployed an EJB 3 module and a JSF WEB app which calls the EJB module's beans using netbeans IDE locally. Now when I try to deploy this in staging environment, i get the following error:
root cause
javax.servlet.ServletException: com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref com.store.managedbeans.CustomerManagedBean/customerService#jndi: com.store.service.CustomerRemote#null#com.store.service.CustomerRemote#Session#null into class com.store.managedbeans.CustomerManagedBean
root cause
javax.naming.NameNotFoundException: com.store.service.CustomerRemote#com.store.service.CustomerRemote not found
I have deployed the EJB module and Web application in glassfish v2 (in the staging environment).The jar of the EJB Module is inside WEB-INF/lib folder of web application. It looks like the web app cannot find the EJB module. The classes are annotated with #Remote. And I am calling interfaces and not the bean by using #EJB. And of course, this worked find when I deployed it under Netbeans.
From the comments:
The EJB Module was referencing a JMS Queue Connection Factory. The resource hadn't been created in the staging glassfish server. Although the EJB module was allowed to be deployed, the JNDI Log from the console reveals that none of the EJBs were bound to any names because of a problem in deploying the module.

Resources