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
Related
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.
I am planning to deploy a web application built on spring boot in windows server.
I want to use tomcat container.
Can I deploy the spring boot fat jar directly or is it recommended to deploy the war file.
please suggest how to deploy and the preferred method?
As Josh Long likes to say "Make Jar not War!" It really allows an application to have flexibility on where it can be run and allows for everything to be packaged as one artifact. Windows has no issue running the embedded Tomcat that is part of Spring Boot and that is exactly what it is doing when running it in your IDE. The one edge case to this is keeping the process running on the server. Normally in Windows you would do that by setting up a service and having that service run java -jar myapp.jar. I haven't personally seen it done so might take some playing around but it is possible.
A simple way to run a spring application in Windows Server is to run it as a service. You can do it using the winsw, that you download its .bin file here
winws download
Then, rename it to something like my-app.exe and create a XML file like this:
<service>
<id>my-app-service</id>
<name>my-app-service</name>
<description>Back end service for app</description>
<env name="HOME" value="YOUR_JAR_FILE_PATH"/>
<executable>java</executable>
<arguments>-Xrs -Xmx256m -jar "YOUR_JAR_FILE_PATH\YOUR_JAR_FILE.jar"</arguments>
<logmode>rotate</logmode>
</service>
Then, using the terminal, run:
my-app.exe install service
Your application is now a windows service and you can start\stop it in the tasks manager on the services tab.
Starting from the latest Windows versions, you could also deploy your Spring Boot app inside a Docker Windows Container. I wrote a complete guide: https://blog.codecentric.de/en/2017/04/ansible-docker-windows-containers-spring-boot/ (as already mentioned, Tomcat is already embedded in Spring Boot).
Spring boot internally has a tomcat server.
If you want to deploy it on tomcat then while building with maven build it as war.
If you want to deploy it has inependent application then build has jar and then place it in some folder and run it using below commands java -jar yourjarname.
Apache tomcat is a web container you cannot deploy a jar in tomcat server. If you created a web application then export your application as war file and put it in tomcat webapp directory, start the server and your war will be deployed.
How to deploy created .jar file in Apache Tomcat server in Eclipse IDE?
There's a huge legacy codebase that I'm working with and I need to export it into an executable JAR file to make it easier for my co-workers to run it. It's a web application built on top of GWT, but I'm not sure what kind of application server it uses (e.g. Apache Tomcat, Eclipse tells me it uses a "built-in" server).
The run configuration shows up when I try to run the project, but not when I'm trying to export it as an executable JAR. All it does is run an application server on the machine, and allows a user to access it via 127.0.0.1:8888 in a web browser. Any ideas?
Right click on the project.
Google
GWT Compile
Zip the output (I think the war folder) into a war file which can be deployed in tomcat or jetty or something else.
(Creating an executable jar from a GWT project is not possible, you should create a war).
(Make sure to have the eclipse google plugin installed (https://developers.google.com/eclipse/docs/getting_started))
I have set up a project inside Eclipse which I can debug on a Glassfish (3.1) server using the Eclipse Glassfish plugin. So when I click 'Debug on server', it uploads fine and I am able to step through the code correctly etc.
The problem is that I don't know if the program is being compiled/build (to a new .war) each time I press debug. I have got an Ant script in the project (as I previously built the project via terminal) but I'm not sure if it is actually being used in Eclipse.
Is there any way to check if my ant script is being run?
Also, how does Glassfish know what resources to upload? Does it just look for any .war files in the project?
Not sure about this particular jar plugin but as far as I know here is how Eclipse handles web applications:
Eclipse automatically compiles all of the sources in the class path
Then it creates a configuration file which tells Application Server to look for webapp on your project folder and does some mapping based
on your project setup. This will not create a WAR file. Eclipse will
just map WEB-INF/classes to {projectDir}/bin, your classpath jars to
WEB-INF/lib and so on.
When launching the Application Server, eclipse will feed it the config file made above.
Actually answering your question: Eclipse will not use the Ant script you created, nor will it create a WAR of any kind. It will just use project configuration to properly map project folders to web application structure.
Again, this is how eclipse handles things by default, the plugin you're using might do something different. This is based on my experience and is not based on some kind of documentation.
I'm working on my first Java EE project with NetBeans IDE. My application server is the integrated GlassFish.
At this moment my project run locally on my Mac with MySQL database. How can I deploy it on my web server?
You need to just create the war file and copy it to your web server. When you start your web-server it will automatically deploy the war file.
You need to use the remote application server functionalities of deploy.
If it's also Glassfish you can use the Administration Console to do it - e.g. example.com:4848 (defaut port for Glassfish admin portal).
Also you may use Cargo Maven Plugin in order to automate the deploy.
You have different possibilities:
Netbeans can deploy your application on the integrated Glassfish server. This should happen automatically if you Run you project and the Glassfish server is selected for this project. You can change the selected server for every project under Project Properties -> Run
You can deploy .war files via the Glassfish admin console if the Glassfish server is already started. Navigate to http://localhost:4848, go to Applications and click on Deploy
You can manually deploy you applications. You have to copy either the .war file or a folder containing the contents of the .war file to the folder /GLASSFISH_HOME/glassfish/domains/domain1/autodeploy