Application requires explicit inclusion of fasterxml
mattjonesorg opened this issue · 14 comments
So, when I included the section mentioned in the wiki into my pom.xml of my appengine application (Ninja Framework):
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.1</version>
</dependency>
and ran the application, I got the following stack trace, repeatedly.
[java.net.URLClassLoader$1.run(URLClassLoader.java:366),java.net.URLClassLoader$1.run(URLClassLoader.java:355),java.security.AccessController.doPrivileged(Native Method),java.net.URLClassLoader.findClass(URLClassLoader.java:354),java.lang.ClassLoader.loadClass(ClassLoader.java:425),com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:216),java.lang.ClassLoader.loadClass(ClassLoader.java:358),java.lang.Class.forName0(Native Method),java.lang.Class.forName(Class.java:270),controllers.api.AuthenticationController.get(AuthenticationController.java:49),sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method),sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57),sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43),java.lang.reflect.Method.invoke(Method.java:606),com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115),ninja.params.ControllerMethodInvoker.invoke(ControllerMethodInvoker.java:56),ninja.FilterChainEnd.next(FilterChainEnd.java:48),ninja.NinjaDefault.onRouteRequest(NinjaDefault.java:82),ninja.servlet.NinjaServletDispatcher.service(NinjaServletDispatcher.java:83),com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:278),com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:268),com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:180),com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:93),com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:85),com.googlecode.objectify.cache.AsyncCacheFilter.doFilter(AsyncCacheFilter.java:59),com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:49),com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82),com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:120),com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:134),com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:131),com.google.inject.servlet.GuiceFilter$Context.call(GuiceFilter.java:208),com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:131),org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157),com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74),org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157),com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:127),org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157),com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34),org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157),com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63),org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157),com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43),org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157),com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125),org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157),com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366),com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349),com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116),org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157),org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388),org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216),org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182),org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765),org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418),com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98),org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152),com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:491),org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152),org.mortbay.jetty.Server.handle(Server.java:326),org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542),org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938),org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755),org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218),org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404),org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409),org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)]
The resolution of this was to manually include the dependency for fasterxml.
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.2</version>
</dependency>
I'm not sure why this is the case, but wanted to document it here just in case anybody else runs into this in the future.
BTW, This looks like an AWESOME library!
Thank you so much for the issue! I'll get a fix out right away.
And thanks for the kudos! Suggestions are welcome!
As far as the dependency - I'm a bit confused - all the test cases work without it. Might this be something specific to your app? (e.g. the Jackson lib we're using conflicts with one of yours perhaps?) Not sure...
I've tried really hard to reproduce this in a test app. I even tried including a different jackson, and it didn't fail. We have a bunch of dependencies in our app, so that is likely.
Here's one which looks like it may be a problem.
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.2</version>
</dependency>
I just looked in our build config. This is listed as an explicit compile-time dependency:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
(where ${jackson.version}
is set to 2.4.2
).
I ran mvn depencency:tree
, here's the output:
io.jsonwebtoken:jjwt:jar:0.2-SNAPSHOT
[INFO] +- org.slf4j:slf4j-api:jar:1.7.6:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.4.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.4.0:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.4.2:compile
[INFO] +- org.bouncycastle:bcprov-jdk15on:jar:1.51:runtime
[INFO] +- ch.qos.logback:logback-classic:jar:1.0.7:test
[INFO] | \- ch.qos.logback:logback-core:jar:1.0.7:test
[INFO] +- org.testng:testng:jar:6.8:test
[INFO] | +- junit:junit:jar:4.10:test
[INFO] | | \- org.hamcrest:hamcrest-core:jar:1.1:test
[INFO] | +- org.beanshell:bsh:jar:2.0b4:test
[INFO] | +- com.beust:jcommander:jar:1.27:test
[INFO] | \- org.yaml:snakeyaml:jar:1.6:test
[INFO] +- org.codehaus.groovy:groovy-all:jar:2.3.0-beta-2:test
[INFO] \- org.easymock:easymock:jar:3.1:test
[INFO] +- cglib:cglib-nodep:jar:2.2.2:test
[INFO] \- org.objenesis:objenesis:jar:1.2:test
which lists the jackson-databind
as a compile-time dependency already (and maven/gradle/ant+ivy/whatever will pull it in automatically).
If you remove the jackson-databind
dependency you added explicitly and then run mvn dependency:tree
what does it show?
Ah, yes - if you have Jackson < 2 in your project already, this will likely cause a conflict. I'll update the docs to reflect this, thank you!
I just updated the readme to cover this:
https://github.com/jwtk/jjwt/blob/master/README.md
I believe this to be a sufficient solution to this issue since I can't change the project's dependency settings (since they already explicitly reference a compile-time dependency). Thoughts?
Here is the dependency tree.
It actually was a runtime error rather than a compile or build error.
[INFO] org.myapp.www:phoenix:war:1.0-SNAPSHOT
[INFO] +- org.webjars:bootstrap:jar:3.1.1-1:compile
[INFO] | - org.webjars:jquery:jar:1.9.0:compile
[INFO] +- org.ninjaframework:ninja-appengine-module:jar:1.9.9:compile
[INFO] | +- org.slf4j:slf4j-jdk14:jar:1.7.7:compile
[INFO] | +- org.ninjaframework:ninja-servlet:jar:3.3.1:compile
[INFO] | | - com.google.inject.extensions:guice-servlet:jar:4.0-beta4:compile
[INFO] | +- javax.persistence:persistence-api:jar:1.0:compile
[INFO] | - com.google.appengine:appengine-api-1.0-sdk:jar:1.9.9:compile
[INFO] +- org.ninjaframework:ninja-test-utilities:jar:3.3.1:test
[INFO] | +- org.ninjaframework:ninja-core:jar:3.3.1:compile
[INFO] | | +- org.jsoup:jsoup:jar:1.7.2:compile
[INFO] | | +- com.google.inject:guice:jar:4.0-beta4:compile
[INFO] | | | +- javax.inject:javax.inject:jar:1:compile
[INFO] | | | - aopalliance:aopalliance:jar:1.0:compile
[INFO] | | +- com.google.inject.extensions:guice-assistedinject:jar:4.0-beta4:compile
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-afterburner:jar:2.4.1:compile
[INFO] | | +- org.freemarker:freemarker-gae:jar:2.3.20:compile
[INFO] | | +- commons-codec:commons-codec:jar:1.9:compile
[INFO] | | +- org.mindrot:jbcrypt:jar:0.3m:compile
[INFO] | | +- org.slf4j:jcl-over-slf4j:jar:1.7.7:compile
[INFO] | | +- org.slf4j:log4j-over-slf4j:jar:1.7.7:compile
[INFO] | | +- commons-io:commons-io:jar:2.4:compile
[INFO] | | +- org.apache.commons:commons-lang3:jar:3.3.2:compile
[INFO] | | +- org.apache.commons:commons-email:jar:1.3.2:compile
[INFO] | | | - javax.mail:mail:jar:1.4.5:compile
[INFO] | | +- commons-configuration:commons-configuration:jar:1.10:compile
[INFO] | | +- org.hibernate:hibernate-validator:jar:4.3.1.Final:compile
[INFO] | | | - javax.validation:validation-api:jar:1.0.0.GA:compile
[INFO] | | +- net.sf.ehcache:ehcache:jar:2.8.3:compile
[INFO] | | +- net.spy:spymemcached:jar:2.11.3:compile
[INFO] | | +- com.googlecode.flyway:flyway-core:jar:2.3.1:compile
[INFO] | | +- com.google.inject.extensions:guice-persist:jar:4.0-beta4:compile
[INFO] | | +- org.hibernate:hibernate-entitymanager:jar:4.3.5.Final:compile
[INFO] | | | +- org.jboss.logging:jboss-logging-annotations:jar:1.2.0.Beta1:compile
[INFO] | | | +- org.hibernate:hibernate-core:jar:4.3.5.Final:compile
[INFO] | | | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | | | - org.jboss:jandex:jar:1.1.0.Final:compile
[INFO] | | | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | | +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.4.Final:compile
[INFO] | | | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] | | | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.0.Final:compile
[INFO] | | | - org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] | | - org.hibernate:hibernate-c3p0:jar:4.3.5.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.1.3.GA:compile
[INFO] | | - com.mchange:c3p0:jar:0.9.2.1:compile
[INFO] | | - com.mchange:mchange-commons-java:jar:0.2.3.4:compile
[INFO] | +- org.ninjaframework:ninja-standalone:jar:3.3.1:test
[INFO] | | +- org.eclipse.jetty:jetty-server:jar:9.2.1.v20140609:test
[INFO] | | | +- org.eclipse.jetty:jetty-http:jar:9.2.1.v20140609:test
[INFO] | | | | - org.eclipse.jetty:jetty-util:jar:9.2.1.v20140609:test
[INFO] | | | - org.eclipse.jetty:jetty-io:jar:9.2.1.v20140609:test
[INFO] | | - org.eclipse.jetty:jetty-servlet:jar:9.2.1.v20140609:test
[INFO] | | - org.eclipse.jetty:jetty-security:jar:9.2.1.v20140609:test
[INFO] | +- org.mockito:mockito-core:jar:1.9.5:test
[INFO] | | - org.objenesis:objenesis:jar:1.0:test
[INFO] | +- org.fluentlenium:fluentlenium-core:jar:0.10.2:test
[INFO] | | - org.seleniumhq.selenium:selenium-java:jar:2.41.0:test
[INFO] | | +- org.seleniumhq.selenium:selenium-chrome-driver:jar:2.41.0:test
[INFO] | | | - org.seleniumhq.selenium:selenium-remote-driver:jar:2.41.0:test
[INFO] | | | +- cglib:cglib-nodep:jar:2.1_3:test
[INFO] | | | - org.json:json:jar:20080701:test
[INFO] | | +- org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.41.0:test
[INFO] | | | - net.sourceforge.htmlunit:htmlunit:jar:2.13:test
[INFO] | | | +- xalan:xalan:jar:2.7.1:test
[INFO] | | | | - xalan:serializer:jar:2.7.1:test
[INFO] | | | +- commons-collections:commons-collections:jar:3.2.1:test
[INFO] | | | +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.13:test
[INFO] | | | +- xerces:xercesImpl:jar:2.11.0:test
[INFO] | | | | - xml-apis:xml-apis:jar:1.4.01:test
[INFO] | | | +- net.sourceforge.nekohtml:nekohtml:jar:1.9.19:test
[INFO] | | | +- net.sourceforge.cssparser:cssparser:jar:0.9.11:test
[INFO] | | | | - org.w3c.css:sac:jar:1.3:test
[INFO] | | | - org.eclipse.jetty:jetty-websocket:jar:8.1.12.v20130726:test
[INFO] | | +- org.seleniumhq.selenium:selenium-firefox-driver:jar:2.41.0:test
[INFO] | | | - org.apache.commons:commons-exec:jar:1.1:test
[INFO] | | +- org.seleniumhq.selenium:selenium-ie-driver:jar:2.41.0:test
[INFO] | | | +- net.java.dev.jna:jna:jar:3.4.0:test
[INFO] | | | - net.java.dev.jna:platform:jar:3.4.0:test
[INFO] | | +- org.seleniumhq.selenium:selenium-safari-driver:jar:2.41.0:test
[INFO] | | +- org.seleniumhq.selenium:selenium-support:jar:2.41.0:test
[INFO] | | | - org.seleniumhq.selenium:selenium-api:jar:2.41.0:test
[INFO] | | - org.webbitserver:webbit:jar:0.4.14:test
[INFO] | | - io.netty:netty:jar:3.5.2.Final:test
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.3.4:compile
[INFO] | | - org.apache.httpcomponents:httpcore:jar:4.3.2:compile
[INFO] | +- org.apache.httpcomponents:httpmime:jar:4.3.4:compile
[INFO] | - com.devbliss.doctest:doctest:jar:0.7.0:test
[INFO] | +- com.google.code.gson:gson:jar:2.2.2:test
[INFO] | +- de.devbliss.apitester:apitester:jar:0.7.0:test
[INFO] | | - com.fasterxml:jackson-xml-databind:jar:0.6.2:test
[INFO] | | - org.codehaus.jackson:jackson-xc:jar:1.9.2:test
[INFO] | +- org.json:org.json:jar:chargebee-1.0:test
[INFO] | +- commons-lang:commons-lang:jar:2.6:compile
[INFO] | - javax.activation:activation:jar:1.1.1:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.0.1:provided
[INFO] +- com.google.appengine:appengine-api-stubs:jar:1.9.9:compile
[INFO] +- com.google.appengine:appengine-tools-sdk:jar:1.9.9:compile
[INFO] +- com.google.appengine:appengine-api-labs:jar:1.9.9:compile
[INFO] +- com.google.appengine:appengine-testing:jar:1.9.9:compile
[INFO] +- com.google.guava:guava:jar:17.0:compile
[INFO] +- junit:junit:jar:4.11:compile
[INFO] +- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] +- org.doctester:doctester-core:jar:1.1.3:compile
[INFO] | +- commons-fileupload:commons-fileupload:jar:1.3.1:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.3.1:compile
[INFO] | +- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.3.1:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.0:compile
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.3.1:compile
[INFO] | | - org.codehaus.woodstox:stax2-api:jar:3.1.1:compile
[INFO] | | - javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] | - org.slf4j:slf4j-api:jar:1.7.6:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.2:compile
[INFO] | - ch.qos.logback:logback-core:jar:1.1.2:compile
[INFO] +- com.googlecode.objectify:objectify:jar:4.1.3:compile
[INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
[INFO] | - org.codehaus.jackson:jackson-core-asl:jar:1.9.2:compile
[INFO] +- io.jsonwebtoken:jjwt:jar:0.1:compile
[INFO] | - com.fasterxml.jackson.core:jackson-databind:jar:2.4.2:compile
[INFO] - joda-time:joda-time:jar:2.4:compile
And while I have your attention, now that I realize who is on the other side of this, thank you for your videos on REST APIs. You've strongly influenced how I build APIs. 👍 :)
Updated the docs to reflect the runtime nature.
And thanks for the kind words - it's always nice to know if I've been helpful to others!
Closing this issue per updated docs. If you feel a need to re-open, please feel free!
I'm curious to watch the videos on REST APIs that was mentioned in @mattjonesorg last comment. Will someone add a link as a comment?
@axiopisty -- Here's one of my favorites: https://www.youtube.com/watch?v=hdSrT4yjS1g. And here's the written form: https://stormpath.com/blog/fundamentals-rest-api-design.
For some reason when using the gradle import I get the following:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
File1: /Users/gsyrimis/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.8.0/45b426f7796b741035581a176744d91090e2e6fb/jackson-annotations-2.8.0.jar
File2: /Users/gsyrimis/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.8.2/80004060cc6f71a027b81e89ef4d74628f824f/jackson-core-2.8.2.jar
File3: /Users/gsyrimis/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.8.2/1f12816593c1422be957471c98a80bfbace60fa2/jackson-databind-2.8.2.jar
When I inspected my dependencies it seems that jsonwebtoken is getting all three files, so I'm confused as to why it's finding duplicates
@GMSyrimis
Perhaps, is the cause of its problem here?
https://stackoverflow.com/questions/22467127/error-duplicate-files-during-packaging-of-apk
I solved it with this.
exclude 'META-INF/LICENSE'