Deploying Java Spring Rest Service To Tomcat 6.0.20 - java

I'm fairly new with Spring Framework and struggling to get this simple example to work on a Tomcat 6 instance. The example is here http://spring.io/guides/gs/rest-service/ .
It works fine when i run it within Eclipse but when i convert it to a WAR file and deploy, the directory in Tomcat is created but the service/tomcat responds with a 404.
I suspect i need to create a web.xml file (not sure the annotated way will work with tomcat 6 because it supports only servlet 2.5) but not sure where to start.
Any help would be much appreciated.

Related

Is it possible to make a Spring MVC web app run as a "standalone executable" with Java and Tomcat embedded?

I have a web app built with Java, Spring MVC, and JDBC. The result is a WAR file.
To run it, the user has to install Java 8 JDK and Tomcat, and deploy the WAR file to the Tomcat server.
It would be great if they could just download the one file run it as a standalone application.
That is, run "the WAR file" and just browse to http://localhost:8080/myapp
Also, on Windows it would be great it was setup as a Server (like Tomcat is when installed with the installer).
Is there any way to do this? Maybe with Spring Boot or something new like that?
Yep, Spring boot is the way to go.
It allows you to build an executable Jar with all dependencies and a Tomcat (by default, can be changed) embedded.
But users will still need to download a JRE to execute the Jar, and a database if it's required, but you can use en embedded database like H2, HSQLDB..., depends what is your needs.
Yes . you can use spring boot to achieve your results. Kindly refer the below link for sample code
https://mkyong.com/spring-boot/spring-boot-hello-world-example-jsp/
You can use embedded jetty server using maven but that would require you to setup few things your app and may have align your existing app, please check this article for more information.
Jetty is similar to tomcat server in terms of running spring application, there are not much difference in terms of development. Tomcat is just more famous.
Other option as others said, is to migrate your app to spring boot which would be easy if you already have app written in spring (But that depends how much code you have and how much time you have)

How to build web.xml for Dropwizard application

I have created application in Dropwizard, which is serving REST API to my clients. I used to run this from .jar file on server, everything worked fine.
Now I have requirement to move my application to WildFly, so now I assume that I need to have a WAR instead of JAR, and here comes my problem:
How to write web.xml to my application? What to include in there? Could anyone give me any template or tutorial or some example how it is done in Dropwizard?
I found what I was looking for. It's wizard-in-a-box project that do all the necessary things to build a WAR file.

How to deploy a non-Liferay web application to tomcat bundled with Liferay

I have decided to use Liferay for my next project and I'm trying to somehow get an old non-Liferay web application deployed on tomcat 8 that was bundled with Liferay. The application uses servlets.
After some googling I got the impression that it should be possible to simply deploy the application on tomcat which I did. Liferay does pick it up from the /deploy folder but there is an error while deploying it saying web.xml needs to be upgraded to 2.4. My web.xml is almost empty because I use #WebServlet annotatations for servlet mapping.
So my question is, is it possible to deploy a non-Liferay application to tomcat that comes with Liferay without making any changes to it?
You should only place Portlet-WARs into LIFERAY/deploy, as Liferay will try to convert such WARs into a Liferay specific Portlet-WAR, before deploying them in Tomcat.
If you need to deploy a legacy WAR you should place that into LIFERAY\tomcat...\webapps\ and Tomcat will start it without any modification.

Java Web Container implementation independant development

One of the most important non-functional requirements of any project is the build process in my opinion and that's where I kinda get stuck in my java project, which has just one external dependency, a jdbc compatible database. All the tutorials about spring and deployment out there; I've read them all, but they either say:
run it with gradle bootRun applications.properties (yes works but on a webserver I'm not going to have any properties-files, but JNDI resource for example) or
build a deployable war file with JNDI resources (yes it works on the webserver, but not in my embedded webserver or I'm doing it wrong, but I cannot find any doc about how an embedded tomcat loads a context.xml from outside the jar file).
Now I tried to use the same setup as my server and installed tomcat7 and the #Asyc #Scheduled services run, but no servlets, like a simple /status page should return "OK" just for checking. catalina.out does not show any errors. My /manager from tomcat7-admin says deployment ok, and when I click start: "FAIL - Application at context path /xyz-0.1.0 could not be started
FAIL - Encountered exception org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/xyz-0.1.0]]"
And now I want to make a cut here and throw every "bootstrap" stuff away and start from zero.
So my question is, am I wrong when I say, that the big deal of my deployment is a jdbc JNDI resource provided from the web container, which is called 'jdbc/xyz' and everyone who wants to deploy my war needs that JNDI. That means so matter if you're using wildfly, jboss, tomcat, glassfish or any embedded server: your server impl has to provide that web container and jndi resource to make it run. And I don't want to configure any tomcat, glassfish or whatever implementation in my war.
Is that wrong?
It would be great, if you could help me. I'm playing around with that many weeks now :( and if A works B does not and vice versa. Would it be easier to use JEE?
Thank you.

JSF Beans not accessable when deployed as war

I ran into a Strange Problem. I'm currently working on a project with the following configuration:
Spring Framwork for data services
JSF and Vaadin as web Framwork (2 seperated subcontexts)
Tomcat 7 as application Container
Spring EL resolver
When I deploy this application to my Tomcat Server everything works fine. When I build the application as a war-file with maven and deploy this war file on my Tomcat (the same tomcat!) the Vaadin frontend works fine, but in the JSF all Tags with values from beans stay empty. Tags with just plain text in it are processed correctly.
My biggest Problem is, that I don't get any exception. I'm also a bit confused that I also don't get an exception, when I try to access non-existing beans in my eclipse-deployed environment no error occurs, just no output is produced at that point.
I raised all Log Levels to max, but in the logs everything seems to be fine.
So, has anybody an idea, how to get JSF to display errors, when beans are not accessable and why there are difference when I deploy directly from eclipse or from a war file?
Thanks in advance!
nclaasen

Categories

Resources