I have an application that is currently built on Spring Boot 1.5.9 and I am trying to update it to the latest Spring Boot 2 version.
The application uses spring-security, spring-security-taglibs, spring-boot-starter-data-jpa, spring-session-jdbc, jstl (jsp pages) and connects to two databases, I also use profiles to configure the application differently in development and production environments.
I was successfully able to upgrade my development application. I only needed to modify my pom.xml and a few java files.
During development I usually use the integrated Tomcat server. i.e. The one you get when you run mvn spring-boot:run
As a sanity test I also installed Tomcat 9.0.43 (this is the same build that is used in my production environment). The Spring Boot 2 version of the application works perfectly fine using this method.
However, all my problems started when I tried to deploy my application into the production environment.
When restarting the Tomcat server, I don't see any indication that it even detects the Spring Boot 2 application. In Spring Boot 1, I would usually get the Spring logo and a bunch of startup messages. Visiting the website in a browser shows The origin server did not find a current representation for the target resource or is not willing to disclose that one exists
The Spring Boot application does not generate any log files and Tomcat's log files merely indicate the application was deployed successfully.
What could be causing this issue.
Both my development system and the production server have JRE and JDK 8 installed (although, different minor versions)
Both systems are running the same version of Tomcat.
Both systems run on Windows. The server runs on Windows server 2013 and the development environment is on Windows 10.
I use Visual Studio Code for development and debugging
Update 1
The spring boot 2 version of my application is using version 2.5.1
Here are a few things that I have done:
I have made sure that the application extends SpringBootServletInitializer
I can't put my local Tomcat installation in the production server (at least, not without a lot of issues), but I've copied the server's Tomcat installation onto my development machine and verified that the application DOES start correctly.
The only property in my POM is <java.version>8</java.version>
While both environment have JRE and JDK 8, they may have different minor versions
Update 2
I created a brand new Spring Boot 2.5.9 application (using Spring Initializr and no dependencies) and tried to run this in a Tomcat 8.5.20 instance on the server. I also created an index.html to display a simple Hello World!!! if the application starts correctly
The application works fine on my development system (using both integrated Tomcat and separate Tomcat installation)
In production, the Spring Boot application did not start (i.e. I got a 404)
It did not appear to generate any logs or errors.
Related
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)
I have configured and running a weblogic12C server (12.2.1.4.0) on my computer, and I am working with eclipe, where I have a spring boot application with java 1.8.
I need to configure ecplipse to deploy and debug on my local weblogic server.
The problem is that when trying to create the server in Eclipse and indicate what the server will be, its domain and the WAR to deploy, the wizzard says "The server does not support version 4.0 of the J2EE Web module specification."
The strange thing is that my client has a 12C weblogic server (12.2.1.3.0) and I can deploy there without problems via console (ip: 7001 / console).
Any ideas? Will it be a problem with the domain configuration?
Grateful for the answers !!
Some images speak more than a thousand words:
Configuration server weblogic wizzard
Selecting the domain
Indicating that it is a local domain
When trying to move the resource, the wizard tells me that it is not compatible
Checking the domain settings, I don't see anything wrong
According to this document
https://docs.oracle.com/en/middleware/fusion-middleware/weblogic-server/12.2.1.4/wbapp/basics.html#GUID-62B6050D-6DD3-4028-B863-4CD0B5692E7F
WebLogic Server fully supports HTTP servlets as defined in the Servlet 3.1 specification at http://jcp.org/en/jsr/detail?id=340. HTTP servlets form an integral part of the Java EE standard.
It looks like your Eclipse installation is trying to use Java EE version 4, which is not supported by Oracle Weblogic 12.2.1.*
Furthermore, I have found the below post, which I think could be useful to fix your issue.
Project facet Dynamic Web Module 4.0 is not supported by this server
That post explains the issue with Servlet-API version 4.0 and how to configure your IDE to use the version supported by Oracle Weblogic 12.2.1.*
I have created Spring boot application and Angular project (Angular 1) separately. In my local i am using npm to server the client app and it calls my back end app services. I am using Embedded tomcat in spring boot application.
Now i want to host my application in server. How do i do that?
Can i have embedded tomcat and build as jar or should i have to install standalone tomcat in the server and deploy my application as war?
How to configure my client code for example, in godaddy i have given ip xx.xx.xx.xx to www.xyz.com. The ip address is my production cloud server. How to redirect to angular application and that application calls server exposed apis.
I cannot have single application that has client code. I should do with two different application only. Please help me deploying this in best way. If embedded tomcat doesnt help then i can install standalone tomcat in server and and build my app as war and deploy it.
The current best practice would be to embed the servlet container (Tomcat, Jetty, other) into the artifact and build a fat JAR. The main advantage is a simplified deployment process: it's enough to push the far JAR into environment and execute it. Unlike the usual servlet container with WAR deployment model the embedded approach doesn't have to deal with additional configuration layers e.g. thread pools or data sources shared between different WARs.
One example of how to build a far JAR with embedded servlet container is spring-boot-starter-web dependency with spring-boot-maven-plugin:repackage goal. In this setup to build a fat JAR it's enough to run mvn clean package repackage.
If you are developing locally your web client code most likely will face issues with the same-origin policy. You most likely will need a CORS filter, however it's provided by Tomcat.
After a day of googling, I'm still lost.
I've created a Spark web-application that runs on the embedded Jetty server, but I want to run my web-application on a Tomcat server.
I'm using Maven to build my web-application and can't find any good resources on using Spark on Tomcat with Maven.
How can I create a Maven project with Spark and run it on a Tomcat server?
You'll need to implement EmbeddedServer interface in order to do it. Currently, it only supports Jetty by default. So, fork it and submit a PR to the author.
I have WebLogic (10.3.5) application server installed in a server and in an another
server JBoss AS (7.1.1) installed.
ServletA.java gets compiled using Java EE specific jars in JBoss AS and deployed in WebLogic (during
runtime WebLogic will be using its own Java EE specific jars to execute). Currently, when I access the servlet in WebLogic, I'm not getting any errors, it's working fine.
My question is, is this approach OK or will this create any problems in the future?
As long as you stick to the classes in the Java EE spec and don't use any JBoss specific classes or features this approach is OK.
What can still go wrong is if you rely on server specific behavior (hard to test) or run into bugs on one server.