4 Replies Latest reply: Jul 8, 2011 5:52 PM by Ales Justin RSS

    JBoss 6.0: ignore persistence.xml in jar file

    Gonne Martens Novice

      Hello!

       

      As Sergey I want to ignore the persistence.xml in a jar lib placed in the lib folder of my ear.

      I tried to use the AbstractIgnoreDeployer by placing a jboss-ignore.txt file in ear/META-INF.

       

      Structure of my ear:

       

      playground.ear

      \ lib

           \ playgroundTool.jar

               \ META-INF\persistence.xml

      \ META-INF

           \ jboss-ignore.txt

      \ playgroundEJB.jar

           \ META-INF\persistence.xml

      \ other jars and wars

       

      content of jboss-ignore.txt:

      lib/playgroundTool.jar/META-INF/persistence.xml

       

      Debugging of the AbstractIgnoreDeployer showed me that the jboss-ignore.txt file is parsed and creates an instance of CollectionNameIgnoreMechanism with "lib/playgroundTool.jar/META-INF/persistence.xml" as ignored path. I am not sure that this is correct, but through further debugging I could see that only the ignoreName() method is called once for the name persistence.xml of the playground.ear deployment unit (the variable ignoredNames is always null, so the method returns false). The method ignorePath is never called.

       

      How should it work right?

       

      Please help!

       

      Kind regards,

      Gonne

        • 1. Re: JBoss 6.0: ignore persistence.xml in jar file
          Ales Justin Master

          Hmm, looking at EARStructure

           

                           if (archive.getChild("META-INF/persistence.xml").exists())
                           {
                              log.trace(archive.getName() + " in ear lib directory has persistence units");
                              if (structureContext.determineChildStructure(archive) == false)

           

          it means that .ear lib is considered a sub-deployment if it has persistence.xml.

           

          This means you need to add META-INF/jboss-ignore.txt to the actual lib.

          Which sort of defeats the purpose of ignore file ...

          • 2. Re: JBoss 6.0: ignore persistence.xml in jar file
            Ales Justin Master

            This means you need to add META-INF/jboss-ignore.txt to the actual lib.

            With proper relative path: META-INF/persistence.xml or just persistence.xml will also do.

            Or simply delete the persistence.xml ... (grrr, need to see who put this code there)

            • 3. Re: JBoss 6.0: ignore persistence.xml in jar file
              Gonne Martens Novice

              Hi Ales,

               

              thank you for your response.

              According to your advice I tried to add the META-INF/jboss-ignore.txt to the actual lib. It was properly parsed by the AbstractIgnoreFilesDeployer and the NameIgnoreMechanism was registered in the DeploymentUnit.

               

              AbstractParsingDeployerWithOutput<T>: createMetaData()

              ...

              unit.getTransientManagedObjects().addAttachment(key, result, getOutput());

              ...

              But in the ignoreFile() method of AbstractVFSParsingDeployer<T> the DummyNameIgnoreMechanism is always used.

              It seems that the nameIgnoreMechanism attribute is not set properly even though the correct one is registered in the DeploymentUnit as transientManagedObject "org.jboss.deployers.spi.deployer.matchers.NameIgnoreMechanism".

               

              I overrided the nameIgnoreMechanism attribute in the debugger with the correct value and it worked as exprected.

               

              setNameIgnoreMechanism((org.jboss.deployers.spi.deployer.matchers.NameIgnoreMechanism)unit.getTransientManagedObjects().getAttachment("org.jboss.deployers.spi.deployer.matchers.NameIgnoreMechanism"))

              But I do not know where it should be fixed.

               

              Kind regards,

              Gonne

              • 4. Re: JBoss 6.0: ignore persistence.xml in jar file
                Ales Justin Master

                Which deployer instance is this?

                 

                By default all parsing deployers get set with DummyNIM; see org.jboss.Main class.

                It's then per parsing deployer to set the appropriate NIM instance.