7 Replies Latest reply on May 12, 2015 9:14 AM by Jonathan Lermitage

    EAP6: how to always prefer webapp's jars instead of JBoss modules?

    Jonathan Lermitage Newbie

      Hi,

       

      I'm migrating a webapp (WAR, based on Spring MVC/WS/Data) from Tomcat 7 to JBoss EAP 6.4.0.

       

      I have a problem with JBoss classloader: I need to load and prefer my webapp's WEB-INF/lib/ jars, especially JPA2.1 and some Jaskson libs, but the server loads its own version (JPA2.0, etc.).

       

      Thanks to this ticket ( [WFCORE-209] do not export api if excluded within jboss-deployment-structure.xml - JBoss Issue Tracker ), I've found how to disable the JBoss version of JPA, but I still have to disable many other JBoss libraries.

      Q: Is there a way to simply always prefer my webapp's libs ?

       

      Accodring to the documentation, JBoss EAP6 (based on JBoss7) allows this configuration with modules exclusions, I can't play with parent-first/parent-last classloaders anymore (I tried with no success), I have to deal with module exclusions only.

       

      Thx for your support,

        • 1. Re: EAP6: how to always prefer webapp's jars instead of JBoss modules?
          Tomaz Cerar Master

          if you need JPA2.1 and other EE7 related goodies, you might want to take a look at WildFly 8.x

          • 2. Re: EAP6: how to always prefer webapp's jars instead of JBoss modules?
            Jonathan Lermitage Newbie

            Unfortunately I can't (this is not my decision).

            There's no way to tweak class loading?

            • 3. Re: EAP6: how to always prefer webapp's jars instead of JBoss modules?
              Mustafa Musaji Novice

              but I still have to disable many other JBoss libraries.

               

              Which ones? You can tweak the classloading by installing your your custom modules, include them in your deployment, or simply use the ones that came with JBoss. There are options but it depends on what libraries you're trying to override and why.

              • 4. Re: EAP6: how to always prefer webapp's jars instead of JBoss modules?
                Jonathan Lermitage Newbie

                Actually, I don't want to force some libraries only, I want to force the entire content of my WEB-INF/lib. To be honnest, I know I have to load my own JPA implementation and the Jackson libraries, but there may be many other one like that (I have 150+ libraries for each project)

                 

                I work with Maven based projects, Spring Boot and a Spring Boot Parent Pom to manage dependancies (jars and their version numbers).

                My project is frequently updated and, unfortunately, I can't seriously keep up to date a list of libraries to include in a JBoss module. Also, I don't know if a future migration from EAP 6.4.0 to 6.4.x or 6.5 will include additional libraries I'll have to deal with. It's too dangerous.

                I'd like to proceed the same way I work with Apache Tomcat or IBM WebSphere. With Tomcat, there's nothing to do (but it's not a full JavaEE container, that's true). With WebSphere, I only had to declare a "parent-first" (or "parent-last", I never remember...) classloader to load my webapp jars first.

                 

                Is there a way to load my entire WEB-INF/lib jars first?

                 

                Regards,

                • 5. Re: EAP6: how to always prefer webapp's jars instead of JBoss modules?
                  Mustafa Musaji Novice

                  As far as I know as long as you are including only implementation Jar's in your WAR and not API's, WAR's are isolated by default as per the JEE spec so these should work fine with no additional configuration. This is why you needed to change things for JPA 2.1 to work and exclude specific API's and then include individual ones so there was no clash. Where you're going to struggle I think is when you try to override API's that are part of the JDK (which is not allowed) or implementation's not compatible with the version of JBoss API's (resulting in things like no such method exceptions).

                   

                  Jonathan Lermitage wrote:

                   

                  I can't seriously keep up to date a list of libraries to include in a JBoss module. Also, I don't know if a future migration from EAP 6.4.0 to 6.4.x or 6.5 will include additional libraries I'll have to deal with. It's too dangerous.

                   

                  Surely this is the same as keeping up to date with a list of libraries to include in your application? Further more, installing modules lets you use multiple versions of the libraries for applications. Your JBoss Modules should not be one module, it should be a module per library and this could easily be created as part of a scripted install. i.e. you'd have to do it once.

                   

                  I'd start by including libraries in your WAR and seeing what happens. It's going to be trial and error to see where any conflicts occur and trying to understand which API's are causing you this issue.

                  • 6. Re: EAP6: how to always prefer webapp's jars instead of JBoss modules?
                    Tomaz Cerar Master

                    well given that you don't use / need anything from JEE itself you could just go and disable/remove most subsystems that server provide.

                    this way you wont have many problems with clashing libraries.

                     

                    you mostly need web & naming subsystem and probably datasources one, others you could remove.

                    you can remove them in standalone.xml or via CLI.

                    or you can just add exclude-subsystem directives in jboss-deployment-structure.xml if you want to limit that to your deployment only and no server wide.

                    • 7. Re: EAP6: how to always prefer webapp's jars instead of JBoss modules?
                      Jonathan Lermitage Newbie

                      Thx for your answer.

                       

                      Yes, this is a possible solution; I am asking my customer to know if we'll can proceed this way.

                      The problem is they already have other webapps on their EAP 6.4. I don't want to break their websites

                       

                      I also read about upgrading the EAP modules with newer jar versions, but I still have the same problem: I don't want to break other webapps.

                       

                      Precisely, I am only working on new projects that I'll have to install on a EAP that already have other webapps (and they may use JBoss bundled jars). I have to be able to install my own application with minimum modifications on their EAP, and I can't use JBoss bundled jars.

                       

                      [edit]

                      I've tried to work with the jboss-deployment-structure.xml file. I am able to use my own JPA implementation, but I still have a lot of libraries conflicts. I have something like 150 jars in my webapp ant they are frequently updated. I can't handle it with this file, unfortunately. This is also a problem if my customer upgrades its EAP from 6.4 to 6.4.x or 6.5...., I don't know if I'll have to deactivate other JBoss modules. It's too dangerous.

                      I really need to be able to load my entire WEB-INF/lib jars. Is JBoss able to handle it?

                       

                      Thx,