Spring web app deploys on Gradle's embedded Jetty but not in standalone Jetty - spring-mvc

I have built a small web app using Gradle. Things seemed to be going well using the embedded Jetty server, but not so well when I tried to copy the WAR file to a standalone server.
I used the gradle war plugin to assemble the war.
Running gradle jettyRunWar works fine.
Copying the war to the Jetty webapps folder and running Jetty fails with this exception:
java.lang.IllegalStateException: No such servlet servlet_name
But this very same servlet is found and used without issue in the embedded Jetty server.
The same issue happens if I manually copy the exploded war to the webapps directory.
The Spring web and Spring mvc libs are copied and present in the WEB-INF/libs directory, so it isn't an issue of not finding Spring (or is it?)
I'm using Jetty 9.1, and my web.xml file is configured for Servlets v3.
I'm also using Spring 3.2. The web app I'm writing is a RESTful service, using the #Controller annotations to route requests.
This should be as simple as copying the war over, but it seems not to be. At a bit of a loss at what to do here, any thoughts?
Thanks!

Sometimes the answer is staring you in the face...after posting I realized that I had my servlet-mapping before my servlet declaration. While this did not present an issue for the Gradle Jetty (not sure why), it made Jetty unhappy. Not sure why I changed the order to begin with...
In short, Jetty seemed to not find the servlet because it had not been declared yet.

Related

Deploying Spring MVC from SBT

I'm having trouble deploying my Spring MVC Webapp with the xsbt-web-plugin. When i'm using container:start everything works just fine, but when i'm trying to run the packaged .war file inside a tomcat instance the webapp isn't loaded. It is just starting a plain tomcat instance.
I had an error in my path that slipped through. I've overlooked this for days. Sorry.

Embedded Tomcat without unpacking

What steps are required to make a executable war without unpacking the war. ( Similar to the way spring boot does). Basically want to wrap Embedded Tomcat into existing war and make it execurable.
Env: Spring mvc, Java 7, Webapp with web.xml
So far I have done following research:
How Spring boot creates Embedded container in TomcatEmbeddedServletContainerFactory, but all those WebApploader stuff I'm not able to understsnd.
Successfull in packaging a executable war just using spring boot maven plugin but not able to run without unpacking it.
Tomcat api class doesn't read app from war directly.
Have successfully tested embedded tomcat by extracting it in a particular location and calling addWebapp method.
I do not want to create a big fat jar using shade plugin.
Do not want to specify path like src/main as indicated on many examples on the internet.
Upgrading the app to spring boot web is not possible due to time and other dependencies.

Spring Boot static files deployed via WAR with bad encoding

I am working on a project with spring boot web to serve a rest API (and using react.js on frontend) where embedded tomcat and dev-tools is used in development phase but is deployed to a jboss server via war file.
To keep consistency between dev mode and deployment mode, I am copying my front-end files to the classpath directory classpath:/public. This way of working is being very productive and I liked it.
The problem that is happening is that these front-end files have special characters (Portuguese characters) and only when I serve my application via WAR in jboss these characters are being displayed with problems. When I serve with embedded tomcat everything works fine.
Thanks in advance.
Spring MVC defaults to ISO-8859-1, embedded Tomcat overrides it to UTF-8, see https://github.com/spring-projects/spring-boot/issues/1182
I fixed it with property spring.http.encoding.force=true

example stand alone application using EJB-MDB, eclipse, jetty server?

how to develop one example application using EJB-MDB, eclipse, jetty server?
I have created two java class. and i have .jar file, where I have to deploy .jar file in jetty server? after that what I have to do?
Your requirement for EJB-MDB seems to demand a full blown server like Jboss, Glassfish, TomEE and others. If you need jetty with the equivalent of EJB MDB functionality probably you should look at Spring-Boot. On the other hand if you need EJB/MDB compatibility you should probably choose an Application server and each of these comes with a plethora of examples and quickstarts, but each one comes with it's own Servlet Container respectively Undertow, Tomcat, Grizzly, but not Jetty.

Updated servlet class not being referred in tomcat ubuntu

I am beginner to servlets. I am trying to create and run servlets using tomcat in ubuntu. I am facing a problem. I am able to call the servlet from the html file by adding an entries into web.xml. But when I change the java program a little and recompile and invoke the new servlet class, the html still seems to call the old one.
Any help is appreciated.
Thanks.
Check if you are redeploying the application properly.
Tomcat by default supports HOT Deployment, you should check if the modified servlet got reflected in TOMCAT_HOME/webapps/{application-name}/WEB-INF/classes location.
.
References:
How do i update JSP's without restarting
Hot Deployment
Hot Deployment Support in WebLogic and Tomcat

Resources