Gradle WEB-INF/classes folder - java

How can I create WEB-INF/classes in war when I don't have anyone?
In my war I have only web.xml.
I need this because jboss. It cannot deploy project without this folder.
I need gradle configuration.

Add a fake text file to src/main/resources, and it will end up in WEB-INF/classes. Explain the purpose of this file by writing it in the file.

Related

Ant build.xml ear generation

I have a j2ee application. That application is packaged as ear file. Inside that ear file there are two wars. Can anyone guide me that how I create an ear file consisting those war's inside that ear with ant build.xml script.
You can use command line to create EAR using below command:
jar -cvf <<ear file name>> <<war files to be included>>
You can also refer to question how to create ear file, and include war and jar files inside that.
Also, if you want to do it using build.xml, you can refer How do I create an EAR file with an ant build including certain files?
I hope it helps.

Maven war plugin - including other files in WAR

I am building an Maven based Java web-app. In my src/main/java/package folder I have a .xml file and a .properties file that needs to be included as a part of my war. However when I look at the war file that gets generated (using a maven install) this does not include the .xml and the .properties file. It only contains the .class files from the package.
Is there anyway of including these files in the war ?
In addition, I also checked under the target/classes folder, here again the .xml and .properties files are not included.
Put your .xml file and .properties file in resources folder of your project, by default Maven will pick it up from there.
Little more googling around stackoverflow got me the answer. I just had to change the default resources folder for maven as outline in the following stackoverflow question Why does maven not copy the properties files during the build process?.

how to create ear file, and include war and jar files inside that

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

How do I package a web fragment in a jar with Netbeans and Maven

When selecting a new maven project from the Netbeans New Project Menu, there is the option to create a Web Application, or a Standalone Application. I'd like to create a Class Library for use with a Web Application.
How would you recommend I go about this. I see the new Servlet 3.0 Web Fragments need to be put into the META-INF folder and saved as web-fragment.xml. I'm not too sure where I'd create this directory if I'm packing a JAR and a WAR.
Some insight would be greatly appreciated.
You can create either Java application or Web Application. Just place the META-INF folder in the src/main/resources folder. and place web-fragment.xml directly under it. You can also place any images,css or javascript files in META-INF/resources folder. So when the application you are deploying this for will look in the WEB-INF/lib folder and load all the META-INF contents of the jar onto the classpath.
when generating the .war file with standard maven settings (no special config of maven-plugin-war) the web-fragment.xml should found in the /META-INF dir of the generated JAR file inside the WAR's /WEB-INF/lib dir.
in our case the web-fragment.xml was not in this dir but in the WAR's /META-INF dir, which is the wrong place

jar file in persistence.xml not loaded by glassfish

folks,
i understand this is a silly question... bt i am so new to glassfish...
i have got an ear to deploy to deploy in glassfish 3. the ear has a jar and war inside already. the jar is a JPA jar and it has persistence.xml file. i have added a jar-file entry to load inside the persistence.xml file, with a jar entry which is not in the ear to be deployed. Where should i put the jar for glassfish to load it
( i have tried putting it in all lib folders in the glassfish dir and even inside various places in the ear only. there is something with lazy deployment i guess... so please suggest me a way to somehow solve this.)
thank for your time,
rajan
okay, what i did was created a lib folder inside the ear, put the additional jar there and in the persistence.xml file inside the ejb jar, i had set the jar-file value as lib/jarname and it recognized...
thanks for yure time guys...
rajan...

Categories