"JNDI name is already in use" in Weblogic 12c with EJB3
Asked Answered
S

2

9

I have the following code that I'm trying to deploy as an EJB to WebLogic 12c, but I'm getting an error:

"Error deploying the EJB GeopoliticalServiceBean(Application: campaigner-ejb, EJBComponent: campaigner-service.jar), the JNDI name java:global/campaigner-ejb/campaigner-service/GeopoliticalServiceBean!com.dr_dee_sw.campaigner.service.GeopoliticalServiceLocal is already in use. You must set a different JNDI name in the weblogic-ejb-jar.xml deployment descriptor or corresponding annotation for this EJB before it can be deployed."

public interface GeopoliticalService
{
...
}

@Local
public interface GeopoliticalServiceLocal extends GeopoliticalService
{
}

@Remote
public interface GeopoliticalServiceRemote extends GeopoliticalService
{
}

@TransactionManagement(value = TransactionManagementType.CONTAINER)
@TransactionAttribute(value = TransactionAttributeType.REQUIRED)
@Stateless
public class GeopoliticalServiceBean implements GeopoliticalServiceLocal,GeopoliticalServiceRemote
{
...
}

More information: I've reduced the EJB-JAR file, campaigner-service.jar, so that there's only one bean in it, plus the interfaces and exceptions. the EAR file, campaigner-ejb.ear, has only the EJB-JAR in it at the main level. It also has a "lib" directory with supporting libraries, but it only has the DAO and DTO jars in it plus third-party libraries. So, to me, it doesn't seem like a packaging issue.

This is my first app using all annotations, but it still seems fairly straight-forward. What am I missing?

Sartor answered 21/7, 2015 at 18:21 Comment(9)
Could you clarify what do you mean by reducing EJB-JAR file? Can you paste the content of the file?Escharotic
Do you get the same error even if you bounce weblogic?Pronoun
The EJB-JAR had several beans in it. To reduce the number of variables in this problem, I changed the build file to only include one bean. The EJB-JAR file is a JAR file, so I can't truly copy it, but its contents include the one EJB implementation plus its interfaces, plus some custom exceptions.Sartor
Yes, I get the same error when I bounce weblogicSartor
We've upgraded from OC4J. In OC4J, an EJB could either be local or remote, but not both. I was assuming that in WebLogic an EJB could be both. Is that assumption wrong? I do need both because I'm going to be accessing these beans from both a web site and a standalone command line app.Sartor
An EJB may be both Local and Remote. Its not clear what you mean by accessing the EJB from a website. Do you want to access the bean from a web project in the same ear file, different server via RMI, do you want to give it a Restful facade....?Eveevection
I meant from a web project that may or may not be in the same ear file. Haven't decided. I may just deploy the website(s) as a war file.Sartor
I've cleared out WebLogic's cache of anything connected to my project and restarted it. I've simplified the lone EJB so that the only method it has is "String getHelloWorld()". It now has only one interface, the local one. Now I get this: ClassNotFoundException: com.dr_dee_sw.campaigner.service.impl.GeopoliticalServiceBean_4cpp7k_GeopoliticalServiceLocalImplSartor
If you are using Weblogic + Eclipse, check the Published Modules under your Weblogic Server. Remove conflicting ear if there is one.Kingston
F
5

During the migration from Weblogic 10 to Weblogic 12 we faced the same issue. We could reproduce the issue by deploying the EAR on a fresh server without the datasources configured properly; this would cause a NameNotFoundException during deployment. Every next attempt to deploy the EAR would result in the JDNI name is already in use, even after restarting, undeploying, redeploying.

The only thing that resolved the issue was removing the cache (and most importantly the EJBCompilerCache) and tmp folder of the target server.

Fabriane answered 23/5, 2017 at 9:39 Comment(0)
V
2

WebLogic caches artefacts even if they are undeployed (deleted). The solution is to remove the caches.

Solution

For each domain you should remove the cached artefacts. For example for svc domain, stop all the servers (Admin and managed), then Execute the following to delete the tmp and EJB caches.

cd /data/weblogic/Oracle/products/Oracle_Home/fusion/user_projects/domains/svc
rm -fr ./servers/svc_srv1/cache/EJBCompilerCache
rm -fr ./servers/Administrator/cache/EJBCompilerCache
rm -fr ./servers/AdminServer/tmp
rm -fr ./servers/svc_srv1/tmp

Otherwise, from weblogic admin console, go to Home >Summary of Servers >YOUR_DOMAIN_NAME and then on EJBs tab tick Force Generation to true

Voletta answered 25/6, 2019 at 14:27 Comment(1)
YOUR_DOMAIN_NAME and then on EJBs tab tick Force Generation to true dosent work for me.Hallucinosis

© 2022 - 2024 — McMap. All rights reserved.