Starting Jetty 8 through arquillian does not start Servlet 3.0 App - jetty

When starting Jetty 8.1.17 through Arquillian my Servlet 3.0 Annotations do not get processed. The webapp seems to not work (i.e. #Path mappings do not respond). Deploying the same .war file to the standalone jetty 8.1.17 works.
Why?
I thought this would have something to do with the component "arquillian-jetty-embedded". This seems never to have been published for "8". But even when using it by building it local this won't resolve the issue.
While the sources are there: https://github.com/arquillian/arquillian-container-jetty/tree/master/jetty-embedded-8 they never made it into the maven central.
Furthermore http://arquillian.org/modules/arquillian-jetty-embedded-7-container-adapter/ implies that this would work for 7 and 8.
I also tried to add the container-dependency of
container 'org.eclipse.jetty:jetty-annotations:8.1.17.v20150415'
and using jettyPlus configuration. Still no success.

Related

Swagger with Resteasty 3 + Jetty 9.2 + JAX-RS 3

I am trying to configure an existing application to use Swagger. This application uses Resteasy 3 and Jetty 9.2 along with JAX-RS 3.
My changes are based on the explanations given on the Swagger wiki.
I have first added swagger 1.5.0 in my build.gradle before adding annotations #Api and #ApiOperation on a resource named SchedulerStateRest.
The next step was to edit my web.xml in order to hook up Swagger-Core in my Application and Initialize Swagger using Swagger's Servlet.
My issue is that when I launch my application, no resource is found when I browse /swagger.json or /swagger.yaml from http://localhost:8080. However, I get no error while starting Jetty and existing services are running and available.
I have enabled Jetty logs but I found no information relevant to me (the class in charge to launch Jetty embedded is JettyStarter).
By looking for similar problems, I found people who say that swagger content should be available at /v1/api-docs, so I tried different URLs but I always get a 404 error.
Recently, I found a gist from ben-manes for configuring swagger with Resteasy 3 + Guice 4. I tried to mimic its configuration and deduce the configuration for web.xml based on Guice-servlet explanations but I end up with the same problem as for the configuration explained above (no resource available are the expected address).
Since there is no error while starting embedded Jetty, I wonder if the issue is not related to a wrong address. Do you know how to list "resources" that are available on a Jetty instance?
I noticed that explanations on Swagger wiki are for Resteasy 2.X. Does it mean that Swagger is not compatible with Resteasy 3.x?
Ideas, suggestions, etc. to debug, solve the issue are welcome ;)
I actually figured it out yesterday. I'm going to post a sample application on git hub sometime this week since I can't find an example anywhere

WAR outside the EAR, not able to reference JAR inside EAR. In wildfly 8

I am migrating to Wildfly 8.2 from JBoss 5.1, I am deploying a Web Service using the resteasy and some EAR which has the code to get the requested data from the DB. Both the EAR which has multiple (6) JARs, but when I call the Web Service, it is not able to find the EAR and refer it's JARs
14:57:48,183 INFO [stdout] (default task-4) InitialContextFactory not defined - using default: org.jnp.interfaces.NamingContextFactory
14:57:48,184 ERROR [stderr] (default task-4) javax.naming.NameNotFoundException: bpc/AccountManagementService -- service jboss.naming.context.java.bpc.AccountManagementService
I have 2 separate deployment of EAR and WAR and both of them are deployed simultaneously and they both get deployed without any hassle.
Why are then not able to integrate is my issue right now.
If you migrated from jboss 5 to wildfly, you have to adjust your jndi lookups.. You are getting a NameNotFoundException, so probably you are performing a lookup using the old jndi syntax..
When you startup your server, the log will show you different jndi names for your ejbs..
If you are looking for an ejb from a war, and both of them are not bundled in the same ear, then you have to use the java:global naming type..
For example, assuming that AccountManagementService is an interface, annotate it with #Remote, and search it from your war using the following jndi syntax
java:global/earName/ejb-jar-name/AccountManagementService!com.example.AccountManagementServiceImpl
See if this document helps (Modify JNDI lookup code section) https://docs.jboss.org/author/display/AS71/Order+Application+Migration+from+EAP5.1+to+AS7
I resolved this issue by adding jboss-deployment-structure.xml in my WAR file under the web-inf folder
by adding dependency like
dependencies>
<module name="deployment.MY_EAR.ear.MY_EJB_JAR.jar"/>
</dependencies>
I have similar issue.
I am migrating from weblogic to wildfly.
One JAR which has only one property file and one EAR, both are deployed simultaneously without any issue.
From EAR application, need to access the property file from the JAR.
This is working fine in weblogic but wildfly not identifying the property file.

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.

How does one add or update a WAR file/folder to the default embedded Jetty server in a Restlet 2.1 Application?

I would like to develop a Restlet 2.1 Java SE or Java EE Application that uses a (default) Jetty server, as opposed to an external Jetty/Tomcat server.
But I would like to configure the WAR file/folder that Jetty is processing, even allowing for stop(), reconfigure() or reload(), start() to happen at run time. In the external case, I can use setWar("path to war file/folder") from the Jetty API to achieve my goal, so this is plan B. Plan A is to figure out how to do this from the Restlet 2.1 API.
I cannot see a way to do it and I'm hoping that I'm just missing an obvious, or even not-so-obvious solution.
I think the Jetty WebAppProvider will provide what you need. If not, have a look at my hot swap code for WAR files in an embedded Jetty on this thread.

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