0

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

I have a simple java class and trying to initialize it as an ApplicationScoped object using CDI. The below code works fine and gets deployed.

import javax.enterprise.context.ApplicationScoped;

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

However when I try to initialize the object with @Named annotation, it fails to deploy what so ever

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

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

The exception log is as below:

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 is as follows:

<?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 Running On:

JDK 1.8 b121;
Mojarra JSF 2.2;
WebLogic 12.2.1.1;

Any hint on fixing this issue is highly appreciated.

Sirish V
  • 930
  • 2
  • 12
  • 24
  • 1
    look for link may help you http://stackoverflow.com/questions/10994158/difference-between-named-and-managedbean-annotations-in-jsf2-0-tomcat7 – ankush yadav Mar 16 '17 at 07:17
  • 1
    Just from the first look - the exception says there are two beans with the same name ("appContext"). Try giving a custom name to your bean. E.g. `@Named("myAppContextBean") and see what happens. – Siliarus Mar 16 '17 at 07:18
  • Thanks @Siliarus! I have tried your suggestion but still getting the same error message. It definitely got something else to do than the actual error message being displayed. – Sirish V Mar 16 '17 at 20:26

1 Answers1

0

I was able to deploy eventually.

However, I had to remove the WAR from EAR and deploy it separately. For some reason, packaging the WAR in the EAR and deploying fails. Not sure if this is an issue with WebLogic or EAR configuration.

Sirish V
  • 930
  • 2
  • 12
  • 24