Heroku allows the option of directly deploying one's Java .war file using heroku deploy:war (the Procfile is automatically managed by heroku in this case).
How does one use NewRelic with such a setup? The current documentation on Heroku DevCenter on NewRelic asks one to place the NewRelic jar in the root folder of the Java application.
How does one achieve this when using heroku deploy:war to directly deploy the app and not via git?
Following up on this question from New Relic support and adding clarifying statements to this old question. Unfortunately as far as I'm aware, it isn't possible to use the New Relic .jar file in an embedded war file without exploding the war.
On Heroku, using deploy:war simply wraps your war in jetty runner. An alternative would be to deploy an app that uses jetty runner by deploying source code instead of a binary. Instructions are here:
If you use the approach above, you should be able to add New Relic to your project.
I received this response from Heroku Support team:
WAR deploy doesn't specifically handle this case. However, it should
work. You can include the New Relic JAR in your WAR and add the
javaagent flag in your JAVA_OPTS config.
Related
We extensively use Java ServiceLoaders as a plugin infrastructure for our application components. We define interfaces, and then use the loader to load them at run time. Adding additional jars with extensions and service files are fine for our use cases.
However, i'm struggling to understand how we would be able to continue this approach while deploying an application within Wildfly. The intent is as stated above, the ability to add "extension" jars to the web-application class path without having to
Stop the server
Unzip the war
Add additional jar
Zip war
Start the server
In Tomcat, we could deploy web application folders instead of a war. So stopping the server, dropping in a jar, and starting the server worked fine. Within Wildfly (latest), it appears to not like the deployment of a folder vs war.
I've read about the modules approach, but have not been successful using this approach to get the deployed application to see the module from the service loader implementations.
Would like to know if there is an alternative solution or perhaps we are doing something wrong?
Thanks
WildFly supports exploded deployments with the deployment scanner or using the explode command with jboss-cli. Using the jboss-cli you can even update files remotely.
So I made a java web application with a normal pom.xml specifying my maven dependencies. Then, I went through the Heroku step by step tutorial on deploying their already-made web app, which did not help in the least bit. Then, I tried deploying the war, with no luck. Then I tried using the Maven plugin. I'm not sure if Heroku or some blog has a step by step guide on deploying to Heroku, but I need one. Can anyone go over what modifications need to be done to the pom.xml and what the procfile should be? And is it also necessary to have a main method in a java class? I thought each servlet was an entry point. My web app works fine on localhost and when I deploy the war on tomcat. It just doesn't work on Heroku no matter what I do to the pom.xml. I included my pom.xml. enter link description here
Run these commands:
$ heroku plugins:install heroku-cli-deploy
$ heroku deploy:war yourapp.war
Then read WAR Deployment on Heroku's Dev Center.
In my application I have three java modules. I have to deploy it into the tomcat server dynamically by selecting module 1 and module 2 or module 3. The selected modules will gets packaged and form a war file and gets deployed in server without restarting. How can I achieve this? Is there any Apache products/tools or any available to do this?
The products/tools you should look at is the Tomcat Manager. The default installation of Tomcat comes with the Tomcat Manager. As the names says it can manage (deploy, undeploy, reload, start, stop) applications for Tomcat without reastart. I'm not realy sure what are your needs and how your precondition look like, but i see four ways how you may can do this:
If you already have a WAR, you can simply use the Tomcat-Manager via a Browser. Just call the manager URL (e.g. http://localhost:8080/manager/html). There you have options to upload a WAR and undeploy a application. (Before you can login, you have to edit tomcat-users.xml - just google a bit).
Use Apache Ant. Ant is a XML-based build tool for Java. With Ant you can compile your SourceCode and pack it into a WAR. If you tomcat runs local, you can copy the WAR via ant in the webapps directory of the Tomcat. Tomcat will auto-deploy it (if auto-deploy is active, as it is by default). And if you remove one WAR from webapps, tomcat will auto undeploy.
Tomcat provides a library with ant commands, to deploy the WAR via HTTP over Tomcat-Manager to the server (Tomcat Ant Commands). So if the tomcat is remote, use this command via ant.
You don't like Ant? Use the Tomcat Manager direct via HTTP. (HTTP Commands). Of course than you have to compile and build the WAR on your own.
I hope it is usefull for you.
I've developed a small MVC project using Spring MVC, Hibernate, MySQL, Maven and Tomcat. I can run and test the application (locally) smoothly.
Now I need to publish/deploy this project on an (online) server that have only Tomcat installed on it. How can I publish/deploy the project online? Is there any special build I should do? What files I shall upload and to where?
There are several types of development options available.
For development on localhost EAR (Exploded ARchive) type of project is usually used (because you can easily make hot deploy on servery). But for production WAR (Web ARchive) is used (basically it's the same EAR archive, but compressed using ZIP algorithm).
If you want to deploy your project to remote Tomcat server then make your project as WAR archive and upload it to Tomcat's webapps directory. Then you might need to restart Tomcat. But it's manual way of deploying.
Better option is to use automated build tools (like Maven) which can compile your project, run unit tests, deploy on web server (local or remote) etc.
This one is a great example of how to deploy your project on Tomcat server by using Maven's tomcat-maven-plugin: http://www.mkyong.com/maven/how-to-deploy-maven-based-war-file-to-tomcat/
Good luck ;)
Do a mvn clean install and you will get a .war file in your target directory of web module.
Copy it and paste it in tomcat_home/webapps directory and restart tomcat. Thats it. now, you can access it in whatever configured port (eg: http://localhost:8080/<your webapp war name>). lets say your war name is myapp.war, then tomcat would have extracted it into myapp folder in webapps.
so your url will be http://localhost:8080/myapp
With maven deploy command, usually gets errors for various reasons.
if you work in Unix/Linux system, I recommend using "rsync" method on console. (You can write own shell script to manage easily). It helps not only deploying without a problem but also helps to get time while redeploying (only uploading changed / new files). Because maven deploy / redeploy uploads your project as a bundle in jar/war. However "rysnc" method uploads your project files one by one.
Before using it, you should sure that two conditions.
1- your project is built in target folder (Spring Tool Suite)
2- you have access to tomcat via ssh
example code : (v_ : prefix which is variable(customizable))
rsync -avz v_your_project_in_target root#v_ip:v_tomcat_name/webapps/v_project_name
(Second sharing)
I have a repository on GitHub. It consists of 3 projects. Main web application and libraries. Main application is jar with embedded Tomcat. I would like to deploy main application on Heroku. Can I deploy just prepared jar? If so how?
While it is not recommended to check in binary files (e.g. JARs) into a Git repo, you can try using the third-party Null Buildpack to have Heroku just deploy your repo as-is without compilation. You'll still need to have a Procfile to tell Heroku how to launch your application.
Besides the problems with checking in JARs, this method will also not be running your application on the latest patch JDK. If you want the best of both worlds, you'd need to make your own custom buildpack that downloads the JDK, similar to what the Java Buildpack does.