Where to install JDBC driver for Vaadin app run from IntelliJ using bundled Jetty servlet container? - maven

I will ultimately be deploying my Vaadin web app to Tomcat servlet container.
In Tomcat, JDBC drivers generally need to be stored outside of the web app, in a separate Tomcat folder. So I do not want to add any JDBC driver as a dependency within my Maven build settings.
In the meantime, while developing I am running the Vaadin 8 or 8.1 web app (created from the vaadin-archetype-application Maven archetype) from within IntelliJ 2017.1 using the Jetty servlet container that is somewhere mysteriously bundled (“embedded”?) within the project.
Where can I store my JDBC driver jar file(s) while developing with IntelliJ-Jetty combo?

This depends on wether you use Tomcat or Jetty as an "old fashioned" appserver, or if you use it as an embedded component in your application. The archetype you have used probably assumes the latter (adds jetty-plugin to pom), while it sounds like you want the first scenario. In that case, just install the driver in the tomcat or jetty instance you want to use, and create a run configuration in IntelliJ for that instance. If you need the driver compile-time, add it to the pom with scope "provided". If you want to just have it available to the jetty-plugin, add it as a dependency for that plugin (inside the plugin definition).
See this related question for more info about including dependencies only for embedded jetty.

Related

Does every spring boot application create a tomcat container to be able to run?

For example,
I understand adding specific dependencies like spring-boot-starter-web that contains tomcat as transitive dependency triggers the spring framework to initialize tomcat container but I want to know if we say a spring-boot application is running, does it imply always that tomcat is also running?
I want to know if we say a spring-boot application is running, does it imply always that tomcat is also running?
No, it doesn't.
Spring boot can be used for both web applications and non-web applications.
For web applications you can use tomcat/jetty/undertow/netty for example, its up to you to chose what works for you the best.
If you don't want to run an embedded version of the web server you can opt for creating a WAR file and place it into the web server prepared in-advance.
If you don't want to run web application at all (something that is built around "Request - Response" way of work in the most broad sense) - you can create a "CommandLineRunner" - in this case you don't need to depend on neither web-mvc nor webflux. For more information about Command Line Runners read here for example
You can have an embedded server in your JAR that is able to be run on its own. By default it is Tomcat but you can change this to others, like Jetty. Additional details:
https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/howto-embedded-web-servers.html
If you don't want to have an embedded server and you want to deploy your application you can also create WAR files instead of JAR files. Additional details:
https://www.baeldung.com/spring-boot-no-web-server
https://spring.io/guides/gs/convert-jar-to-war/

Using Spring Framework Web when Tomcat is already installed and running

I am studying Spring Framework (all features) preparing to start some microservices and web applications for the first time. I am puzzled by the injection of Tomcat by Spring. If I buy Java hosting with Tomcat already running or set up tomcat to be already configured and supposedly running on a server, is this going to cause a conflict because it is also included in Spring? Or are we talking two different things where what is included in Spring is a connector to Tomcat instead of Tomcat itself?
I believe you are talking about Spring Boot which comes with bundled tomcat (JAR packing). If you package as a JAR, tomcat will be bundled but if you want to use your own tomcat or Jetty or whatever you should look at bundling as WAR file which will exclude tomcat bundling.
few pointers for you
https://spring.io/blog/2014/03/07/deploying-spring-boot-applications
https://therealdanvega.com/blog/2017/06/28/deploying-war-application-server-spring-boot

Does spring boot needs a WAS (Websphere Application Server)?

In my theory spring boot is capable of running java web application stand-alone. It says it has a own embedded servlet container and can use JNDI itself.
I built a war file before (spring-mvc, security, gradle built), but Spring boot assemble jar file and it runs on any machine which has JVM.
So my question is, if I made a spring boot based web app (contained JSP files & JNDI for looking up datasource), although it has own embedded servlet container and packaged jar file for running standalone, do I still need to package it as WAR file and deploy it in WAS (Websphere Application Server) or servlet containers for any reasons such as performance, stability, scaling-out etc?
WAS is an full blown Java Enterprise Application Server, on the other hand you have Spring that only requires a Servlet Container (Servlets are a part of full JEE).
Servlet Containers are for example: Tomcat, Jetty, but also WAS.
Spring Boot is able to package the complete application TOGETHER with the code of Tomcat in an JAR, so that this jar contains the Servlet Container and your Application.
Do I need a additional WAS for performance, stability, scaling-out etc?
Performance: No - There should be no important performance differerence between Tomcat and WAS when you run a Spring-Application. (Only that Tomcat needs less memory for itsself)
Stability: Tomcat and WAS are both very mature products.
Scaling: You can build a cluster of Tomcats by your own.
The main features of WAS over Tomcat are:
- WAS supports EJB and CDI (Tomcat would need TomEE for this), but Spring will not use it, because it is its one Dependency Injection container
- WAS has more Monitoring features, but this does not matter, because Spring Boot has Actuator
#See Difference between an application server and a servlet container? for more details
Simple answer is No. You do not need any Full blown application servers for any of the reasons that you mentioned (for performance, stability, scaling-out). You can just do fine with tomcat
Edit
Looks like you are using only JNDI feature from the Application server. Do you really need JNDI when you pack your servlet container along with your application ? I don't think so. That days are long gone.
JNDI really shines when you have to move an application between
environments: development to integration to test to production. If you
configure each app server to use the same JNDI name, you can have
different databases in each environment and not have to change your
code. You just pick up the WAR file and drop it in the new
environment.https://stackoverflow.com/a/7760768/6785908
(If you still need JNDI to be used to look up your data source refer: https://stackoverflow.com/a/24944671/6785908).
No, still I do not really see a reason for packaging your application as WAR and deploy it to traditional application server. That being said, if you have some existing infrastructure lying around and you are being forced to deploy to existing WAS (or WebLogic or JBoss any application server for that matter) server, then I rest my case :).

EAP application using Eclipse

I have created a sample EJB Project and a Dynamic project.
Now I have used the interface of EJBProject inside the client project so that it could use the proxy object and in turn interact with the bean to fetch the data.
However, I have created a blank EAP project and have added both the EJBProject and the DynamicWebproject. Now according to the concept I have bundled the EJB and Web inside EAp and have deployed on JBoss Server, so technically if I hit the jboss url then it should direct me to welcome page of client. However I am not getting as expected.
Am I doing any mistake in deploying it??
When you will deploy EAP then a target must be generated in that target you will have application.xml in that you will have context root now use this context root in your url foreg: localhost:yourport/yourprojectname/contextroot
this must take you to your page

Run gwt app with jetty

I want to run a gwt app with jetty - that is with jetty:run
The problem I'm finding is that jetty is not picking up the gwt compiled artifacts.
I run gwt:compile and it creates my module in the target// location.
Jetty does not seem to include that folder in the web app though.
I know this as when I start the app it does not find the <module>/<module>.nocache.js content.
Use jetty:run-exploded instead; or configure Jetty to look at your target/<finalName> for web resources in addition to or instead of src/main/webapp.

Resources