Jersey 2.27 with Guice - Is this supported without the HK2-guice bridge - jersey-2.0

I have started using Jersey 2.27 to develop REST APIs. I could use Jersey-HK2 dependency to have dependency Injection working.
I tried to use Jersey-Guice as DI but it did not work.
Is this supported off the shelf ? Has anyone made it work with version 2.27 ?
For HK2 - the dependency is Jersey-HK2 , which has the version 2.27. Which is same as Jersey.
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>2.27</version>
</dependency>
But i did not find the jersey-guice of version 2.27. May be it is not supported as of yet in Jersey 2.27. Can anyone point me to any doc ?

Related

GWT 2.8 websocket support

Does jetty server in gwt 2.8 support websocket now? As I know it did not support before. If there is a positive answer, then how to make it work? Stripping out jetty-8 and replaceing it with jetty-9 is not a good idea I think.
then how to make it work?
I want to elaborate a bit on this after the GWT 2.8.0 release. The only thing required for using javax.websocket is the knowledge of the Jetty version packaged with GWT and the following set of Maven dependencies (see also the Jetty WebSocket examples on GitHub):
<project>
<properties>
<sdm.jetty.version>9.2.14.v20151106</sdm.jetty.version>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>${sdm.jetty.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server-impl</artifactId>
<version>${sdm.jetty.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</depencies>
</project>
Make doubly sure that the scope is provided - for the former two this will mean they are not packaged into the final app - you will be requiring those only when running the SuperDev-Mode (SDM). Ifjava.websocket-apiwas on your classpath probably the annotation-based configuration will not work at all (at least in embedded Tomcat and Jetty) due to the annotations being picked up by the wrong class loader (see also related question WebSocket 404 error for more info on this topic).
GWT 2.8 has switched to Jetty 9.2, and now supports Servlets 3.1 servlets container initializers, which I think are being used to setup WebSockets.
I haven't tried it but I suppose that you can now have WebSockets in DevMode, provided you add the required dependencies to the classpath.
You can also simply use a separate server rather than the one embedded into DevMode.

JAX-RS support in JBoss (Apache CXF, JBoss Resteasy)

I'm working on a java RESTful client using Apache CXF's Proxy-based API, deploying to JBoss 5.1.
Here's my dependency in POM:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>3.0.1</version>
</dependency>
I've written a test and it works just fine, but it doesn't work in application after deployment to JBoss. It fails with NPE after application start because #SessionContext was not injected for some reason and is null.
I suppose that there are some conflicts between dependencies, because when I change above POM to:
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>3.0.1</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
</exclusion>
</exclusions>
</dependency>
the application works fine (!) until it creates a proxy:
authenticationProxy = JAXRSClientFactory.create(
myServiceUrl,
IAuthenticationResource.class,
Collections.singletonList(jsonProvider));
At this point it hangs and fails by timeout.
I've tried to use Resteasy instead of CXF and had the same problem.
I've tried to detect conflicts in my POM using maven plugins, but it gave nothing.
I think that the problem is in JBoss. Does JBoss 5.1 support JAX-RS 2.0? Is there a default implementation of it within JBoss? Can I use Apache CXF 3.x.x in JBoss 5.1? Please advise
JAX-RS 2.0 is part of Java EE 7 Web Profile and JAX-RS 1.1 is part of Java EE 6 Web Profile.
JBoss AS 7.1 uses RESTEasy with JAX-RS 1.1, see JBoss AS 7.1 - JAX-RS Reference Guide.
JBoss AS 6 uses RESTEasy , see RESTEasy JAX-RS.
JBoss AS 5 has no implementation of JAX-RS, see RESTEasy JAX-RS, but some issues:
Resteasy has no special integration with JBoss Application Server so it must be configured and installed like any other container. There are some issues though. You must make sure that there is not a copy of servlet-api-xxx.jar in your WEB-INF/lib directory as this may cause problems. Also, if you are running with JDK 6, make sure to filter out the JAXB jars as they come with JDK 6.
If you use JBoss EAP 5.1 you find versions of JBoss AS, RESTEasy and Apache CXF at JBoss Enterprise Application Platform 5.

Best version of the mongodb gorm plugin for grails 2.2.x?

Will the current MongoDB GORM plugin work on grails 2.2.x versions ? Specifically grails 2.2.3.
Just a note, upgrading to grails 2.3 is really not an easy option for this app.
After a few tests, the last version of the mongodb Grails plugin compatible with Grails 2.2.x (2.2.4 in my case) seems to be 1.3.3.
Trying to use the version after (2.0.0) gives the following:
Plugin mongodb-2.0.0 requires version [2.3.2 > *] of Grails which your current Grails installation does not meet
You can use the latest one: 3.0.1
This version has support for mongodb 2.6
After experimenting with various combinations.
I have found that it's the 1.3.3 version of mongodb that worked for my grails version 2.2.3.
additional notes:
I also had to use the 1.1.9 versions grails-datastore-core and grails-datastore-simple
as the 1.1.8 versions were causing a class def not found for StatelessDatastore.
I use maven for my build so the final dependencies I added look like this:
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>mongodb</artifactId>
<version>1.3.3</version>
<scope>compile</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-datastore-core</artifactId>
<version>1.1.9.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-datastore-simple</artifactId>
<version>1.1.9.RELEASE</version>
<scope>compile</scope>
</dependency>
Thanks for the replies everyone.
watch out!
mongo 3.0.1 uses updated version of gorm/hibernate libs, which are incompatible with the ones delivered with hibernate:3.6.10.13 (the most recent version is 3.6.10.14, but when I try getting it, the dependency couldn't be resolved). That means, that the libs in the older versions of hibernate plugin can not be newer than that.
see or in namedQueries in Grails 2.3.8: AbstractMethodError for details.
I had to switch from 3.0.1 back to 3.0.0. If you want to upgrade you mongo java driver, you can do it via dependencies w/o upgrading the grails plugin. Heck! I even used aggregation in mongodb:1.0.0.RC3 :)

Arquillian and jboss-4.2.3.GA

i am workign on a jboss-4.2.3.GA project. Its a old project but we cant upgrade to new server.
I am trying to use Arquillian for JPA..
We are using folliwng entry in pom for JPA
<dependency>
<groupId>com.jboss</groupId>
<artifactId>ejb3-persistence.jar</artifactId>
<version>4.2.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>hibernate</groupId>
<artifactId>hibernate3</artifactId>
<version>3.2.4.SP1</version>
<scope>provided</scope>
</dependency>
I am trying to configure Arquillian but i am getting some issue like nosuchmethod found or some time no default container set.
Anyone help me what container i need to set and any dependency settings ?
Add the arquillian-bom to the dependencyManagement section of your pom, see the Getting Started Guide: http://arquillian.org/guides/getting_started/#add_the_arquillian_apis
That will update the version of the dependencies the jbossas adapter has on arquillian core. Without it you will be running a mix of Core 1.0.1.Final and Core X (what ever the adapter happens to be compiled against currently which may or may not be compatible with the 1.0.1.Final Core artifacts).

Using Drools on Jetty

I am trying to start up a webapp that uses Drools 5.2.0.M1. I get the following stacktrace on startup:
java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()[Lorg/eclipse/jdt/core/compiler/CategorizedProblem;
at org.drools.commons.jci.compilers.EclipseJavaCompiler$3.acceptResult(EclipseJavaCompiler.java:336)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:335)
at org.drools.commons.jci.compilers.EclipseJavaCompiler.compile(EclipseJavaCompiler.java:366)
at org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCompiler.java:51)
at org.drools.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java:366)
at org.drools.compiler.DialectCompiletimeRegistry.compileAll(DialectCompiletimeRegistry.java:55)
I have the jars in my pom:
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.2.0.M1</version>
</dependency>
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>3.5.1</version>
</dependency>
Why Can't it find CompilationResult.getProblems()?
JDT isn't backwards compatible.
Check the drools-compiler pom (of exactly the version you're using) on which version of ecj it depends and use that version. Or don't declare ecj at all, it's a transitive dependency for drools-compiler anyway.
PS: upgrade to drools 5.2.0.CR1 (or final once it's out)
I had a similar problem. I was having a web-app using Jetty 6. Jetty 6 which apparently bringing in a non-compatible version of JDT. After switching to Jetty 7 the problem was solved.