Jetty in eclipse - loads static content from .war - java

I'm running Jetty from within Eclipse, installed with the Jetty Server Adaptor. I'm building a Tapestry app, and live class reloading works great. However, changes to static assets, such as images and css are not being instantly reflected: I have to do a Jetty restart-rebuild-redeploy, which is quite slow.
I think the reason for this is that my app is being deployed as a .war, and Jetty is reading static assets from here. Obviously the .war is only updated with a rebuild-redeploy.
How can I get Jetty to load static content directly from my workspace?
Thanks

It might not be possible to deploy an exploded war using the current version of the Jetty eclipse WTP plugin, at least according to this outstanding feature request.
An alternative solution would be to run Jetty manually instead of through Eclipse WTP, this would allow you to deploy the web app exploded. Although you'd need to hack a script together to copy static resources to the deployment directory as and when they change in the source folder in your eclipse project.

Adjusting a parameter in Jetty's webdefault.xml named useFileMappedBuffer to be false should prevent locking of static files when running Jetty from Eclipse.

Related

How can I make Tomcat interpret a jar library?

I'm working at a company that doesn't belong to the IT field, but its processes and data depend on a web application. My responsibility, as part of the IT team, is to update this application due to changes in the processes. The problem I have is that the former developers, that made this app with JAVA JDK 6, for some unknown reason, left a development environment on JBOSS and a production environment on Tomcat without the documentation to generate a war file on Tomcat.
Given this, I decided to substitute the .class and .xhtml files, which worked at the beginning. My problem is that one of my developments depends on the gson library, which JBOSS can interpret by copying the jar file to the server/default/lib, but when trying this same process with Tomcat (copying the jar file to lib folder from Tomcat or lib folder from the project), it doesn't work.
Could someone offer me an alternative so the project deployed on Tomcat identifies gson library?
Thanks beforehand for your help.
Putting in /WEB-INF/lib folder of the deployed webapp should work.
Restart your server after you add your jar.

Is there a way to deploy a Maven project with "jar" packaging into Tomcat7?

My project generates a Jar as the output package and uses an external War file, available on our Artifactory, as the Web Application to be deployed on Tomcat (currently using version 7). This War file contains all libs and modules required for the application to run.
I have already packaged and ran those projects outside eclipse on a "vanilla" Tomcat installation. In this scenario, the Jar my project generates is loaded on the context.xml file this way:
<Loader className="org.apache.catalina.loader.VirtualWebappLoader" virtualClasspath="/home/igor/workspace/myapp/myapp-2.4.3.jar"/>
Is there a way I can deploy this project on Tomcat using Eclipse and still be able to debug it? Can I use the Jar generated for this purpose or do I have to deploy the workspace project?
As for the War file, do (or can) I have to add it as an dependency?
Thanks in advance!
EDIT
We actually provide an Web Framework, which is packaged as a war. Other applications that use that framework are exported as jars and loaded into the framework through the context file as cited above.
Your question is confusing probably because of your custom plugin/classloader and deployment which is sort of orthogonal to debugging.
What I recommend is you keep whatever system you have to build/package/deploy and use JVM remote debugging. That is do not use the Eclipse WTP since you seem to have custom steps for deployment but rather build your code deploy & run a separate Tomcat instance and then run the remote debugger in Eclipse.
You will get some hotcode swapping with this method but not as much as something like JRebel.. (which you could use also) it will certainly be better than constantly redeploying.

How to Deploy to Intellij IDEA Tomcat Folder?

I use Intellij IDEA 11.1.2 Ultimate Edition. I run Tomcat 6 from Intellij IDEA. Beside my .war application I have another folder that has static HTML files. When I run tomcat manually from command line I put that folder under Tomcat's webapp folder and it automatically deploys it and works. However I want to debug my application so I want to run Tomcat from Intellij IDEA. I think that Intellij IDEA deploys tomcat applications into .IntelliJIdea11\system\tomcat folder. Where I can put my folder that contains static files when I run Tomcat from Intellij IDEA?
(I request the main page of static HTML file folder within an iframe at one of my HTML pages of .war file )
Any ideas?
Tomcat Run configuration has an option to deploy other applications from the server (that already present in the original webapps folder), like your static files:
Another option would be to create a second module for the static content with another artifact and deploy both artifacts from IntelliJ IDEA.
I think that CrazyCoder's answer is a little bit better. But here is my solution.
Go to File -> Project Structure...
Select your Web facet
In section Web resource directories click to +
Web resource directory path is your static content
Relative path in deployment directory is where you want to find it in your application war
If you want to debug you have no need to run Tomcat from IDEA. You can use remote debugging feature.
Just set up Tomcat to accept debug(listen to particular port). And create debug configuration from IDEA to attach to this port.

Using the gradle tomcat plugin

I am trying to fiddle with the gradle-tomcat-plugin and I am having some issues with some of the preliminaries. Assuming that my WAR is present in one of my folders, what do I need to do in order to run the war in an embedded tomcat using gradles tomcat plugin? The readme mentions the tomcatRunWar but I am a little lost as to how to use it in my gradle file
Any help would be appreciated.
Thanks
if you have set up everything right
go to your root directory (your build.gradle file should lie there), then execute
gradle tasks
and you should see tomcats different tasks
tomcatRun: Starts a Tomcat instance and deploys the exploded web
application to it.
tomcatRunWar: Starts a Tomcat instance and deploys
the WAR to it.
tomcatStop: Stops the Tomcat instance.
tomcatJasper:
Runs the JSP compiler (Jasper) and turns JSP pages into Java source
using.
and then you just run it
gradle tomcatRunWar
myself I prefer jetty plugin

GWT app - deploying on Tomcat or any other servlet container

Is there a plugin for Eclipse GWT or any other method to automatically deploy and run GWT app on Tomcat (or any other Serlvet container)? For the moment the only method I know is copying the compiled classes into WEB-INF directory but this is an arduous work. Additionally you have to configure Apache Tomcat manually. I'd like to have something like in Eclipse Dynamic Web Project where you can run your servlets directly by spawning tomcat process.
Thanks
You could write an Ant task to deploy and run your GWT app. It could copy the files and then tell your servlet container to reload the latest files.
Is this what you are looking for: "How do I use my own server in hosted mode instead of GWT's built-in Jetty instance?"?
PS: You only need to copy the contents of the war folder once.
PPS: I'm assuming here you want to be able to easily deploy your app to Tomcat during development, since you are bringing up spawning Tomcat from Eclipse - meaning it's not a production server.

Categories

Resources