11 Replies Latest reply on Jul 2, 2010 3:04 AM by hu qianghui

    Component.xml -- Two components with the same name and precedence

    Robert Blaszczak Newbie

      AS Version: 4.2.1
      Seam: 2.0.1


      I am receiving the following when I deploy my applications ear file:



      Caused by: java.lang.IllegalStateException: Two components with the same name and precedence: entityManager
           at org.jboss.seam.init.Initialization.addComponentDescriptor(Initialization.java:479)
           at org.jboss.seam.init.Initialization.installComponentFromXmlElement(Initialization.java:389)
           at org.jboss.seam.init.Initialization.installComponentsFromXmlElements(Initialization.java:195)
           at org.jboss.seam.init.Initialization.installComponentsFromDescriptor(Initialization.java:720)
           ... 93 more





      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
           xmlns:core="http://jboss.com/products/seam/core"
           xmlns:security="http://jboss.com/products/seam/security"
           xmlns:components="http://jboss.com/products/seam/components"
           xmlns:bpm="http://jboss.com/products/seam/bpm"
           xmlns:persistence="http://jboss.com/products/seam/persistence"
          xmlns:transaction="http://jboss.com/products/seam/transaction"
          xmlns:web="http://jboss.com/products/seam/web"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd 
                       http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
                       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd
                           http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.0.xsd
                       http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.0.xsd
                       http://jboss.com/products/seam/transaction http://jboss.com/products/seam/web-2.0.xsd
                       http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd">
      
           <!-- 120 second conversation timeout -->
          <core:manager conversation-timeout="120000" 
                        concurrent-request-timeout="500"
                        conversation-id-parameter="cid"/>
      
          <core:init debug="false" jndi-pattern="trecgui-gui-1.0.0/#{ejbName}/local"/>
          
         <persistence:managed-persistence-context name="entityManager"
                                           auto-create="true"
                            persistence-unit-jndi-name="java:/AuditManagement/entityManagerFactory" />
      
           
      </components>



      The components.xml is located in the war's WEB-INF dir...and yes there is only one of them in the ear.  If I remove the entityManager entry it will then complain about the next entry in the file.  The only way I can get it to deploy correctly is by creating a empty file or not including it in the build.  I am in the process of migrating from Seam 1.2.1 and this is my last hurdle.  I know I am doing something stupid, but I just cannot see it.  Any help would be appreciated. 

        • 1. Re: Component.xml -- Two components with the same name and precedence
          Nicklas Karlsson Master

          Are you sure that there isn't anything cached on the AS side? Tried nuking the tmp content and deployment dir and redeploying?

          • 2. Re: Component.xml -- Two components with the same name and precedence
            Robert Blaszczak Newbie

            Yup, I clear the servers tmp and work dirs every time.  I even bounce the server in between deployments just for grins.

            • 3. Re: Component.xml -- Two components with the same name and precedence
              Nicklas Karlsson Master

              Hmm, you sure you haven't dumped some extra jars somewhere in the server or jre libs?

              • 4. Re: Component.xml -- Two components with the same name and precedence
                Robert Blaszczak Newbie

                I have looked.  I understand why you think that and if I were you, I would be suggesting the same thing.  Plus, I know I have to be doing something odd.  After searching for dup files or entries, I put some break points in the Seam Initialization class and I changed the name of my managed-persistence-context in my deployed components.xml file (just in the one deployed xml file) to theEntityManager and I still got the same error.  I did not rebuild/redeploy the ear, just shutdown the server, edited the file and then started the server again.  It seems to get picked up in the public Initialization create() method and then again in the public Initialization init() method.

                • 5. Re: Component.xml -- Two components with the same name and precedence
                  Norman Richards Expert

                  Look at the debug log information.  Seam will report what directories and jars it is scanning and where it is finding those duplicate classes.

                  • 6. Re: Component.xml -- Two components with the same name and precedence
                    Robert Blaszczak Newbie

                    When I step through it with the debugger It seems to first read the components.xml from my war's WEB-INF at the first line and then again it finds it at the last line prior to the the stacktrace while its scanning the war file:



                    20:36:09,640 INFO  [Initialization] reading /WEB-INF/components.xml
                    20:36:09,867 INFO  [Initialization] reading jar:file:/home/doug/Applications/jboss-4.2.1.GA/server/default/tmp/deploy/tmp34699jboss-seam-ui.jar!/META-INF/components.xml
                    20:36:09,872 INFO  [Initialization] reading jar:file:/home/doug/Applications/jboss-4.2.1.GA/server/default/tmp/deploy/tmp34700jboss-seam.jar!/META-INF/components.xml
                    20:36:09,878 INFO  [Initialization] reading properties from: /seam.properties
                    20:36:09,879 INFO  [Initialization] reading properties from: /jndi.properties
                    20:36:09,884 INFO  [Initialization] initializing Seam
                    20:36:09,942 INFO  [Initialization] two components with same name, higher precedence wins: org.jboss.seam.web.parameters
                    20:36:09,944 INFO  [Initialization] two components with same name, higher precedence wins: org.jboss.seam.transaction.synchronizations
                    20:36:09,946 INFO  [Initialization] two components with same name, higher precedence wins: org.jboss.seam.core.expressions
                    20:36:09,948 INFO  [Initialization] two components with same name, higher precedence wins: org.jboss.seam.core.locale
                    20:36:09,950 INFO  [Initialization] two components with same name, higher precedence wins: org.jboss.seam.core.manager
                    20:36:09,951 INFO  [Initialization] two components with same name, higher precedence wins: org.jboss.seam.core.resourceLoader
                    20:36:09,958 INFO  [Initialization] two components with same name, higher precedence wins: org.jboss.seam.web.userPrincipal
                    20:36:09,962 INFO  [Initialization] two components with same name, higher precedence wins: org.jboss.seam.persistence.persistenceProvider
                    20:36:09,966 INFO  [Initialization] two components with same name, higher precedence wins: org.jboss.seam.core.locale
                    20:36:09,991 INFO  [Initialization] two components with same name, higher precedence wins: org.jboss.seam.security.identity
                    20:36:09,995 INFO  [Initialization] two components with same name, higher precedence wins: org.jboss.seam.bpm.businessProcess
                    20:36:09,996 INFO  [Initialization] two components with same name, higher precedence wins: org.jboss.seam.web.isUserInRole
                    20:36:10,023 INFO  [Initialization] two components with same name, higher precedence wins: entityManager
                    20:36:10,024 ERROR [[/soklow]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
                    java.lang.RuntimeException: error while reading soklowscorner.war/WEB-INF/components.xml
                         at org.jboss.seam.init.Initialization.installComponentsFromDescriptor(Initialization.java:732)
                         at org.jboss.seam.init.Initialization.scanForComponents(Initialization.java:695)
                         at org.jboss.seam.init.Initialization.init(Initialization.java:562)
                         at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
                         at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3854)
                         at org.apache.catalina.core.StandardContext.start(StandardContext.java:4359)
                         at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)
                         at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)
                         at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
                         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:585)
                         at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
                         at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
                         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                         at org.apache.catalina.core.StandardContext.init(StandardContext.java:5310)
                         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:585)
                         at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
                         at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
                         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                         at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)
                         at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
                         at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
                         at org.jboss.web.WebModule.startModule(WebModule.java:83)
                         at org.jboss.web.WebModule.startService(WebModule.java:61)
                         at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
                         at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
                         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:585)
                         at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                         at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                         at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                         at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                         at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
                         at $Proxy0.start(Unknown Source)
                         at org.jboss.system.ServiceController.start(ServiceController.java:417)
                         at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:585)
                         at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                         at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                         at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                         at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                         at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                         at $Proxy45.start(Unknown Source)
                         at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
                         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:585)
                         at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                         at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                         at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                         at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                         at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                         at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
                         at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
                         at org.jboss.ws.integration.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:93)
                         at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
                         at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
                         at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                         at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                         at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                         at $Proxy46.start(Unknown Source)
                         at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
                         at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1015)
                         at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
                         at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
                         at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:585)
                         at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                         at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                         at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                         at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                         at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                         at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                         at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                         at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                         at $Proxy9.deploy(Unknown Source)
                         at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
                         at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
                         at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
                         at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
                         at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
                    Caused by: java.lang.IllegalStateException: Two components with the same name and precedence: entityManager
                         at org.jboss.seam.init.Initialization.addComponentDescriptor(Initialization.java:479)
                         at org.jboss.seam.init.Initialization.installComponentFromXmlElement(Initialization.java:389)
                         at org.jboss.seam.init.Initialization.installComponentsFromXmlElements(Initialization.java:280)
                         at org.jboss.seam.init.Initialization.installComponentsFromDescriptor(Initialization.java:720)
                         ... 94 more



                    • 7. Re: Component.xml -- Two components with the same name and precedence
                      Robert Blaszczak Newbie

                      Fixed.  I had one too many seam.properties in my ear.  I had mistakenly placed one in the ears meta-inf.  After I removed it the components.xml was scanned only once.

                      • 8. Re: Component.xml -- Two components with the same name and precedence
                        Juan Medín Newbie

                        Just wanted to drop a line to thank you for posting the solution. I had the same problem and spent a lot of time trying to fix it. It was the seam.properties too

                        • 9. Re: Component.xml -- Two components with the same name and precedence
                          Julien Kronegg Novice

                          I got the same problem on another class: one of my Java class was compiled in two directories (one in the WEB-INF/classes and one in the WEB-INF/xxx directory), which was causing the problem. Changing the source directory's output dir to the default one solved the problem.
                          The duplicated seam.properties post above helped me a lot in understanding the problem, so thank you for the help!

                          • 10. Re: Component.xml -- Two components with the same name and precedence
                            hu qianghui Newbie
                            <blockquote>
                            _Norman Richards wrote on Mar 07, 2008 23:58:_<br/>

                            Look at the debug log information.  Seam will report what directories and jars it is scanning and where it is finding those duplicate classes.
                            </blockquote>

                            please tell me where si the debug log information.
                            I can not find it in directory of C:\opt\jboss\jboss-4.2.3.GA\server\all\log\log.
                            Thanks .
                            • 11. Re: Component.xml -- Two components with the same name and precedence
                              hu qianghui Newbie

                              I am meeting the same problem.


                              log:
                              java.lang.RuntimeException: error while reading fileupload/components.xml
                                   at org.jboss.seam.init.Initialization.installComponentsFromDescriptor(Initialization.java:745)
                                   at org.jboss.seam.init.Initialization.scanForComponents(Initialization.java:708)
                                   at org.jboss.seam.init.Initialization.init(Initialization.java:575)
                                   at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
                              ...
                              ...
                              ...
                              Caused by: java.lang.IllegalStateException: Two components with the same name and precedence - component name: org.jboss.seam.web.multipartFilter, component classes: XXXMultipartFilter, XXXMultipartFilter
                                   at org.jboss.seam.init.Initialization.addComponentDescriptor(Initialization.java:489)
                                   at org.jboss.seam.init.Initialization.installComponentFromXmlElement(Initialization.java:389)
                                   at org.jboss.seam.init.Initialization.installComponentsFromXmlElements(Initialization.java:280)
                                   at org.jboss.seam.init.Initialization.installComponentsFromDescriptor(Initialization.java:733).


                              but I can find the only one class XXXMultipartFilter.