Spring Boot static files deployed via WAR with bad encoding - spring-mvc

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

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.

FAIL - War file cannot be uploaded if context is defined in server.xml (Spring mvc)

I'm trying to deploy my webapplication (made with Spring MVC) on the server of a provider (Tomcat 7). I was trying to upload my ROOT.WAR, by using Tomcat manager page (without specifing a context), to the server, but I get this error:
FAIL - War file "ROOT.war" cannot be uploaded if context is defined in server.xml
How can I solve this problem? I read something on the internet but the solution is not clear to me.
Thank you in advance

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.

Standalone Tomcat Server for webapp

I am newbie in configuration. I have made Spring web application. When I run it on Intellij's Tomcat it works correctly. Now I would like to move to a different computer without Java, IntelliJ on it. Is it possible to do this only with Tomcat (XAMPP) installed?
To run a java web app (including Tomcat) you need to have Java on all computers at the level of your web application code.
i.e. if your web app is done with Java 1.8 then you have to have it there.
You treat the deployment as a standard java web application deployment check out this link:
http://www.codejava.net/servers/tomcat/how-to-deploy-a-java-web-application-on-tomcat

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

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.

Resources