A component named 'XXX' is already defined in this module in JBoss 7.1.1

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 02:34:10

I had a bean annotated with @Singleton and @Stateless that triggered this error. My code was of course wrong but the message and posts like this lead me down the wrong path for a while.

djchapm

I know the answer to this one. Spent weeks with JBoss Support on it due to my stubborness. They plan on providing fix or at least better messaging with EAP 6.2.x release.

The problem arises with the EJB Annotation preprocessors - which take your war, and the libs compiled into it and scans them for EJB annotations. Some Jar files can have an entry in the Manifest for "Classpath: ." (or whatever but with '.' as one of the entries). This causes the annotation preprocessor to idiotically process all the jar files in the web-inf lib again. Finally it will get around to a jar file with an EJB annotation in it that it has already seen, because it was already processed earlier - this causes it to complain with "A component Named xxx is already defined".

So the most frustrating part here is that it's probably some old jar file that you don't even care about that has this unnecessary Classpath manifest entry in it - and causes JBoss to recurse on itself.

Andreas Bögelein

I had the same problem but for me none of the suggested solutions helped. I noticed that the EJB JAR was present twice (newest version and older version) in the WEB.WAR.

This was because the maven clean operation on the parent project in eclipse didn't cascade to the child projects. I fixed it by doing a simple "mvn clean" on the child project.

Running the Maven goals:

  1. wildfly:undeploy
  2. clean
  3. wildfly:deploy

helped in our case:

[ERROR] Caused by: java.lang.IllegalArgumentException: WFLYEE0040: A component named 'xxx' is already defined in this module"}}

I had the same problem in IntelliJ. The reason was that IntelliJ created a WAR file with my classes both in WEB-INF/classes AND as a separate Jar file in WEB-INF/lib.

It took me some time to find out why IntelliJ did this. The reason lay in the dialogue File -> Project Structure -> Artifacts:

After removing the 'vertrag-ui-war' compile output, the error did not occur anymore. P.S. I have no idea why IntelliJ made this setting - I definitively did not set this.

Removing @Singleton fixed this error for me. No idea why though.

The problem is not that you dint create TimeServiceDispatcher it is a class part of seam framework org.jboss.seam.async.TimerServiceDispatcher , its a seam fw class.

Now about the error.

These kind of error occur when there are conflicts in libraries provided with application and by server. Its seriously very common with JBoss 7.1 and very frustrating as well.

You need to know

  1. What all Libraries and there version are u packaging inside your application ?
  2. what all of above libraries and version are provided by JBoss 7.1

Now for libraries that are on both side check for version

if version of application and JBoss is same , then remove that jar from Application (suggested) (else you can configure in the deployment-structure.xml which one to use)

if version of application jar and jboss is different, in that case , you will need to configure in deployment descriptor which one to pick.

While copy pasting and creating new components, I forgot to update the value that the @Stateless(value) annotation accept in the new components. This meant I had two components with the same name and I got this error. Hope it helps someone.

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