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.
Related
I need to deploy my application in an embedded solution (running on a raspberry pi zero). As such, I only really can deploy things on localhost. I am not too familiar with virtual hosts, so I may be wrong on this.
My problem is that I want tomcat to auto-deploy the war file that is contained within the git repository I cloned onto the raspberry pi. This is so that updates can be made over the git respository easily instead of having to deal with the manager. That being said, I also like to keep the manager and other admin tools active and working which are contained within the default webapps directory. Copying these into the git repository is not something i want to do as they will be misplaced and kept in the repository which is not necessary. Furthermore, I want tomcat to "explode" or extract the WAR files in the original webapps directory, as to not add these files to the git repository.
Basically I want to be able to auto-deploy all war files in a certain directory without that directory being actually being written to and while also auto-deploying the war files in the "standard" webapps directory.
Is this possible?
Im using tomcat9
Solution A:
Tomcat 9 has only one appBase attribute, which by default is the webapps. In order to change that you need to configure 2 Common attributes :
1.appBase: Set this parameter to the folder where the war that needs to be deployed is located.
2.autoDeploy: Make sure this is set to true.
It is not possible to have 2 appbase directories. So the original webapps will not work for autodeployment.
Solution B:
Use a script to pull the WAR from the GIT repository, that will also copy or move the file to the standard webapps folder of Tomcat9.
e.g.
git pull rm path/to/tomcat/webapps/warname.war
mv warname.war
path/to/tomcat/webapps
Solution C:
Configure your GIT repository or another GIT repository to just include webapps folder with the desired war. If you use this folder only to pull the war from your GIT repository you do not need to commit the default Tomcat apps. See the following steps.
Starting from a vanilla Tomcat 9 installation
Rename webapps to webappsOriginal
Clone the webapps repository so that another webapps folder is now created, containing only the war.
Move all contents of webappsOriginal to webapps.
Delete webappsOriginal
Now if you pull from the repository the updated war will be fetched and autodeployed.
There is no reason to add, commit or push the prexisting files in your GIT.
How about using "inotify" to watch over the war directory in the cloned repository and if it changes copying the war into the "webapps" of the tomcat which will autodeploy the changed application. You can install inotify-tools for this. Check here for more on this.
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.
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.
I'm new to tomcat and maven configuration. I was given a single .war that has all the dependencies in it. I'm trying to figure out how to run the war file on a given port configured using a pom.xml file
I tried mvn tomcat:run-war where the .war file lives but it obviously needs a pom.xml How can I configure this to be able to run this?
If you have already compiled project with all the dependencies in it then it has nothing to do with maven (because it's a tool for building projects from source code).
In order to deploy a war file you should install standalone tomcat on your system and drop the war file into webapps directory in the tomcat installation home folder, then (re)start tomcat. Give it 20-30 seconds to launch and open http://localhost:8080/war-file-name-without-dot-war in your browser, if everything went right then you will see the deployed application.
I have quite an interesting issue. I'm running maven to compile my Servlet site into a single WAR File. This works completely fine on my local machine; and even when I change my deployment settings to use just the war file, it works fine. However, when I deploy the WAR file to the server, I'm getting 404 errors. I'm no expert with WAR files, so is there some sort of internal file that specifies the location of resources that I need to look at?
First try to unzip your war (wars, jars, ears are zip files) and see if your files are actually there, verify if your unzipped war contains:
dir WEB-INF
file WEB-INF/web.xml
dir WEB-INF/lib with the jars your aplication depends on
dir WEB-INF/classes with *.class files, where your servlets and related classes are supposed to be (if you have decided to have them there and not in a jar in WEB-INF/lib)
static resources in the root directory
You could make your conclusions of what is missing in your war.
You could also try to build your own war manually (creating a zip file with the structure I mentioned above and renaming it as *.war) if you have problems with doing it by your IDE's options