What is an exploded EAR? - ear

Can someone please explain what's an exploded EAR ? I checked in google but couldn't find a clear answer.
Is it a different format?
What's the difference to a non exploded EAR?

A compressed EAR file, with extension .ear is just a ZIP file containing the directory structure of a JEE project. It is normally used in order to deploy a JEE project.
An exploded EAR file is just the uncompressed content of the above.
Incidentally speaking, war and jar files are also compressed in ZIP format.
The use of the wording "Exploding" instead of "decompressing" a ZIP file seems to be traditional in the java community, and is present in official documentation.
E.g.: www.java2s.com/Code/Java/File-Input-Output/classforexplodingjarzipfilesontothefilesystem.htm (on a IBM contributed source file belonging to Eclipse ).
They can be exploded with the jar command.
You can also use any compression utility, provided you keep the directory structure intact.
e.g.:
jar xvd /myapp_path/myapp.ear

Related

How to copy directories into WAR using Maven?

My goal is this: I have 2 directories (not their contents but the directories themselves) which I need to get copied into both the exploded WAR directory and the packaged WAR.
Specifically, I need the following directories inside the final WAR:
${project.basedir}/web/WEB-INF/templates needs to get copied into
target/${finalName}/WEB-INF/
${project.basedir}/web/WEB-INF/classes/dao needs to get copied to
target/${finalName}/WEB-INF/classes/
So far, I haven't found any way of doing it. I've tried the resources plugin, the war plugin's webResources feature, antrun, exec-maven-plugin, etc., and each have limitations that prevent the aforementioned directories from ending up in the final WAR. In some cases the resultant directory structure ended up with too much nesting (e.g.: target/${finalName}/WEB-INF/classes/WEB-INF/classes/); in other cases nothing got copied at all, presumably because the war plugin has its own beliefs about what should and should not get copied.
As such, I'm at my wit's end. Is there any way to copy actual directories without having the war plugin question my motives? I wish I could tell Maven, "Do as I say!"

Wrapping a text file in a war and in a jar format

I have a springboot program that reads from a text file present inside the project. I use eclipse IDE. I want to share the project. While packaging the project in war format the text file was missing. Can someone tell me how do I package it so as to have the text file inside the package ?
I want to know the steps for both war and jar packaging which will include the text file in them.
This will let the user who unpacks it finds the text file and it can be used by the springboot service directly.
Thanks
Put any resources (files) used at runtime in src/main/resources. They should be available in all packages.

Websphere liberty profile 16.0.0.4 deployment issue (ZipException)

We are using Websphere liberty profile 16.0.0.4 to deploy EAR application.
Nothing jee specific. the EAR has a simple WAR file. We put the EAR file inside
the dropins folder and it seems like websphere is extracting the content of EAR
file inside the workarea directory.
When reading the content of one jar sqljdbc.jar it puts the jar inside cache
folder. However the sqljdbc.jar seems to be a 0 sized file.
Here is a sample path to the sqljdbc.jar. All of them are directories
D:\comdata\wlp\usr\servers\defaultServer\workarea\org.eclipse.osgi\121\data\cach
e\com.ibm.ws.app.manager_88\Tax2290.war\WEB-INF\lib\.cache\sqljdbc.jar
The sqljdbc.jar inside sqljdbc.jar folder above turns out to be 0 byte sized.
Because of this ZipException is thrown.
There is also this exception thrown before the ZipException. I am not sure if
it is related to this or not.
java.lang.ClassNotFoundException: iconnectlogout
com.ibm.ws.jaxrs20.server.component.JaxRsWebModuleInfoBuilder
What are these org.eclipse.osgi, cache, com.ibm.ws.app.manager_88 folders.
We checked the WAR file inside EAR and it has the right sized sqljdbc.jar.
any ideas why this is happening? Is anything getting downloaded from internet?
Proxy / firewall issues.
First Edit:
-----------
Uploaded the problematic ear file.
Here is link to problematic ear file
https://wetransfer.com/downloads/3585882e88626f6e5a480075fba0c48e20170118170610/43e43f
The sqljdbc.jar file in the Tax2290.war's WEB-INF/lib directory contains an embedded JAR file with the same name - and that embedded sqljdbc.jar file is 0 length - with another another file, sqljdbc.jar.old, that seems like a valid archive. It is this embedded JAR file that Liberty is choking on.
You should be able to resolve the problem by removing that 0 length JAR file from the sqljdbc.jar -- or by replacing it with a valid JAR.
That said, Liberty should probably provide a better error message or be able to handle this case better, so I would suggest opening a PMR with IBM support to have this addressed.
Thanks, Andy

Maven. How to create .jar with local .txt files

I use Intellij Idea.
Java-classes use .txt files which are placed in folder where .java files are situated.
I created .jar file with maven and pom.xml. But there are no .txt in .jar file.
How to add them there?
UPDATED:
I have such structure src/main/java/Project-name/ for .java files. And src/main/resources/for .txt files. Within .java files I access files as ../../resources/filename.xml and all works fine. But .jar-files created with maven says:
Unable to open "../../resources/filename.xml"
How correctly should I declare filenames?
You are going against the convention. Java source goes to src/main/java but your resources must go to src/main/resources. The rest ist handled by Maven.

How do I add a directory in /target to the resulting JAR with Spring Boot?

I'm using Enunciate to generate REST documentation upon building a REST application. Enunicate outputs documentation to /target/docs. I would like to add the /docs directory to the resulting JAR file (and rename it) to be able to serve docs as static content.
How do I do this? I can't figure out how to get these static files (which are generated upon build) into the JAR.
I guess you can solve this by configuring the Maven plugin for enunciate and wiring it up to be run in the 'generate-resources' lifecycle phase.
Also, make sure you set the output-dir to a subdirectory of src/main/resources/static, as commented by Rob above.
I added this to my enunciate.xml to force the docs directory to be generated in a custom location which will be packaged with the .war file
<docs docsDir="target/<app_name>/docs"/>
and then maven will put the entire contents of target/ into the resulting war file package

Resources