Search code examples
springmavenwebsphereearfilesize

How to reduce the size of ear file


The size of my EAR file has reached around 100 MB after adding many exetrnal jars.

Environment : Java Spring/Websphere application server/Maven

Please share the tips to reduce the size of an EAR file.

Seems the exteral jars contribute most to the large size. Is it possible to follow an approach like below, if so how to do that?

  1. Do the maven build with compile scope for large jars
  2. Keep the large sized jars in app server lib, with this will the app take these jars at runtime from appserver?

Thanks Smitha


Solution

  • You should really review your jars, especially poorly done Maven builds add a lot of unnecessary jars to the application (like jta, servlet, jee-api, etc..), so make sure you don't have them. Sometimes jars are duplicated in every web module you have in the EAR.

    Second WebSphere is Java EE 6 server, so it provides lots of common features like JAX-WS, JAX-RS, JPA, etc..., so you should consider using them, before throwing all that as third party libraries in your application.

    If you want to use shared library approach, do not put the jars in the server lib folder or server classpath. This is not recommended.
    Create Shared library via Environment > Shared libraries see here and assign them to the application.