0

I started building my web application using the architecture of JBoss7.1 quickstarts.

I like it but now I need to add some libraries to my project, so I add several dependencies to pom.xml. For example, this is for JasperReports:

<dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>5.0.0</version>
        </dependency>

And so on, for other libraries. Unfortunately after building my project, I notice that the war's size produced by "mvn package" is.... 36MB?!? That's too much, I have to upload that thing to a remote server, quickly!

The bulky stuff is all stored inside /WEB-INF/lib and is indeed a set of JARs (the libraries I've included as dependencies).

What's the best practice for not having to include each time that unnecessary payload in my war?

I imagine I should include somewhere in JBoss environment the JARs and declare maven dependencies in a different way, maybe... but how?

Fabio B.
  • 9,138
  • 25
  • 105
  • 177

1 Answers1

0

You could use Jboss as 7 module system to put some dependnecy as JBoss module taking away from the war.

For an example on how to create and use a module you can look at this blog post.

In pom.xml file you should add a scope element for the modulerized jar with provided as value (should already be present for the Java EE depedencies). This will tell maven that the jar will be provided by the environment, no need to put them in the war.

This technique will make your war lighter, but you will lose maven management of the runtime depednecies. You will have to make sure you have the correct version on all the server the application will be deployed.

Kazaag
  • 2,115
  • 14
  • 14
  • Thank you but what do you mean for module? Do I need to create a new project with only libraries dependencies and add it as a dependency to the main app project? – Fabio B. Feb 04 '13 at 08:31
  • JBoss module are the new way JBoss handle call loading isolation of the different part (internal, extrenal) of the app server to prevent class loading issues. You need to put your jar in a specific folder with correct xml file to create a module. In JBoss deployment xml file in your war WEBINF need to reference the module. Every thing is explain in the link you can find in my post. – Kazaag Feb 04 '13 at 17:02
  • You can look at this question that have more detailed answer: http://stackoverflow.com/questions/8289813/best-practice-for-loading-3rd-party-jars-in-jboss-as7-standalone-deployment – Kazaag Feb 04 '13 at 17:36