configure jetty for hot deployment in spring boot - jetty

How do I configure jetty for hot deployment, i.e. set intervalScan ?
Is it possible set from properties file?
I've read the documentation, but it's only explain to setting basic configuration such as port,context path,etc.

Spring Boot doesn't expose all Jetty features via external properties, but you should have access to all the Java APIs. Having said that, I doubt if "intervalScan" is very useful to you for thymeleaf with the default Boot settings because it's a Jetty setting related to the Servlet context (as far as I understand) and Boot prefers you to load templates from the classpath. Your IDE should allow you to build automatically (ie update the classpath when resources change), or the Gradle and Maven tooling from Boot can be used on the command line.

Related

Can't run my Spring MVC project on a Tomcat web server (local)

I have used Spring Template Project to create a Spring MVC Project. It works fine running it on the "VMware vFabric tc Server Developer Edition v2.8"-server. But when I move it to the Tomcat server and I try to run it it doesn't work. When I try to access the site I get following:
HTTP Status 404 - /analyse
type Status report
message /analyse
description The requested resource is not available.
Do I have to convert the project some how? It doesn't have the same structure as the other projects in the webapps-folder.
Any idea?
So basically I need to know what has to be done in order to run my Spring MVC Project on my Tomcat-server.
Aprreciate any help I can get!
What is the name of your *.war file?
Typically you can access your app via a URL by the same name, minus ".war"
The problem is in deployment assembly,you have to check it.
As you are using maven so you can type following command
eclipse:eclipse -Dwtpversion=2.0
so it will solve deployment assembly problem and also download necessary jar's.
Then run command
clean install
and clean the project from
project clean option.
Go to Project --> Properties configure Java, Javascript and Dynamic Web Module.
And now you can access the application in Tomcat Server as well. The problem is in deployment assembly.
Properties Configuration

Jetty and/or Servlet-api in JavaFX breaks deployment

I try to embed (use) Jetty into my JavaFX 2.2 applet (which runs in a browser).
My problem is that, to host servlets I need to include the servlet-api-3.0.jar also (for javax.servlet namespaces) besides jetty-server.jar, jetty-servlet.jar and jetty-util.jar.
If I include the servlet-api.jar, my project compiles, but when I run it inside the browser, the deployment fails with the "JavaFX application could not launch due to system configuration (show error details). See java.com/javafx for troubleshooting information." error message.
If I remove the servlet-api.jar (and remove the relevant source) it deploys again.
For the JavaFX project the Java Platform is set to "Default JavaFX Platform", and it would be good to keep it this way to reduce the minimum footprint required.
I'm not a java(fx) expert (I come from .NET world), so I'd appreciate any help!
You have an issue with signing the JARs. I'm not very familiar with signing JARs for JavaFX but here is the documentation:
http://docs.oracle.com/javafx/2/deployment/packaging.htm#BABJGFBH
http://docs.oracle.com/javafx/2/deployment/javafx_ant_task_reference001.htm#CIAFJGAB
servlet-api-3.0.jar is what's known as a provided dependency.
It is not needed to be included in your war file, as the web app container (in this case Jetty) provides it for you. In your build tool, just exclude the servlet-api.jar from being bundled in your war file.
Note: jetty-server-9.0.0.M5.jar is also a provided dependency and has the same rules.

How do I enable multiple contexts in cloud foundry?

We'd like to set up a development environment using cloud foundry. Unfortunately, our architecture packages a few different wars into one webapp, each war running under its own context. Furthermore, we have a bunch of absolute URIs with the context in it, too many to rename all of them to relative URIs.
CF apparently deploys a war to the root context. Is there any way to get around this? I tried faking it by editing the web.xml in tomcat/conf/ but when I did a whole other application folder was created on my machine.
Thank you
When you push a Java web app to CloudFoundry, the platform installs and configures the Tomcat instance(s) for you, and you have limited control over the configuration. It is possible to configure your own Tomcat (or other application container) and push it along with your application instead of letting the platform do it for you.
There is a good blog post about using this bring-your-own-container approach with Tomcat 7: https://www.cloudfoundry.org/blog/deploying-tomcat-7-using-the-standalone-framework-2/.
I suggest using this approach to configure a Tomcat 6 or 7 distribution in a way that works for your application, zip up the customized Tomcat distribution along with your war files, and push that bundle as a stand-alone app on CloudFoundry.

Compile JSP & Java on browser refresh - Tomcat

Is there any way to setup Tomcat server so whenever I make changes to Java class or JSP page the change is visible on browser refresh.
I'm bored stopping and starting Tomcat. I want to configure Tomcat like the way WAMP works [where you can see the PHP code change upon browser refresh]
If it's for development mode that's ok. Don't use it for production stuff.
You don't have to restart the server. You can restart the app through the Tomcat Manager.
You can even do this directly as: http://[hostname]:[port]/manager/reload?path=[/path/to/your/webapp]
or
Define your context as reloadable
Be careful: It is NOT recommended to place elements directly in the server.xml file
Check out the Tomcat configuration guide
For java classes: reloadable
Set to true if you want Catalina to monitor classes in /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically reload the web application if a change is detected. This feature is very useful during application development, but it requires significant runtime overhead and is not recommended for use on deployed production applications. You can use the Manager web application, however, to trigger reloads of deployed applications on demand.
NOTE - The value for this property will be inherited from the reloadable attribute you set on the surrounding Context component, and any value you explicitly set here will be replaced.
(http://tomcat.apache.org/tomcat-7.0-doc/config/loader.html)
For JSP: development ($CATALINA_BASE/conf/web.xml)
development - Is Jasper used in development mode? If true, the frequency at which JSPs are checked for modification may be specified via the modificationTestInterval parameter.true or false, default true.
Hope this helps

How can I deliver jetty with many webapps via jnlp?

I have a webapp (http://sourceforge.net/projects/sf-mvn-plugins/files/m2-repo/net/sf/maven/plugins/example-captaincasa-jnlp/0.1-SNAPSHOT/example-captaincasa-jnlp-0.1-SNAPSHOT.war/download) which uses jsf in a servlet container. This works fine with jetty-maven-plugin run-war target at my local pc. In the future I would like make more of this kind of webapps.
I am looking for a way to deliver these webapps with jetty via jnlp. The end user should be have a zero installation but the webapps needs servlet container and my hoster does not support a servlet container or application server or so on.
I don't like an embedded solution because in this case each webapp must be delivered with a separate jetty und run with a separate jetty -> too big size -> to many download size and so on.
The architecture should be similar to this:
(source: sourceforge.net)
Example: Bundle1 could contains jetty and deployed webapp1 and Bundle2 could contains jetty and deployed webapp1 and webapp2 (related to requirements of end user I would like deliver many variant of my webapps)
But what is my question?
Which jars of jetty are needed? I would like these upload to my homepage for hosting.
Which jar should I use for jetty as main jar to start him via jnlp?
Which main class should I use to start jetty via jnlp?
Which parameter could I use to configure jetty to say this is war of webapp1 and this is war of webapp2.... or this is directory of weapps for hot deployment...?
The important question for me is 1. If this is answered so that I could run jetty local (without maven plugin) and via manual maybe I could solve the rest 2-4.
Why not deploy a normal Java app (with a main() etc.) that invokes Jetty programatically via its Server class? That class is configured via code with the appropriate contexts, servlet classes etc.
I've done that before with success. The only headache is running one Jetty with multiple apps being downloaded on request (if I read your question correctly). Can you use some classloading magic, and load classes/apps on demand from a remote URL ?
I have found another way today. This is interesting too. Here is the concept:
Use java webstart to install an osgi container
Use a bundle x or a osgi service to download all bundles of your app
Use the jetty bundle to provide jetty support
Then the application is installed
I got the idea from this article:
http://www.toedter.com/blog/?p=45