Add servlet in a clojure ring project - clojure

I am integrating Togglz library into a Clojure Ring project to support feature toggles and would like to activate the Togglz admin console. According to the Togglz documentation it is necessary to add a servlet in the /WEB-INF/web.xml file for projects that don't support Servlet 3.0. I used the :uberjar-merge-with leiningen plugin to merge the file with the Togglz servlet configuration with the web.xml file autogenerated by leiningen. However, this was not sufficient to activate the admin console.
I could not find much information on how to integrate a servlet from an external library into a Ring application. What would be the best way to do it?

I have not tried it myself, but the lein-servlet library seems to promise to do exactly that

Related

clojure How do you package jax-ws web service to war

I have successfully created a JAX-WS web service in clojure using definterface and deftype. How so I package this to a war file using lein ring uberwar so that I can deploy it in tomcat or any other servlet container? I cannot seem to find a way to do this.
I never tried that as usually I package my applications as JARs and use an embedded container such as Jetty.
However, it looks like that lein-ring is able to generate WAR files. I never tried that but maybe it will works for you even that you aren't using Ring library.
If it not working, then it is possible to extend Leiningen to create custom tasks. Properly you can create a task to package your project as WAR file. If so, please consider releasing it on Github later!

Objects and web-services in jBPM

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

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.

Auto-reloading WAR in Jetty standalone

I have a WAR deployed to Jetty 9.0.0.M3. I am trying to figure out what I need to set in my context in order to be able to have it reloaded every time I upload an updated war file (without having to restart Jetty).
I had a look at the docs, but I'm afraid I couldn't find what I was looking for. I only know how to do this with the embedded Jetty Maven plugin, but not with the standalone.
Any help would be appreciated! Thanks.
The key is in the deployer. You need to wire up the deployment manager functionality and have it manage the starting of the webapp.
http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/WebAppProvider.java
The jetty xml files are effectively a thin skin over java so look the following xml file which is what jetty uses for the traditional webapp startup of our distribution.
http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/jetty-deploy/src/main/config/etc/jetty-deploy.xml
This ought to get you fixed up.

Consuming a web service with the Netbeans Platform

I have an application that is written with the NetBeans Platform 5.5. I'm having trouble consuming a web service.
If I create a Java SE application in NetBeans, I can add a web service reference without problem.
Since my application is using the NetBeans Platform, many of the menu choices change. So, I cannot figure out how to add a reference to the web service. I've googled this topic a number of ways but haven't found any pages that deal with consuming a service through the platform. They all talk about consuming a service with a Java SE application.
Changing the application from the Platform architecture is not an option.
Here is a good tutorial for setting up a Feed Reader on NetBeans Platform. It covers some of the configuration issues for using web services
Blog with an entry about making a web services client
I'd be happy to try and give you a more specific answer if you can give information about the service you want to access.
Found this:
Create web service and client using this tutorial
Create library wrapper module for web service client (you don't need to include JAX-WS libs, only your client jar)
In your wrapper module add following dependencies (important):
JAX-WS 2.1 API
JAX-WS 2.1 and JAXB 2.1 Library (for this you have to check Show Non-API Modules in "Add Module Dependency" window)
If you try to build module after these steps it will fail telling you that your module is not friend of "path-to-netbeans"/java2/modules/org-netbeans-modules-websvc-jaxws21.jar.
Right click on JAX-WS 2.1 and JAXB 2.1 Library and choose Edit. Select Implementation Version.
from here.