My main problem is I have to sign all the JARs of WEB-INF\lib folder.
So this is what I have done:-
Enabled archiveClasses option to package classes also into JAR
Added JAR-Signer Plugin and setting the archive directory to ${project.build.directory}\${project.build.finalName}\WEB-INF\lib
After package finishes, I can check that in target directory all JARs in lib folder are signed but my war file contains unsigned JAR only. Most probably because the jar-signer executed after maven-war-plugin has created the war file.
I tried with setting JAR-Signer to pre-package phase also, but the lib folder is not present by then.
So what I need is to execute Maven JAR-Signer just before maven creates the war file from target directory.
Thanks
Related
I have a standard java application that I'm building with Maven. It includes a few files under src/main/resource directory. At present, those files are being packaged inside the JAR fiel that is produced, which I would expect, but is there a way to configure the maven assembly plugin to package those files outside of the JAR file, or can I achieve that with another plugin (resources?)?
The packaging of pom.xml is war but I need the compiled webapp folder (with html/css/js/jsp, resources, classes and lib) only, because I will do some modification and package this folder programmatically and packaging this folder into war by maven waste time.
Can I skip generating war file by mvn clean package?
if you want skip generating war file you can use war:exploded plugin
after that, you can run mvn clean compile war:exploded
I am trying to create an EAR file from the command prompt. I have used
jar -cvf myServletWAR.ear .
But my question is, how can I get this EAR file to have WAR files and JAR files inside it?
Do I need to create the war file separately and include in the ear file?
I can't use the ANT file for this, as there are few restrictions on this project.
One of my EAR files has structure as follows:
app.ear
- APP-INF
- lib
// libraries (.jar) here
- META-INF
- MANIFEST.MF
- weblogic-application.xml
- module1.war
- customlib.jar
This archive is being deployed onto WebLogic 10.3.
Remeber .ear is just a ZIP file, so you can always create it this way, although it seems messy.
check if jar cmd is working if so, create the jar of your class files and descriptors etc.
After that jar -cvf <<earname>> <<files want to be in the ear >>
Could you try this :
jar -xvf myServletWAR.ear
You could also refer to :
How to add a WAR file into an existent EAR file? and how to I have two .war files within one .ear file?
You would have to add these EAR file references in the application.xml of the ear file.
If you have generated a client and EJB together, they are automatically packaged into an enterprise archive file (.ear) and you do not need to do this. Otherwise:
Package the EJB's .jar file into an .ear for your application. To do
this use a jar command similar to the following:
jar -cvf myApplication .ear myService.jar
If you have a client .war file you can add that to the .ear file in the same way.
Create a deployment descriptor application.xml either using your
application server's tools or by copying and editing a sample, as
follows:
Locate a sample .ear, which is in examples directory in
mapdemo/mapdemo/repos/myService.deploy/JMapServ-WL.ear
Extract the descriptor application.xml from the .ear file, using the following jar command:
jar -xvf JMapServ-WL.ear META-INF/application.xml
Make a copy of the application.xml descriptor and edit it, replacing JMapServ with the name of your .jar file. You can also add the name of your .war file if you added that to the .ear file.
Put the descriptor in the meta-inf subdirectory of the directory containing your .ear file.
Package the descriptor into your .ear file using a jar command similar to:
jar -uvf myService.ear META-INF/application.xml
If you want to create an ear from the command line, following are the options that you can try.
Option 1. Using an ant build and use the ear task. Configure this ear task as stated in stackoverflow question on ant ear task usage
Note: Maven based build is preferred over ant these days.
Option 2. If you can use maven, configure your modules and use maven ear plugin to generate an ear. The below command will be able to generate the ear.
mvn clean package
Refer to the maven question regarding a Java EE project for more information on configuring war, jars for an ear.
.jar file into an .ear
jar -cvf myApplication.ear myService.jar
.war file you can add that to the .ear file in the same way.
Refer http://supportline.microfocus.com/Documentation/books/sx51/thdpoy10.htm
I needed to add external jar files to a EAR Project.
I did add but the jar files are not reflecting in the lib directory, it is showing below to lib directory.
I added these jar files on right clicking on Deployment Descriptor, Import-> Java EE Utility Jar and choosing to copy from the folder.
When I dragged the jar file on the lib directory the velocity jar file gets changed to .ear file in the eclipse project explorer.
I have attached a snapshot of the project explorer. Could you please let me know how to add external jar files to ear project as my EJB requires external jars to be included.
I have even added classpath for jar files in my EJB manifest file
Class-Path: ErpServices-ejb.jar velocity-1.6.4.jar velocity-1.6.4-dep.jar xwork-core-2.2.1.1.jar
Looking forward to your reply. thanks.
Add those jars under folder EarContent/lib directly , then all is done.
I.E., EarContent/lib/foo.jar will work but EarContent/lib/dir/foo.jar won't.
A similar question : here
Just try project root folder right click properties -> build path -> add external jars
Instead of drag-and-drop, add it to the lib folder manually (outside the IDE), refresh the IDE, right-click the EAR project and in modules and dependencies, make sure that it is included in the lib folder and as a dependency.
I am trying to build java client for rabbitmq.
I have my source folder as A.mq.client.
Also I have a libs folder where I have my rabbitmq jar files. These jars have been added to build path. Everything works OK in Eclipse.
Then I export the entire project in eclipse as jar. jar contents are .classpath, libs folder and my package folder + rest of stuffs.
Now I am getting exception :
java.lang.ClassNotFoundException: com.rabbitmq.client.Consumer
com.rabbitmq.client.Consumer is in lib jars.
I am running jar using java -cp rabbit.jar A.mq.client.Worker where I want to invoke main method of worker class in my package and Worker is accessing jar packages.
As far as I know, you can't generally package jar files inside of another jar file. Typically, you would have to expand all the various dependent jars prior to packaging up your final jar. If you've ever used Maven, this is what the maven-shade-plugin helps to automate.
See the answer in this question for more information.
The CLASSPATH lists places, where the classes are found - either in a directory or in a jar, but not
directories of directories
directories of jars
jars of directories
jars of jars