简体   繁体   中英

“JNDI name is already in use” in Weblogic 12c with EJB3

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?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM