What are the Jersey versions compatible with Jackson 2.9.2 - jersey-2.0

Could you please help me with these 2 queries/Issues :
Can anyone who has worked on Jackson 2.9.2 ,let me know what is the compatible Jersey version for Jackson 2.9.2.I am currently using Jersey 2.23.2 but it does not work with Jackson 2.9.2.I get following error :
[ERROR ] SRVE0777E: Exception thrown by application class 'org.glassfish.jersey.servlet.WebComponent.serviceImpl:489'
javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.util.BeanUtil.okNameForSetter(Lcom/fasterxml/jackson/databind/introspect/AnnotatedMethod;)Ljava/lang/String;
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:489)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1290)
2) In general ,is there some way to find combination of Jars.I have faced this issue earlier also while finding right combination of Jersey and Spring jars.It will save my and other's facing same issue lot of time,if someone can guide on this.
Thanks.

As of mid November 2017, the most recent version of Jersey is 2.26.
Jersey supports Jackson via the jersey-media-json-jackson extension module, which is released under the same version number as Jersey core modules. This extension module contains the auto-discoverable JacksonFeature that registers the JacksonJsonProvider class for binding JSON to Java objects.
In the version 2.26, this extension depends on Jackson 2.8.4. While in the version 2.23.2, it depends on Jackson 2.5.4.
The BeanUtil.okNameForSetter(Annotated Method) method was deprecated in Jackson 2.5 and has been removed in Jackson 2.9.
To support the most recent version of Jackson, you could get rid of the jersey-media-json-jackson extension module.
Then add the jackson-jaxrs-json-provider module to your project and register the JacksonJsonProvider directly in your ResourceConfig or Application implementation.

I am getting the same error as below:
[ERROR ] SRVE0777E: Exception thrown by application class 'org.glassfish.jersey.servlet.WebComponent.serviceImpl:489'
javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException:
java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.util.BeanUtil.okNameForSetter(Lcom/fasterxml/jackson/databind/introspect/AnnotatedMethod;)Ljava/lang/String;
I was able to resolve above issue with
Jersey2 version: 2.23.2
Jackson version: 2.7.4

Related

Error upgrading to Mongo java driver 3.2.2

we have migrated to MongoDB 3.2.6. What could be the compatible mongo version jars for below dependencies,
mongo java driver version (org.mongodb)
spring data mongo version (org.springframework.data)
spring data commons version (spring-data-commons)
I have tried to upgrade these to 3.2.2 for java driver and 1.9.4.RELEASE for spring data and spring commons but facing maven compatible issues. Below 2 issues i'm unable to resolve as of now.
Kindly suggest what could be the problem.
Issue 1:
The type org.springframework.data.repository.query.QueryByExampleExecutor cannot be resolved. It is indirectly referenced from required .class files
Issue 2:
Error occured processing XML 'Invalid default: public abstract java.lang.Class
org.springframework.data.mongodb.repository.config.EnableMongoRepositories.repositoryBaseClass()'. See Error Log for more details
Tried mvn clean dependency:tree and it is successful. But mvn clean compile is failing with Issue 1 error mentioned above.
Answer:
I'm able to resolve both the issues by upgrading to 1.12.1 for spring-data-commons. This will resolve above mentioned compile time issues.
Below are my current settings.
mongo-java-driver to 3.2.2, spring-data-mongodb to 1.9.4.RELEASE, spring-data-commons to 1.12.1.
As per Spring data commons documentation Spring Data Commons I also upgraded my Spring framework version to 4.2.8.RELEASE.
Facing below issue which I couldn't resolve. Any ideas will be appreciated.
Issue1:
06:37:33.943 [localhost-startStop-1] DEBUG o.s.c.t.c.AnnotationAttributesReadingVisitor - Failed to class-load type while reading annotation metadata. This is a non-fatal error, but certain annotation metadata may be unavailable.
java.lang.ClassNotFoundException: javax.annotation.Nullable
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305) ~[catalina.jar:na]
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1139) ~[catalina.jar:na]
at org.springframework.core.type.classreading.RecursiveAnnotationAttributesVisitor.visitEnd(RecursiveAnnotationAttributesVisitor.java:47) ~[spring-core-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.asm.ClassReader.readAnnotationValues(ClassReader.java:1802) [spring-core-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.asm.ClassReader.readMethod(ClassReader.java:976) [spring-core-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.asm.ClassReader.accept(ClassReader.java:695) [spring-core-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.asm.ClassReader.accept(ClassReader.java:508) [spring-core-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:64) [spring-core-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:98) [spring-core-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102) [spring-core-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:93) [spring-core-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter.match(AbstractTypeHierarchyTraversingFilter.java:121) [spring-core-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter.match(AbstractTypeHierarchyTraversingFilter.java:105) [spring-core-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.data.repository.config.RepositoryConfigurationDelegate$LenientAssignableTypeFilter.match(RepositoryConfigurationDelegate.java:202) [spring-data-commons-1.12.1.RELEASE.jar:na]
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.isCandidateComponent(ClassPathScanningCandidateComponentProvider.java:346) [spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:280) [spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.data.repository.config.RepositoryConfigurationDelegate.multipleStoresDetected(RepositoryConfigurationDelegate.java:167) [spring-data-commons-1.12.1.RELEASE.jar:na]
at org.springframework.data.repository.config.RepositoryConfigurationDelegate.<init>(RepositoryConfigurationDelegate.java:88) [spring-data-commons-1.12.1.RELEASE.jar:na]
at org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport.registerBeanDefinitions(RepositoryBeanDefinitionRegistrarSupport.java:80) [spring-data-commons-1.12.1.RELEASE.jar:na]
Tried adding dependency jsr305 from com.google.code.findbugs but still seeing same exceptions.

akka-kryo-serialization ClassNotFoundException: scala.Enumeration$Val

Sometimes when updating a dependency version for my project, when I would run the project I would get the following error:
ERROR 09:31:34:241 apply$mcV$sp - Class could not be loaded and/or registered: scala.Enumeration$Val
ERROR 09:31:34:247 apply$mcV$sp - exception caught during akka-kryo-serialization startup: java.lang.ClassNotFoundException: scala.Enumeration$Val
java.lang.RuntimeException: Nonzero exit code: 1
at scala.sys.package$.error(package.scala:27)
I usually got lucky and was able to fix this by tweaking the versions of my dependencies.
Until I updated my akka version from 2.3.6 to 2.3.12, specifically akka-contrib which contains akka-cluster, akka-remote and akka-peristance.
Turns out that the problem was actually occurring during the transition between akka 2.3.8 and 2.3.9. Looking at the change log, I found that between these two versions the Scala version was upgraded from 2.11.4 to 2.11.5.
My project was building on scala 2.11.4. Upgrading to 2.11.5 fixed the problem.
I couldn't find any help online for this, and lost a couple days trying to figure this out. I'm hoping that this will help someone else out.

Overload GWT Date_CustomFieldSerializer

I'm trying to overload the GWT "Date_CustomFieldSerializer" ( GWT 2.5.1 with maven2 and java1.6 ).
I've read that it is possible to overload a serializer by creating the same package structure inside your own project.
In my case I reproduce the package com.google.gwt.user.client.rpc.core.java.util to overload the class Date_CustomFieldSerializer but it does not seem to work well.
When serializing the Date, GWT Date_CustomSerializer is used but when the Date is deserialized my own "Date_CustomSerializer" is used.
If I delete the compiled Date_CustomFieldSerializer.class off gwt-user.jar and gwt-servlet.jar then my own Date_CustomFieldSerializer is always used but this is a bad solution, I am after a clean way to say to GWT that uses my own serializer always.
For delvelopment I use jetty and maven with the gwt-maven-plugin and in production mode I use weblogic.
I try to compile my own version of GWT but it fails when I try to run it, the server says:
[ERROR] Unable to initialize static dispatcher
java.lang.UnsupportedClassVersionError: com/google/gwt/core/client/JavaScriptObject$ : Unsupported major.minor version 51.0
How can I set it up to use my own serializer without GWT custom compilation?
Is your version first on the classpath?
It'a the version of Java.
You must compile the GWT Jar and your class with the same version of java.
The version 51 is the Java 7 version. (How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version)
But the GWT must be compiled with java 6.
You must set your java source to 1.6

Using AspectJ/AJDT in RAD 7.5.5

I'm using RAD 7.5.5. I installed AJDT plugin from the download site:
http://archive.eclipse.org/tools/ajdt/34/update/
I converted one of the existing Java projects to an AspectJ project, added an aspect to print log statements on method start and end of a methodA(), rebuilt the project and deployed.
I'm getting the below exception when methodA() is called:
Exception thrown : java.lang.NoSuchMethodError: org/aspectj/runtime/reflect/Factory.makeMethodSig(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lorg/aspectj/lang/reflect/MethodSignature;
I googled and found this could be caused because of an older version of aspectjrt.jar. But RAD extends Eclipse 3.4 and hence I added the version of AJDT plugin that is compatible with Eclipse 3.4 (/RAD 7.5.5). Any pointers to what could be the problem?
Make sure that aspectjrt.jar is on your classpath. Also, make sure that it is the aspectjrt.jar that comes with AJDT.

configuring Play framework with Scala to use Neo4j graph db

I'm using scala in my app, it run without problem, but if I add neo4j in the dependencies, it throws a NoSuchMethod error. I didn't even have references to any neo4j classes in my code...
I have no problem using play framework with scala, or play framework (Java) with neo4j, just when using both together, it crash...
and I tried both neo4j 1.4.2 and 1.5.M02 to no avail.
thanks for any help~
Chris
dependencies.yml
# Application dependencies
require:
- play
- play -> scala 0.9.1
- org.neo4j -> neo4j 1.4.2
exception details:
play.exceptions.UnexpectedException: Unexpected Error
at play.Invoker$Invocation.onException(Invoker.java:232)
at play.Invoker$Invocation.run(Invoker.java:273)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.NoSuchMethodError: scala.collection.generic.GenericTraversableTemplate.flatten(Lscala/Function1;)Lscala/collection/Traversable;
at play.scalasupport.compiler.PlayScalaCompiler$.scanFiles(ScalaCompiler.scala:18)
at play.scalasupport.compiler.PlayScalaCompiler$$anonfun$scanFiles$1.apply(ScalaCompiler.scala:17)
at play.scalasupport.compiler.PlayScalaCompiler$$anonfun$scanFiles$1.apply(ScalaCompiler.scala:15)
at play.scalasupport.compiler.PlayScalaCompiler$.scanFiles(ScalaCompiler.scala:15)
at play.scalasupport.compiler.PlayScalaCompiler$$anonfun$scanFiles$1.apply(ScalaCompiler.scala:17)
at play.scalasupport.compiler.PlayScalaCompiler$$anonfun$scanFiles$1.apply(ScalaCompiler.scala:15)
at play.scalasupport.compiler.PlayScalaCompiler$.scanFiles(ScalaCompiler.scala:15)
at play.scalasupport.ScalaPlugin$$anonfun$templates$1.apply(ScalaPlugin.scala:178)
at play.scalasupport.ScalaPlugin$$anonfun$templates$1.apply(ScalaPlugin.scala:177)
at play.scalasupport.ScalaPlugin.templates(ScalaPlugin.scala:177)
at play.scalasupport.ScalaPlugin.update(ScalaPlugin.scala:195)
at play.scalasupport.ScalaPlugin.detectClassesChange(ScalaPlugin.scala:107)
at play.plugins.PluginCollection.detectClassesChange(PluginCollection.java:358)
at play.Play.detectChanges(Play.java:594)
at play.Invoker$Invocation.init(Invoker.java:186)
... 1 more
it turns out that scala-library-2.9.0-1.jar is included as a dependency for neo4j...
every time I run play dependencies it will be downloaded into the lib folder, after I delete it from the folder, it works without problem (so far I just have code for starting and shutting down of the DB).
The Cypher Query language depends on Scala. We will update that dependency to 2.9.1 for the 1.5 release.