CDI deployment failure:WELD-001414 Bean name is ambiguous

我只是一个虾纸丫 提交于 2019-12-19 06:22:13

问题


I have an application, which has multiple modules and various dependencies. When I deploy the application on Glassfish 4, I am getting error:

org.jboss.weld.exceptions.DeploymentException: WELD-001414 Bean name is ambiguous. 
Name    JerseyClassAnalyzer resolves to beans: [Managed Bean [class org.glassfish.jersey.internal.inject.JerseyClassAnalyzer] 
with qualifiers [@Default @Named @Any], Managed Bean 
[class org.glassfish.jersey.internal.inject.JerseyClassAnalyzer] 
with qualifiers [@Default @Named @Any]]

What can be the cause? I saw already topics about this and the solution was to edit the annotation but this is not my EJB, just a dependency. How can I avoid this exception?

I am using Java EE 6 with JDK 1.7 and Glassfish 4.0.


回答1:


Glassfish is already having Jerseys libraries packaged for you, so you need add provided scope into your Maven pom.xml as stated in the docs.

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.0</version>
    <scope>provided</scope>
</dependency>

If you are using any Jersey specific feature, you will need to depend on Jersey directly.

<dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-servlet</artifactId>
    <version>2.4.1</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-client</artifactId>
    <version>2.4.1</version>
    <scope>provided</scope>
</dependency>



回答2:


Are you by any chance packaging the Jersey specific libraries in your EAR file. I believe glassfish does provide the Jersey libraries and you do not need to package them.




回答3:


I think you have two @Named bean class with the same name.



来源:https://stackoverflow.com/questions/20050266/cdi-deployment-failureweld-001414-bean-name-is-ambiguous

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!