Failed to deploy WAR to EAR on WebLogic

I have a web application running on JSF 2.2 on a WebLogic 12.2.1.1 application server.

I have a simple java class and am trying to initialize it as an ApplicationScoped object using CDI. This is great as a WAR.

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;

@Named
@ApplicationScoped
public class AppContext {
    public AppContext() {
    }
}

However, when I add this WAR to the EAR, it does not expand. I am trying to find all possible solutions, and at the moment nothing is working. The exception log is as follows:

weblogic.management.DeploymentException: CDI deployment failure:WELD-001414: Bean name is ambiguous. Name appContext resolves to beans: [Managed Bean [class beans.AppContext] with qualifiers [@Default @Any @Named], Managed Bean [class beans.AppContext] with qualifiers [@Default @Any @Named]]:org.jboss.weld.exceptions.DeploymentException:WELD-001414: Bean name is ambiguous. Name appContext resolves to beans: [Managed Bean [class beans.AppContext] with qualifiers [@Default @Any @Named], Managed Bean [class beans.AppContext] with qualifiers [@Default @Any @Named]]
    at org.jboss.weld.bootstrap.Validator.validateBeanNames(Validator.java:641)
    at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:487)
    at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:446)
    at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90)
    at com.oracle.injection.provider.weld.WeldInjectionContainer.start(WeldInjectionContainer.java:150)
    Truncated. see log file for complete stacktrace

Also WEB-INF \ beans.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>

Application Launch:

NetBeans IDE 8.2;
JDK 1.8 b121;
Mojarra JSF 2.2;
WebLogic 12.2.1.1;

Any hints to fix this problem are very welcome.

+4
source share
4 answers

IMHO: , .. EAR bean , WAR bean . , CDI EAR, . J2EE . , , .

, :

+1

, WAR, , EAR . bean , - EAR. , ( , ) EAR; APP-INF . , , , , , (, MyUniqueBeanName). , .

+1

WAR EAR . - WAR EAR . , WebLogic EAR.

- CDI Bean

+1
source

It seems that any bean is already registered with the name "appContext" on the bean server.

Either specify a different bean name or change the class name.

0
source

Source: https://habr.com/ru/post/1672597/


All Articles