i am transforming a Java EE application from Weblogic 12.2.1.3 to Wildfly 18.1 (need to stick to Java 1.8) and i am facing a problem with "Eager" EJB injection.
For example, in the deployment of war named MyWar that contains a ViewScopedBean:
#ViewScoped
public class BatchCCBean implements Serializable {
#EJB(lookup = "java:global/consumer.batch.common/BatchJobService!com.company.api.batch.RemoteBatchJobService")
RemoteBatchJobService batchJobService;
}
In Weblogic, if consumer.batch.common is NOT deployed during MyWar deployment, everything goes OK, deployment succeeds. If and only IF you try to initialize the BatchCCBean then you get an Exception. In other words it uses lazy EJB initialization.
BUT in Wildfly, I cannot deploy the MyWar application without deploying consumer.batch.common first because Weld in Wildfly 18.1 tries to eagerly initialize all Remote EJB injections during deployment time.
This is not a wanted behavior. Does anybody know how to "disable eager Remote EJB Injection" in Wildfly?
Thanks
Related
I was wondering if EJB specifications allow to access a stateful session bean over a looked up stateful session bean.
The reason why I'm asking is, that Jboss EAP 7.0 has no problems with it, but Websphere throws a NullPointerException when I try to access the bean.
For example:
#Stateful
public class SampleServiceRoot implements SampleServiceRootRemote {
#EJB
protected SampleServiceChildLocal servicechild;
#Override
public SampleServiceChildLocal getServiceChild(){
return servicechild;
}
}
#Stateful
public class SampleServiceChild implements SampleServiceChildLocal,SampleServiceChildRemote{
#Override
public void anyMethod(){
//DO Anything
}
}
When I do a remote lookup to the SampleServiceRootRemote and call "getServiceChild()" and try to call "anyMethod()" on it, it works on JBoss EAP 7.0 but on Websphere I get a NullPointerException.
So I was wondering if this is a Bug in Websphere or is it forbidden by EJB Specification and I was just lucky with JBoss EAP 7.0?
The EJB specification does require this scenario to work, depending on some configuration options; there are configuration options that may disable it.
The fact that you are seeing a NullPointerException indicates that WebSphere is not aware of the #EJB annotation on the field in the SampleServiceRoot class. Per the EJB specification, an instance of SampleServiceRoot cannot be created if the #EJB annotation cannot be resolved. Since an instance of SampleServiceRoot has been created, then one of the following has likely occurred:
1 - The application performed a new SampleServiceRoot rather than looking it up in JNDI. This doesn't sound like your problem, but good to double check.
2 - The application contains an ejb-jar.xml with the setting metadata-complete="true". When this is set, WebSphere will not look for annotations, and so will not see or process the #EJB annotation. Either change the setting to "false" or add the <ejb-ref> or <ejb-local-ref> to the ejb-jar.xml file.
3 - The application does not have metadata-complete="true", however when the application is deployed to WebSphere the option to set metadata-complete was selected.
This option will change the metadata-complete setting to "true". Stop using this option, or add the <ejb-ref> or <ejb-local-ref> to the ejb-jar.xml file.
4 - The EJB is contained in a WAR module at level 2.4 or older. In WebSphere, annotations for older modules are not processed.
5 - The application includes a copy of the javax.ejb.EJB class. WebSphere provides the javax.ejb.EJB class, and it is loaded by the WebSphere runtime classloader. If the application also contains the javax.ejb.EJB class on the application classpath, then another instance will be loaded by the application classloader, and it will not match the instance used by the EJB Container. There should be a warning in the logs if this has occurred.
So yes, your scenario is required to be supported; however the specification does allow configurations that disable it. You just need to identify which configuration / packaging option has caused WebSphere to not see the #EJB annotation.
Thanks for the answer,
we tried to move the declarations of the Local-Interface to the Remote Interface of the SampleServiceChild. Also we did not use #EJB annotation. We managed it with doing a lookup of the SampleServiceChild over the InitialContext.
Now it works
I'm deploying a new Spring JMS application to Weblogic 11g. What is the accepted way to deploy a Spring application with no web components to Weblogic?
Historically the apps I've been working on have used a WAR to load the application context. This does not seem like an acceptable solution now since this new application does not have any web components. Wrapping the deployment in an EJB does not seem acceptable either since Spring is supposed to be a replacement to EJB. A RAR does not seem to fit either, since the new application is not supplying any resources to other applications.
What options do I have, what is the accepted deployment method here?
Actually RAR archive is used for resources.
Firstly you should create the components of JMS in WebLogic side (JMS server, JMS module, JMS connection factory, queue or topic) that your application may use. When this components are integrated all that you need to create the EAR archive and deploy it. EAR can be created without any EJB modules.
I am a little new to J2EE. I have a EJB3 project and I want to run a class on application start-up, how can I do that?
I know in EJB3.1 I can use #startup and #singleton unfortunately that is not a option and I have to use EJb3 and java 5. I have done some research and there were a few solutions but I have been unable to make it work.
WebSphere Application Server version 6.1 does not support EJB3 with a standard installation. You also need to have a feature pack for EJB 3.0 installed.
See this information on the IBM site.
If this is not your issue you should update your question with more detail of what goes wrong.
Your only options prior to WebSphere 8 (with EJB 3.1 support) are:
WebSphere startup beans. These are a programming model extension
Package a WAR with the application, and use a ServletContextListener to initialize state used by the EJBs.
I'm having an issue with Injecting a javax.enterprise.event.Event instance into my EJB. The inject of the event works fine when the EJB is used in a web app deployed in a war, but when i deploy the web app in large application inside an EAR the event is null. Does anyone why that might be and how i can use inject the event when i deploy as an EAR? I'm using JBoss as 7.1.
Thank you.
I am trying to deploy a spring message message driven POJO on weblogic 8.1. It is a simple POJO, and it works fine being run outside of an application server, but the messages do not seem to be picked up at all. I have created empty home and remote interfaces, as well as a container bean class that contains an instance of the pojo which it gets from the application context. I then added this container bean class to the ejb-jar.xml as a . I have not been able to get the messages pick up.
Does anyone have any suggestions as to what I am doing wrong? Could anyone point me to a tutorial on how to deploy a MDP?
Thanks.
Here's a tutorial:
http://java-x.blogspot.com/2006/12/implementing-jms-with-spring-message.html
I have no idea what you're talking about when you say "home and remote interfaces". You said Spring POJO, but home and remote interfaces are EJB 2.0 artifacts.
The important question to answer is: Are your message driven component EJBs (MDB) or Spring POJO (MDP)? If they're EJBs, I totally understand why you need home and remote interfaces. If not, I would say this could be a pure web app, packaged in a WAR, without the EJB XML.
You also need a JMS queue to be set up. Have you done that properly? WebLogic 8.1 means JMS 1.0.2.
That's an OLD version of WebLogic and JDK. Why aren't you using WebLogic 10 and JDK 6?