For a normal JSP web-app that provides web-services, where should the JAX-WS library jar files be placed?
<tomcat-home>/lib
or
<web-app>/WEB-INF/lib
and why?
In general, when are library files considered part of the container infrastructure or part of the web application?
DETAILS
I have implemented various JAX-WS web services following, among others, these guides:
https://jax-ws.java.net/2.2.10/docs
https://jaxenter.com/creating-soap-web-services-using-jax-ws-117689.html
http://www.mkyong.com/webservices/jax-ws/deploy-jax-ws-web-services-on-tomcat/
http://examples.javacodegeeks.com/enterprise-java/jws/jax-ws-web-services-on-tomcat/
http://www.java2blog.com/2013/03/jaxws-webservice-deployement-on-tomcat.html
Whilst the above guides were useful, there are differences in terms of both the required JAX-WS library jar files and where the JAX-WS library jar files should reside.
By trial and error, for JDK 1.8, Tomcat 8.0.30 & JAS-WS 2.2.10, this is the list of JAX-WS library jars that seem to be required:
gmbal-api-only.jar
ha-api.jar
jaxb-core.jar
jaxb-impl.jar
jaxws-api.jar
jaxws-rt.jar
management-api.jar
policy.jar
stax-ex.jar
streambuffer.jar
I am aware that the JDK contains some of the JAX-WS classes but these seem to be meant for standalone Java apps
ie all of the above jar files seem to be needed to avoid a ClassNotFoundException etc.
I have read the Tomcat 8 class-loader how-to
and appreciate that there is a parent-tree, hierarchal class loader and that jar files in:
<web-app>/WEB-INF/lib
are only available to that web app ie are hidden from other web apps
causes the app war file(s) to be bloated as each web app has it’s own copy
and that jar files in:
<tomcat-home>/lib
are available to and shared by all web apps
forces all web apps to use the same version of the library
libraries must be inter web-app shareable ie no statics, thread-safe etc
enables lookup via a JNDI Resource Factory eg JDBC, mail etc
suppresses memory leaks for DriverManager eg JDBC
The web services seem to work when the JAX-WS library jar files are in either location.
Looking at the Metro JAX-WS project,
where the JAX-WS library jars must be downloaded from, for now, I have put these into <tomcat-home>/lib as that is consistent with the ‘install’ option in the ant file.
As a general rule, I try not to pollute the web-container / app-server with unnecessary library jar files where possible as this can lead to conflicts for other web-apps that have to use a specific version of a required library.
Thanks for reading.
Had the same issue trying to deploy a web service to my local tomcat installation. I went the route of adding the jars you listed to get it going, but see the instructions of what's needed from Apache:
https://tomcat.apache.org/tomcat-8.0-doc/extras.html#Web_Services_support_(JSR_109)
...which I think will go a long way to minimizing the amount of jars that end up in your Tomcat's lib folder.
Related
I started app development with drop-wizard recently and a bit confusing how the whole thing works.
Where is the web app directory?
Is it possible to edit static files (JS, CSS) without needing to have a redeployment?
Thanks.
I have looked into this a bit more and will attempt to answer your questions:
Where is the web app directory
DW applications are not (meant as) web applications. They are deployed as an embedded system running a jetty embedded server and listening on some port(s). Having said that, there are certainly ways of packaging the application as a web application. (see link in comment)
Is it possible to edit static files (JS, CSS) without needing to have a redeployment? - Yes(ish)
This depends on you, really. There is a thing called an AssetBundle. These can be used to server static resources (from the classpath usually). This however is a mechanism you could use to implement your own AssetBundle that instead of serving files off the classpath, will serve files off the regular path.
Or, you could add your regular path to the classpath on startup so that the AssetBundle works.
Or, you could implement a ServletFilter for the AssetBundle (assets are not part of the jersey ecosystem) and implement your dynamic changes in the Filter.
Most of these will require restart for a reason or another. E.g.a custom implementation of a Filter obviously requires a redeploy. The Servlet returning assets also (I believe) employs a caching strategy that might require a restart (subject to your implementation).
For your UI: There is also a DW-views project that adds the ability to create views (with by default mustache templates) that can be powered from your application and served by the same REST endpoints.
Hope that helps,
After some more checking:
You can serve static resources from the file system and modify them as you go. They will be served correctly. How to do this:
Add an asset bundle with the resource path:
bootstrap.addBundle(new AssetsBundle("/assets2/", "/assets"));
This adds the root classpath resource assets2 and has it served statically from the endpoint assets.
The trick is that you have to add your file system location as a classpath resource. This can be done via arguments (or the classpath tab in the eclipse run configuration). You can google that relatively easy. However, you will have to remember that classpath resources behave differently from file system resources:
In my case I added to the classpath:
/home/artur/tmp/assets/
However, my Asset bundle serves from "assets2". Let's have a look at the file system:
artur#pandaadb:~/tmp/assets$ pwd
/home/artur/tmp/assets
artur#pandaadb:~/tmp/assets$ find .
.
./assets2
./assets2/test.txt
artur#pandaadb:~/tmp/assets$
So, in my file system location has been added as root, but assets are only served from the subfolder assets2
Now, all the resources that are located in assets2 can be modified at runtime and will be served by DW as a static resource.
Have fun playing around,
Artur
Is there somewhere I can download a plain Apache Felix with all the bundles required for running the latest Jetty 9?
I've been trying to do this by following the Jetty documentation to no avail, it's like trying to put together a puzzle where you don't know where the missing pieces are. Some of the bundles you get from Maven, others from the lib folder from a Jetty installation, and others you download from Eclipse Orbit.
NOTE: it would be great if the Jetty project just provided a zip file with all needed bundles for OSGi on each release, or even better, create a FatJar bundle, that by just releasing a FullJetty bundle would start the whole thing without having a zillion bundles that you never really use directly.
If you just take a look at the Apache Karaf project it's a OSGi Container based on Felix/Equinox and brings Jetty along with Pax-Web as service Layer.
The most benefit of this server is that you just don't need to care much about all those infrastructure bundles and just unpack it and develop your OSGi application with it.
Is it possible to consume web-services and/or use own libraries (and thus custom objects) into a jBPM workflow? Eventually, could I expose this process as (another) web-service?
You can use web services in jBPM, at least in version 5 and 6. I believe the tooling support in eclipse is minimal or non-existent however. Don't know about the support in web console. See Maciej's blog for details on that.
It is possible to use custom objects and own libraries in jBPM. You just have to make the libraries available to the jBPM runtime. If you're using your own application where you run jBPM, just include the libraries in the CLASSPATH. For the jBPM console, you will have to include the libraries in the lib/ directory of the war, or inside WEB-INF/classes if you have .class files.
Not sure if there is out of the box support for exposing jBPM services over web service. If all you want to do is orchestrate other web services and expose yourself as a web service, you could consider using a BPEL engine rather, like Apache ODE
jBPM can call web services and contain custom libraries. A jBPM project is a Maven project, so you can add dependencies to your POM to include custom libraries. You can call web services or execute any custom Java code you want by creating a "Domain-specific process." There is an example in the documentation about how to do that: http://docs.jboss.org/jbpm/v6.0.1/userguide/jBPMDomainSpecificProcesses.html
Also, if you deploy your projects into the jBPM web console, they can be started and controlled by a REST API. So yes, they are exposed as a REST web service. See this page in the documentation about the REST API: http://docs.jboss.org/jbpm/v6.0.1/userguide/jBPMRemoteAPI.html
For example, the following REST call can initiate a process (taken from the link above):
[POST] /runtime/{deploymentId}/process/{processDefId}/start
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
We have some legacy JAR files from a vendor that were previously distributed as an applet, but we'd now like to simplify as a web service.
While the code works when I run it natively within my Eclipse IDE, it fails when I attempt to call it from a web service client after exporting it as a WAR and deploying it on JBoss (5.0.1). The errors I'm getting are security related ("The jar file is not signed" and "WEB-INF/lib/****.jar is not signed by the specified signer.", depending on what modifications I make). Is there anyway for me to tell my application server to ignore JAR signing for this project?
My guess is that your jar has been signed (when it was distributed as an applet) and contains some garbage in META-INF. Remove *.SF, *.RSA, *.DSA from META-INF to "unsign" the jar if not needed.