how can I deploy a WAR file to Wildfly? - java

In relation to deploying a WAR file to Wildfly, where should the file be copied to?
I don't see where the file is:
thufir#dur:~/java/wildfly$
thufir#dur:~/java/wildfly$ tree wildfly-17.0.0.Beta1 | grep wildflyMaps.war
│ └── wildflyMaps.war
thufir#dur:~/java/wildfly$
seems to be exploded for deployment:
Re: Can't see the .war after deploy ehugonnet Apprentice ehugonnet 21-Aug-2017 2:47 AM (in response to Claudio Miranda)
During runtime the enabled war files are exploded by vfs in the tmp
directory. Those files will be deleted on stop / restart / disable.
The reference content is in the content data directory for recreating
the tmp files.

Standalone mode
The standard location for deployments in standalone mode is Wildfly_Home/standalone/deployments so you can copy your war to that folder via Java or any other means. It will deploy then upon starting the server. And actually it will auto-deploy even while Wildfly is running (and if not, just create a file and call it wildflyMaps.war.dodeploy).
Domain mode
With this, you can't just copy a war file to a directory. It can be done via the cli, but easier is to log on to the management console and go to the deployments section.
Once deployed, if you open up the domain.xml, you'll see something like this:
deployments
  deployment name="wildflyMaps.war" runtime-name="wildflyMaps.war"
   content sha1="d991471f79045413a7c63b8c2b5d4dc345be8808"/
  /deployment
/deployments
And using the above example, you'll find the deployed file at:
Wildfly_Home/data/content/d9/91471f79045413a7c63b8c2b5d4dc345be8808
and in there has a file called content. Copy that elsewhere and rename it as anything.war and you can open it and see that it is the war that you deployed.

Related

How to run war file without using eclipse

I have done a maven project in my eclipse and was generated a war file in my system.I want to run that war file in another system without using eclipse.Is it possible to run without downloading JDK and eclipse..
You can refer the following link to run WAR with tomcat -
Deploy war in Tomcat
or a video - Deploy the war in Tomcat Video
Well, if this suffice your requirement, it is good else please mention the specific issue, if there is that you are facing.
The .war file stands for 'Web Archive'. This is a packaged web application, which can be run by an Application server (Examples: Glassfish / Tomcat / Weblogic, Wildfly)
The process of making an application server run the .war file is called Deployment.
For example, a .war file can be deployed to Tomcat application server (I.E., made to run by tomcat) by simply copying the .war file to the /webapps folder of Tomcat.
Here are the steps to deploy .war file on Tomcat:
Step 1: Build the .war file for the web application.
Suppose that the .war file is "my-app.war".
Verify that the my-app.war file contains the following:
/WEB-INF/ folder and
/WEB-INF/web.xml file
Step 2: Verify the following settings in Tomcat config.
(This step can be skipped if Tomcat was installed with default settings)
autoDeploy : true
unpackWARs : true
(Note: These are default values. These will be set to true if Tomcat is installed with default settings.)
Step 3: Remove any conflicting entries or stale entries from Tomcat config.
For example, if the new app to be deployed is 'my-app', then make sure that the existing config of Tomcat does not have 'my-app' already registered for another application.
This can be checked by trying to browse http://localhost:8080/my-app.
If this link works, then it means that the name 'my-app' was already taken.
Another way to find if the name already exists:
If Tomcat is installed in "C:\Tomcat8",
then the registration for 'my-app' can be found at
C:\Tomcat8\conf\Catalina\localhost\my-app.xml
Step 4: If steps 1, 2, 3 are cleared, then copy the my-app.war file to 'webapps' folder of Tomcat.
If Tomcat is installed in "C:\Tomcat8",
then the my-app.war file can be copied to
C:\Tomcat8\webapps\my-app.war
Step 5: Wait for Tomcat to automatically detect my-app.war file inside webapps and extract it to webapps/my-app folder.
Tomcat usually does this automatically. However, this process may sometimes not work either due to file permissions (Example: User does not have write permissions on webapps folder, or Tomcat is installed to C:\program files, which has read-only permissions) or due to folder being locked.
Try restarting the Tomcat service to fix the issue.
If restarting Tomcat does not fix the issue, then verify permissions of Tomcat service and re-install / execute Tomcat with the necessary permissions.
More information:
https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Top-5-ways-to-deploy-a-WAR-file-to-Tomcat
https://tomcat.apache.org/tomcat-8.0-doc/deployer-howto.html
https://dzone.com/articles/how-deploy-war-file-using
https://developer.jboss.org/thread/268260

Web Deployment Assembly not used by Tomcat7

My understanding is when running tomcat inside of eclipse, during publishing... eclipse will copy files based on the settings in Web Deployment Assembly to tomcat directory. I added my app to Tomcat 7 thru Server --> "Add or Remove...", when I start tomcat, I don't see any files been copied to /usr/share/tomcat7/wtpwebapps/myapp folder. BTW, I have all the folder structure (folders) under tomcat directory, but missing all the files (like .class, .properties, .xml and ...). This is the error I am getting when start tomcat. BTW, the directory show in the pic is the directory under tomcat. I thought the publishing process copies files from eclipse to tomcat dir? It looks like it's trying to copy files from tomcat dir to somewhere else. What am I missing? My Server path and Deploy path are all correct.
It's a permission thing. Also I recommend install tomcat manually instead of running apt-get.
Either https://askubuntu.com/questions/17223/permissions-problem-when-copying-files-to-usr-share-tomcat6 or http://www.frattv.com/tomcat-can-t-start-from-ide-eclipse-luna-wtp-intellij-idea-in-ubuntu/ will work.

Precompiled ROOT.war for Openshift not being deployed

I need to have my precompiled ROOT.war deployed in my Openshift app.
Under the complete path of the war is /deployments/ROOT.war
I've checked this war file before doing git push that the /app/app.nocache.js is there. This js file is there in the index.html. Now when I access the app online, the index.html cannot find this js file. So it means the pre-compiled ROOT.war was not deployed, instead it seems it built a new ROOT.war.
What am I missing here?
remove pom.xml and src folder from your cloned repo as corey112358 said
then put your war file into webapps folder (direct subfolder of your repo)
do the git:
git add --all
git commit -m"another commit"
git push
watch the output for "found port..." to make sure your tomcat restarted fine
Remember that the war file does not get expanded (unzipped) in openshift.
Try reading through this article on help.openshift.com about deploying pre-compiled war files and see if that helps (https://help.openshift.com/hc/en-us/articles/202399740-How-to-deploy-pre-compiled-java-applications-WAR-and-EAR-files-onto-your-OpenShift-gear-using-the-java-cartridges).
You are possibly not removing the pom.xml and src directories if it's building a new root.war file.

Deploy Java Web Project on Tomcat without WAR or EAR

I have a Java Web project (Struts + Spring) working perfectly in my localhost. I have to deploy it on my website, but the Tomcat Manager interface given by the webhost says it cannot upload a WAR file due to safety reasons. When contacting the tech support I was told it is not possible to upload a WAR and that I should try deploying my project by uploading the files directly (I have FTP access).
My problem is that no one at the tech support gave specific instructions on where I should put my project files (I don't know if it should be on de same folder the WAR would be sent to) neither how to start/stop it (Will the Tomcat Manager recognize it once I upload the files?).
You can always try to upload a war file to webapps folder of tomcat.
if tomcat is running with autoDeploy set to true it will auto deploy your application.
i think that the same will happen if you upload the exploded war to the webapps, the context will be the name of the directory you put your files in.
Just place your apllication's root folder to the Tomcat's directory webapps and configure tomcat to auto deploy. Restart the server and your application will be deployed.
You transfer the files to the same place as the war file would go - but just as an expanded war.
Whether or not tomcat will recognise that the files have changed depends on the configuration of the tomcat server. I'd just give it a go - transfer the files and see what happens. If it doesn't pick up the changes then you'll need to find out from tech support how to restart tomcat.

Problem updating existing webapp in Tomcat 6.0.20

In Tomcat 5, I would build a WAR file and place it on my test server. On this server there was a my-app.xml file in the CATALINA_HOME/conf/[EngineName]/[HostName] directory that pointed to my test database. Once I finished testing, I would send the WAR file to my clients IT department and they would put the file in the CATALINA_HOME/webapps directory. On their instance of Tomcat, they had a different my-app.xml file that pointed to the production database.
Recently we upgraded to Tomcat 6, when either of us copy the WAR file into the webapps directory, it deletes the my-app.xml file. After it is deleted, if I copy a backup of my-app.xml file into the CATALINA_HOME/conf/[EngineName]/[HostName] directory, Tomcat ignores it, even if I reload the webapp from Tomcat Manager.
I tried adding a context.xml file to the META-INF directory in the WAR file. When Tomcat was expanding the WAR file, it would overwrite the my-app.xml file with the context.xml file. If I then copied the backup of my-app.xml file back into the CATALINA_HOME/conf/[EngineName]/[HostName] directory, Tomcat deletes the WAR file and the expanded directory.
I can include the appropriate my-app.xml file inside the WAR file, but this means building two WAR files, one with the test my-app.xml and one with the production my-app.xml. I also can get it to work if I copy the WAR files or the my-app.xml backup files in a specific order into the correct directories. I am not fond of either of these solution for multiple reasons.
What am I doing wrong? Why does this not work in the new version? Do I need to change an option? Do I need to change my process? (NOTE: The client's IT department does not want to have to stop and start Tomcat to redeploy a new WAR file.)
Thanks!
It sounds like Tomcat's auto-deploy is interfering with your manual deployment. Try either deploying your WAR file to another directory (i.e. not the webapps dir) or turning of autoDeploy in your server.xml. There's some more notes here: http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Automatic%20Application%20Deployment.

Categories

Resources