Call EJB from another domain - ejb-3.0

What I am doing:
I'm trying to develop a small prog for calling the EJB from another domain.
Version
EJB 3.0
Weblogic 10.3.6
There are 2 domains on Machine1 and Machine2 so the managed servers are
domain1_cluster1_machine1 domain1_cluster1_machine2
domain2_cluster1_machine1 domain2_cluster1_machine2
(hope that I make it clear)
I followed this blog to develop the prog:
http://edwin.baculsoft.com/tag/weblogic/
I deployed the EJB on domain1_cluster1_machine1 and domain1_cluster1_machine2 with Active status and it can be found in JNDI tree.Then the client application is deployed on domain2_cluster1_machine1 and domain2_cluster1_machine2
All of the code is same as the blog, besides the provider url:
t3://[IP of Machine1]:[Listen port of domain**1**_cluster1_machine1]
When I run the client application from domain2_cluster1_machine1, I got the following exception:
javax.naming.CommunicationException [Root exception is
java.rmi.UnmarshalException: failed to unmarshal class
java.lang.Object; nested exception is:
java.lang.ClassNotFoundException: com.edw.ejb3.HelloEJBRemote]
When I type wrong in the lookup ie ic.lookup("com.edw.ejb3.HelloEJBRemote"), the exception is:
javax.naming.NameNotFoundException: While trying to lookup
'com.edw.ejb3.HelloEJBRemote' didn't find subcontext 'com'. Resolved
'' [Root exception is javax.naming.NameNotFoundException: While trying
to lookup 'com.edw.ejb3.HelloEJBRemote' didn't find subcontext 'com'.
Resolved '']; remaining name 'com/edw/ejb3/HelloEJBRemote'
Therefore, can I conclude that the client is able to find the EJB from domain1 as the exception is not NameNotFoundException?
Then what's wrong this it? Is it related to security?
I am newbie of both Weblogic and EJB. Your help will be appreciated. Thank you!

As mentioned in the comments, Please make sure that you have deployed the EJBs like described below -
Cluster 1
HelloEJBRemote
HelloEJBRemoteImpl
Cluster 2
HelloEJBRemote
Do a look up from Cluster2 to Cluster 1 for the Bean using the JNDI name of HelloEJBRemoteImpl

Related

Upgrading from WebLogic 12.1.3 to 12.2.1.4 breaks our application using Spring Framework 3.0.2

Our company is having us upgrade from Oracle WebLogic 12.1.3 to 12.2.1.4 since 12.1.3 is out of support/going out of support.
We have a major application that is using Spring Framework v3.0.2. When we deploy the EAR to 12.2.1.4 and attempt to consume any of the web services, we get this error stack trace. I've removed names that specify our company with generic names but you should be able to get the gist of what is happening:
2021-06-02 15:21:50.019/27.406 Oracle Coherence GE 12.2.1.4.0 (thread=[STANDBY] ExecuteThread: '10' for queue: 'weblogic.kernel.Default (self-tuning)', member=n/a): Configured versioned, multi-cluster Management over ReST
02.06.2021 15:22:11 - error trying to getBean("DefaultJBL"): Error creating bean with name 'DefaultJBL' defined in URL [zip:C:/javadev/server/appserver.12.2.1.4/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/lasor/2wlg44/lib/Lasor_core-1.0.jar!/com/foo/app/corebuslogic/common/jbl/DefaultJBL.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.RuntimeException: java.lang.ClassNotFoundException: com.foo.app.corebuslogic.common.exceptions.LoggedException
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'DefaultJBL' defined in URL [zip:C:/javadev/server/appserver.12.2.1.4/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/app/2wlg44/lib/App_core-1.0.jar!/com/foo/app/corebuslogic/common/jbl/DefaultJBL.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.RuntimeException: java.lang.ClassNotFoundException: com.aep.lasor.corebuslogic.common.exceptions.LoggedException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1045)
at com.foo.util.FOOApplicationContext.fetchBean(FOOApplicationContext.java:203)
at com.foo.app.buslogic.common.generic.GenericSessionBean.getBL(GenericSessionBean.java:293)
at com.foo.app.buslogic.common.generic.GenericSessionBean.query(GenericSessionBean.java:97)
I also believe the API is SOAP in 12.1.3 but I see REST specified in the 12.2.1.4 logs. Could this be the issue or am I reading that incorrectly?
Also, the classes is says it cannot find I've verified are there in the deployment area of WebLogic so I'm not sure why it can't find them.
Here is where the code throws an exception no matter what bean name I pass in but they've all been defined. The class is our FOOApplicationContext that implements org.springframework.context.ApplicationContextAware and has a fetchBean function that does the following:
public static Object fetchBean(final String beanName) throws FOOException {
Object object = null;
if (beanName == null) {
throw new FOOException("beanName is null");
}
try {
object = currentSpringContext().getBean(beanName);
} catch (Exception e) {
final String message = "error trying to getBean('"" + beanName + "\"): " + e.getMessage();
throw new FOOException(message, e);
}
return object;
}
When getBean() is called under WebLogic 12.1.3, it works. But it throws the AOP Exception error listed above when this exact same function is called under WebLogic 12.4.1.2. No code changes, etc. Not sure why this is.
We haven't created an actual server yet to deploy to, but instead I've installed it locally on my development machine. I've set up the database connections, etc the same way as do when locally installing 12.1.3. Is there something that has changed in regards to Spring Framework? The code was written over 8+ years ago and I inteherited the support for it and now I have to get us moved to WebLogic 12.2.1.4 before the end of this year and this is a major part of a very important application. The WebLogic application houses all the business logic and database access in it so without it, the front-end app is dead in the water.
Also, none of our registered beans will instantiate at all under WebLogic 12.2.1.4 but it works under 12.1.3. I've even recompiled the EAR file and again, it works under 12.1.3 but not 12.2.1.4.
I've found what appears to be a possibly circular reference between 2 objects that are not registered as beans, but the beans do depend on. So those 2 objects are not registered as beans. Not sure why it was done that way, but in any case, this doesn't seem to create a problem in 12.1.3. But one of the objects (FOOException) shows up in the error thrown when trying to create the DefaultJBL bean within the FOOApplicationContext object.
I'm not sure what else I can provide. Searching around the internet has not found a solution to my issue. I've found some that appeared as if they would fix it, but they turn out to not apply. I cannot seem to find anyone else with this issue, but Google and Duck Duck Go all find various "solutions" that don't apply to my situation.
Thanks!
ClassNotFound Exception, You may need to update the Dependencies pertaining to Spring Framework

Weblogic JMS binding issue, class could not be initialized exception

Could not initialize class exception is coming when trying to view the jndi bindings for a JMS destination in Weblogic 12c server. I have setup JMS modules with JMS destination queues and connection factory. Below are the things that is deployed in the server :
JMS Module : MyAppJmsModule (JMSSystemResource)
JMS Server : MyAppJMSServer (Foreign Server)
JNDI Initial Context Factory: com.sun.jndi.fscontext.RefFSContextFactory
JNDI Connection URL: file:///abc/oracle/config/domains/domain_test/jms/MyAppJmsModule/MyAppJMSServer/jms
In the above path lies the .bindings file
Destination tab showing Name, Local JNDI name and Remote JNDI name correctly.
Connection Factories tab also showing the jndi names correctly.
Local jndi name is prefixed with jms/
Now when I am clicking on the destination inside the JNDI Tree, it gives me the below error:
Unexpected exception: failed to load return type: class java.lang.Object; nested exception is: java.lang.ClassNotFoundException: Failed to load class com.ibm.mq.jms.MQQueue
Error from weblogic log :
An error was generated by the RMI server:
weblogic.jndi.internal.RootNamingNode.lookup(Ljava.lang.String;Ljava.util.Hashtable;)
java.lang.NoClassDefFoundError: Could not initialize class com.ibm.mq.jms.MQXAQueueConnectionFactory.
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.ibm.mq.jms.MQXAQueueConnectionFactoryFactory.class$(MQXAQueueConnectionFactoryFactory.java:58)
at com.ibm.mq.jms.MQXAQueueConnectionFactoryFactory.getObjectInstance(MQXAQueueConnectionFactoryFactory.java:58)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
Successful JNDI binding should show something like this :
Binding Name: jms.QUEUENAME
Class: com.ibm.mq.jms.MQQueue
Hash Code: Some Value
toString Results: queue://QUEUEMGR/APP.QUEUENAME?persistence=2&expiry=0
I have deployed an appplication which got deployed successfully but in warning state. When I checked the monitoring tab for the application it is showing the below error :
Symtom{MDB,MEDIUM,MyApp-0.0.1-SNAPSHOT,MDB application MyApp-0.0.1-SNAPSHOT is NOT connected to messaging system.}
I have checked few of the classes that got loaded and I found the below relevant classes that is being displayed in application classpath :
~/application/config/com.ibm.mq-9.0.0.jar
~/application/config/com.ibm.mq.headers.jar
~/application/config/com.ibm.mq.jmqi-9.0.0.jar
~/application/config/com.ibm.mq.pcf-6.1.jar
~/application/config/com.ibm.mqjms-9.0.0.jar
~/application/config/commons-codec-1.10.jar
~/application/config/dhbcore.jar
~/application/config/fscontext.jar
~/application/config/javaee-api-5.jar
~/application/config/jms.jar
~/application/config/jndi.jar
~/application/config/providerutil.jar
Please help me to find out what is I am missing in my configurations.
The application got successfully deployed and it is connecting to the JMS messaging system. I have removed javaee-api jar as it was already there in the classpath with a different version and added the jms-api jar from weblogic library.
However, the destination in the JNDI tree is still giving the error.

How to use Jersey in Sling?

I've got Sling 8. I then include Jersey and this Jersey connector in my build: https://github.com/hstaudacher/osgi-jax-rs-connector
My next step should be simply write a Jersey Service and test it, but I'm getting this Exception immediately:
27.01.2017 10:54:16.696 *ERROR* [FelixDispatchQueue] com.eclipsesource.jaxrs.publisher FrameworkEvent ERROR (org.osgi.framework.ServiceException: Service factory returned null.)org.osgi.framework.ServiceException: Service factory returned null.
and
[FelixDispatchQueue] com.eclipsesource.jaxrs.publisher FrameworkEvent ERROR (org.osgi.framework.ServiceException: Service factory exception: org/apache/felix/shell/Command)
org.osgi.framework.ServiceException: Service factory exception: org/apache/felix/shell/Command
and
Caused by: java.lang.NoClassDefFoundError: org/apache/felix/shell/Command
So I look at my bundles list in Felix, and I don't see any bundle that appears to provide this... So I find it online and install it myself. Now I get this exception:
Service factory exception: org/apache/sling/extensions/threaddump/internal/ThreadDumpCommand
and
Caused by: java.lang.NoClassDefFoundError: org/apache/sling/extensions/threaddump/internal/ThreadDumpCommand
and
Caused by: java.lang.NoClassDefFoundError: org/apache/felix/webconsole/plugins/memoryusage/internal/MemoryUsageCommand
Now, I DO have a bundle installed with this class (it's "Apache Felix Web Console Memory Usage Plugin"). So now I really don't understand what the heck is going on.
I have a feeling that I'm not supposed to be providing my own "felix shell" bundle and that the OSGI in Sling is failing to provide it...
Is anybody successfully using Sling 8 and Jersey?
Maybe you should try with just a vanilla OSGi environment for starters. Once you have Jersey working then you can try integrating with Sling.
I have had success with jaxrs in OSGi, specifically using the Amdatu REST bundles.
https://amdatu.org/application/tutorial/step1/
With this I was able to use JAX-RS annotations to serve HTTP services:
https://github.com/figurate/figurate-core/blob/master/modules/figurate-osgi/src/main/groovy/org/figurate/osgi/http/ServiceInfo.groovy
You can see the bundles I used here:
https://github.com/figurate/figurate-core/blob/master/modules/figurate-osgi/src/test/resources/config/HttpVersionSpec.config

Websphere, Spring WS A resource reference binding could not be found

I am trying to deploy Spring web application using Spring Web Services on Websphere 8. Deploy to Tomcat works without any problem but with Websphere I needed to add jaxws-rt (this wasn't needed for Tomcat, but also with it is working) and after that I am still getting on WAS:
CWNEN0044E: A resource reference binding could not be found for the following resource
references [com.sun.xml.ws.transport.tcp.servicechannel.ServiceChannelWSImpl/wsContext,
com.sun.xml.ws.tx.webservice.member.coord.RegistrationRequesterPortTypeImpl/wsContext,
com.sun.xml.ws.tx.webservice.member.coord.RegistrationPortTypeImpl/wsContext,
com.sun.xml.ws.tx.webservice.member.coord.ActivationRequesterPortTypeImpl/wsContext,
com.sun.xml.ws.tx.webservice.member.coord.RegistrationCoordinatorPortTypeImpl/wsContext,
com.sun.xml.ws.mex.server.MEXEndpoint/wsContext,
com.sun.xml.ws.tx.webservice.member.at.CoordinatorPortTypeImpl/wsContext,
com.sun.xml.ws.tx.webservice.member.coord.ActivationCoordinatorPortTypeImpl/wsContext,
com.sun.xml.ws.tx.webservice.member.at.CompletionInitiatorPortTypeImpl/wsContext,
com.sun.xml.ws.tx.webservice.member.at.ParticipantPortTypeImpl/wsContext,
com.sun.xml.ws.tx.webservice.member.at.CompletionCoordinatorPortTypeImpl/wsContext]
How to specify reference bindings?
I also see another error during deployin SystemErr:
Caused by: com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load
webapp: Failed to load webapp: javax.servlet.ServletContainerInitializer: Provider
com.sun.xml.ws.transport.http.servlet.WSServletContainerInitializer not a subtype
But I am not sure if this is somehow connected with reference binding problem.

Deploying Worklight on WebSphere

I've deployed Worklight 6 on WebSphere 8.5.5 trying to follow these instructions ( http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp ) with a derby database and I've encountered the following error when trying to hit my Worklight instance:
Error 500: javax.servlet.ServletException: Worklight Project not initialized
When I check the log, I can see that the worklight server has not been started due to this exception:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'brokerSessionFactory' defined in URL [jar:file:/C:/IBM/WebSphere/AppServer/lib/worklight-jee-library-6.0.0.jar!/conf/spring-server-core.xml]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError: javax/persistence/spi/PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;
...
Caused by: java.lang.AbstractMethodError: javax/persistence/spi/PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode
at org.apache.openjpa.persistence.PersistenceUnitInfoImpl.toOpenJPAProperties(PersistenceUnitInfoImpl.java:499)
at org.apache.openjpa.persistence.PersistenceProductDerivation.load(PersistenceProductDerivation.java:317)
at org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:160)
at org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:62)
I put the worklight jar directly in the WebSphere lib to solve another problem related to an Authentication class not being found if I recall correctly... Perhaps I need more jars in there, or did I solve my previous problem incorrectly? I put the javax.peristence.jar inside websphere as well, but that didn't help.
Are you using Ant scripts for deployment? This happens if you miss some steps while doing the manual application deployment.

Resources