I have successfully installed apache tomcat & verified it to be working using the curl command
curl http://localhost:8080/
Tomcat is installed in
/var/lib/tomcat8/
webapps/ROOT/index.html
webapps/ROOT/META-INF
lib
I have received following structure of the java app in a zip file
App/
build.xml
deploy.sh
run.sh
www/
*.jsp files
WEB-INF/lib/*.jar files
I want to install and run this app on my server. How can I do that. Specifically I want to know where to place these folders. Do I need to run any of the deploy or build files. Do i need to install the jar files? If I directly run one of the .jsp files from curl command, it crashes due to missing java class.
Perhaps I am missing something obvious but I am new to java env and could not find it from google.
If you haven't tried it yet, consider using Maven to build your projects.
This will automate and simplify a lot of similar work for you, like creating a .war file and deploying your project to Tomcat. With Maven, you have to set the <packaging>war</packaging> in pom.xml (a project configuration file) and run mvn tomcat7:deploy command.
For details look at the above link to Maven docs or for instance check out this tutorial.
You can also use the Tomcat Manager under (default) http://localhost:8080/manager to deploy the .war file manually.
Related
I have a Maven project which I need to run from VSCode. Right now the way I do it is:
Open the project folder in VSCode. Edit the java, js, html files etc.
Start my tomcat by running bin/startup.sh; tail -f logs/* ; in the apache tomcat's directory.
Open terminal in the project directory and run mvn clean install -DskipTests.
Then run cp /Users/path-to-my-project/target/myWebApp.war ~/apache-tomcat-8.5.23/webapps/ to copy the war file into the tomcat's webapp directory.
After which I can access my web application at localhost:8080/myWebApp.
Is it possible to do all of this in one click (or command) in VSCode. I know it can be done in Eclipse or IntelliJ but I want to work with VSCode.
I have installed the Spring Boot Extension Pack and Java Extension Pack in VSCode. I am just confused on how to setup the path to my tomcat, build the project and then copy the war file to the tomcat webapps folder.
Is it possible to do all of this in one click (or command) in VSCode. I know it can be done in Eclipse or IntelliJ but I want to work with VSCode.
To make your webapp visitable, just type:
Ctrl+`
in the VS Code to get a terminal, and then type:
mvnw spring-boot:run
in the application there is a suffix after the locahost:8080. So something like localhost:8080/mywebapp/...rest of the url. With the above method everything works but I loose that web app name suffix. Any idea how I can get it back?
In your application.properties file(in the src/main/resources folder in your spring boot project), add below line(for Spring boot v2.0.5):
server.servlet.context-path=/mywebapp
For older version, you may need:
server.contextPath=/mywebapp
See these links for reference:
How to set base url for rest in spring boot?
What is the purpose of mvnw and mvnw.cmd files?
how to run springboot app in visual studio code? is it possible or not?
Is there another way to run deployed spring boot application on server than *sh script?
My idea is create .sh script which will start app (java -jar name...). This solution is simple but have one disadvantage - I have application version in the file name. I can trust that there will be only one *jar file and run it - but I am not sure that it is best solution.
What do you think?
You could use maven-assembly-plugin to bundle your application jar and sh script onto one zip file. In this case you could use maven resource filtering to put replace ${version} placeholder in your sh with exact version of your jar during maven build.
If your jar has name like this: `my-project-.jar1 then your sh script will look like this:
java -jar my-project-${version}.jar
During build maven will replace ${version} with value from pom.xml.
So after build you need to unpack zip (or tar.gz) and execute sh script.
I usually use Eclipse and Google Cloud Tools plugin for Eclipse so I'm not really familiar with the command line tools. Now I have some deployment issues and I'd like to try to deploy using "gcloud app deploy".
I installed Google Cloud SDK and managed to run this:
cd D:\path-to-eclipse-workspace\my-project
C:\path-to-google-cloud\gcloud app deploy src\main\webapp\WEB-INF\appengine-web.xml -v v1
The deployment seems to work, but when I check on appspot.com my servlets are not there - I get: Error: Not Found. The requested URL /hello was not found on this server.
Thanks!
Update:
It looks like Eclipse is not putting .class files in WEB-INF/classes folder, but it creates a build/classes folder in the root of the project.
So, should I just copy the classes folder to WEB-INF before deployment or is there a better way to do it?
I ended up doing this:
Configure Eclipse to put .class files in WEB_INF/classes folder:
Project Properties -> Java Build Path -> Source -> configure Default output folder to be WEB_INF/classes
Deploy to App Engine:
cd D:\path-to-eclipse-workspace\my-project
gcloud app deploy src\main\webapp\WEB-INF\appengine-web.xml -v v1
I´m trying to deploy java application in OpenShift server. My application is divided in four projects: BBDD, Bussiness, Web Services and Web. When I create the application with openshift, it´s created this structure: src(this one has java, resources and webapp folders), webapps and pom.xml. I don´t know how to organize my projects into that structure to upload to the server.
I have put my web structure on webapp folder inside src. Then, I put the other projects on java folder. When I executed the application I can see my web pages and I can navigate for all of them but, when I call to a webservice I have the following error:
Http/1.1 404 not found
Thanks in advance,
Iban
Openshift is expecting to compile the application on their server using the pom.xml then run the application it built. To do that your project needs to be a maven webapplication project. Only when you have tested it locally would you expect that committing the code to your openshift server (using git) would it be able to compile and run the app successfully.
This means that you should not be uploading files using an SCP upload tool; you should be committing your source using git to your openshift server for it to compile then run your app.
The way I typically work with maven and openshift is to add a fragment of xml into the pom.xml to enable the jetty-maven-plugin to be able to use mvn jetty:run to build and launch the project to test it locally. If-and-only-if it works locally do I try to deploy it. That command is 'zero install' as maven downloads the jetty jars and runs them over your project.
Redhat openshift tends to promote redhat jboss AS application server as a Java solution so if you go down that route you should try mvn packageto make the war file and test it against a local jboss install before expecting it to work on the server. There is an approach where rather than committing code for the server to build and run you can build an EAR file locally and have that pushed to the server.
At the bottom of this answer I have a link to a demo I wrote which shows my preferred approach. I create my apps as a DIY cartridge which is an empty shell then customise the scripts in the .openshift folder to start the Java server of my choice. I use maven to build my webapp which I run using the jetty-maven-plugin to debug locally in Eclipse (maven IDE plugin lets me "debug as... > maven > "jetty:run"). Then I configure the pom.xml to build my whole app plus the jetty Java webserver into one huge runnable jar. Then I edit the start script to use "java -jar" to run my full app.
If you are using a DYI cartridge you don't need to use maven; I have used sbt as the build tool to create a runnable jar. You simply have to modify the scripts in the .openshift folder to download and run the tools you choose.
The demo I made GitHub at the link below has instructions on how to deploy it on openshift. So you may want to get that running then after you can both debug it locally and push it to your openshift server then rip out my code and add in all yours:
https://github.com/simbo1905/zkmongomaps
I have installed Red5 server successfully and also am able to run the demos fine. Now, I want to create a sample red5 server application. I created a sample project according to the specific directory structure that Red5 requires. But, now when I try to open this project in Netbeans 6.8, I am unable to because both have a different directory structure. So, Netbeans doesn't consider it as a project. I actually want to convert this project to a war file, so I can deploy it to red5/webapps directory and then red5 deployer service can make project out it automatically. How do I convert this project to a war file? because in Netbeans I am unable to open it. Please help.
I don't know if this will fully answer your questions but this is my configuration.
In the main red5 directory there is a file called project.zip, you can open it to get basic configuration files, directories structure and build files for ant (Pure Java build tool).
Using netbeans, you create a new free-form project and point it to the directory of your project. because of the ant build files the project will be recognized.
Netbeans provides it's own ant version but i prefer to install and use ant from command line.
when you'll run ant in the project directory it will try to find dependencies and probably at first will complain that it cannot find ivy.
Ivy is a dependency manager that red5 project uses that can be found in the following URL: http://ant.apache.org/ivy/download.html
please notice that ant will tell you exactly where it searches for the required jar file, just download the ivy zip, unzip it, and place the jar inside it in the requested directory.
once ant will compile the project properly (just by running the commant ant), it will also create a war file under dist directory.
don't forget to add to your red5 netbeans project the relevant red5 jars in order for the project to compile properly.
I am also prefer use ant from command line. I have two directory structures. One for source files and another for deployment.
This example helped me to start.