30

I did not create the spring bean name with TimerServiceDispatcher in my application. But, the JBoss throw exception because of TimerServiceDispatcher is already defined in this module. I don't know what is the problem. What I am missing? What I need to do?

My application use Seam 2.3, Spring 3.0 and JPA 2.0. I don't use EJB.

11:29:01,531 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "MRBS.war"
11:29:04,217 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed to start service jboss.deployment.unit."MRBS.war".PARSE: org.jboss.msc.service.StartExcept
ion in service jboss.deployment.unit."MRBS.war".PARSE: Failed to process phase PARSE of deployment "MRBS.war"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_23]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_23]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_23]
Caused by: java.lang.IllegalArgumentException: JBAS011046: A component named 'TimerServiceDispatcher' is already defined in this module
    at org.jboss.as.ee.component.EEModuleDescription.addComponent(EEModuleDescription.java:137)
    at org.jboss.as.ejb3.deployment.processors.EJBComponentDescriptionFactory.addComponent(EJBComponentDescriptionFactory.java:60)
    at org.jboss.as.ejb3.deployment.processors.SessionBeanComponentDescriptionFactory.processSessionBeans(SessionBeanComponentDescriptionFactory.java:157)
    at org.jboss.as.ejb3.deployment.processors.SessionBeanComponentDescriptionFactory.processAnnotations(SessionBeanComponentDescriptionFactory.java:86)
    at org.jboss.as.ejb3.deployment.processors.AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.processAnnotations(AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.java:
58)
    at org.jboss.as.ejb3.deployment.processors.AbstractDeploymentUnitProcessor.deploy(AbstractDeploymentUnitProcessor.java:81)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    ... 5 more

11:29:04,230 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "MRBS.war" was rolled back with failure message {"JBAS014671: Failed servi
ces" => {"jboss.deployment.unit.\"MRBS.war\".PARSE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"MRBS.war\".PARSE: Failed to process phase PARSE of d
eployment \"MRBS.war\""}}
11:29:04,292 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015877: Stopped deployment MRBS.war in 61ms
11:29:04,294 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.deployment.unit."MRBS.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."MRBS.war".
PARSE: Failed to process phase PARSE of deployment "MRBS.war"

jboss-deployment-structure.xml

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
  <deployment>
      <dependencies>
          <module name="org.hibernate" export="true"/>
          <module name="javax.faces.api" export="true" />
          <module name="com.sun.jsf-impl" export="true"/>
          <module name="org.dom4j" export="true"/>
          <module name="org.hibernate.validator" export="true"/>
        </dependencies>
        <exclusions>
            <module name="org.apache.log4j" />
        </exclusions>       
  </deployment>  
</jboss-deployment-structure> 

Deplyment Structure

MRBS.war
    -index.html
    +web-page-pakage
    +META-INF
    +WEB-INF
        +classes
        +lib
           aopalliance.jar
            commons-beanutils.jar
            commons-codec.jar
            commons-lang-2.5.jar
            drools-compiler.jar
            drools-core.jar
            drools-decisiontables.jar
            drools-templates.jar
            eclipselink.jar
            el-api.jar
            guava.jar
            guice.jar
            hibernate-ehcache.jar
            httpclient.jar
            httpcore.jar
            javax.persistence_2.0.1.v201006031150.jar
            jboss-el.jar
            jboss-seam-debug.jar
            jboss-seam-excel.jar
            jboss-seam-ioc.jar
            jboss-seam-mail.jar
            jboss-seam-pdf.jar
            jboss-seam-ui.jar
            jboss-seam.jar
            junit-4.8.1.jar
            log4j-1.2.14.jar
            mysql-connector-java-5.1.6-bin.jar
            primefaces-3.3.1.jar
            sac.jar
            spring-aop.jar
            spring-asm.jar
            spring-beans.jar
            spring-context.jar
            spring-core.jar
            spring-expression.jar
            spring-jdbc.jar
            spring-orm.jar
            spring-tx.jar
            spring-web.jar
            urlrewritefilter.jar
            xercesImpl.jar
            xml-apis.jar
        -components.xml     
        -faces-config.xml
        -jboss-deployment-structure.xml
        -pages.xml
        -web.xml
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Zaw Than oo
  • 9,651
  • 13
  • 83
  • 131

10 Answers10

23

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.

Piwaf
  • 808
  • 8
  • 9
  • +1. I made the same mistake. This error message could use some improvement. – Nikola Kolev May 01 '14 at 20:54
  • 1
    WHY do you say "My code was of course wrong"? We have this problem, we have such annotations, but I don't know what is wrong with them. They worked fine until we upgraded to the 1.7.0_60 JDK. – Redboots Jul 02 '14 at 12:38
  • 7
    I say that because the Singleton and Stateless bean types are basically 2 different bean types. I want to say they mutually exclusive. The singleton bean is saying one bean for all client calls, which implies it's stateless in nature. So I believe JBoss ends up deploying the bean twice, once as a Stateless bean and once as a Singleton, which ends up in a naming conflict. – Piwaf Jul 03 '14 at 14:25
  • +1 This answer quickly solved my problem. I don't think that it's that obvious that annotations Stateless and Singleton shouldn't go together. Anyway "A component named 'Foo' is already defined in this module" is not very helpful. – null Jul 23 '14 at 09:09
  • This also applies of course to `@Singleton` and `@Stateful`. So thanks, this answer really helped me find the issue fast. – Stephan Mar 11 '15 at 09:09
16

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.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
djchapm
  • 161
  • 1
  • 5
  • Ok, this seems to be the case for me also, but how did you fix it - that is if you did? – Charles Jun 17 '16 at 07:05
  • 3
    Find the jar file you're using (follow trail of dependencies) - it's likely a custom jar file and not something out in maven. Bust it open, edit the manifest, and remove "." from the Classpath entry specified in manifest.mf, then jar it back up. It will most likely be one off the jars that is actually deployed with your application war or ear etc. – djchapm Sep 22 '17 at 19:59
13

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.

Vinoth Vino
  • 9,166
  • 3
  • 66
  • 70
9

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: IntelliJ Project Structure Dialogue

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.

stefan.m
  • 1,912
  • 4
  • 20
  • 36
8

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"}}

Jens Piegsa
  • 7,399
  • 5
  • 58
  • 106
1

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

Brooks
  • 7,099
  • 6
  • 51
  • 82
0

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.

Mukul Goel
  • 8,387
  • 6
  • 37
  • 77
  • I used jboss-deployment-structure.xml – Zaw Than oo Nov 01 '12 at 05:55
  • @CycDemo, Thats ok but you need to resolve library conflicts as well. can you post the structre of your war? use `jar -tf nameofwar.war` and post the result ? – Mukul Goel Nov 01 '12 at 05:59
  • @CycDemo, would you mind getting in a chat? else its gonna be a long discussion here ? – Mukul Goel Nov 01 '12 at 06:06
  • @CycDemo, the point what I am trying to make with my answer is the cause of your error is `library/version conflict` and not the presence or absence of `jboss-deployment-structure.xml`, – Mukul Goel Nov 01 '12 at 06:12
  • @CycDemo , please read through the post and answer at https://community.jboss.org/thread/202825 – Mukul Goel Nov 01 '12 at 07:13
0

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.

Skurpi
  • 1,000
  • 1
  • 12
  • 22
0

It can be caused by a previous version of the jar being deployed instead of the correct one. It was solved when I deleted all the contents of the target folder.

Filipe P Goes
  • 71
  • 1
  • 2
0

The answers helped me locate the root cause of my issue. I am using Arquillian and I was adding to the Web archive a class through the

JavaArchive ja = ShrinkWrap.create(JavaArchive.class, "myejb.jar")
            .addPackages(true, "a.package.name")

and as a maven dependency

        File[] files = Maven.resolver()
            .addDependencies(
                MavenDependencies.createDependency("G:A:V", ScopeType.COMPILE, false),

Hence the previously described error. I left only the maven dependency and the error disappeared.

Investigator
  • 1,431
  • 2
  • 17
  • 24