krasserm / grails-jaxrs

JAX-RS Plugin for Grails
http://code.google.com/p/grails-jaxrs/
Apache License 2.0
50 stars 48 forks source link

jaxrs 0.11 grails 2.4.4 dependencies #59

Closed slackfarmer closed 8 years ago

slackfarmer commented 9 years ago

I am experiencing two issues with this plugin. Most of it, seems to be some kind of dependency hell.

1.) When I try to demarshal custom jax annotated objects for json I am getting the following:

    
2015-01-14 14:55:09,990 [http-bio-80-exec-4] ERROR org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver  - ClassNotFoundException occurred when processing request: [POST] /templateService/api/pageTemplates/test
org.codehaus.jackson.JsonFactory. Stacktrace follows:
java.lang.ClassNotFoundException: org.codehaus.jackson.JsonFactory
        at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:655)
        at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:765)
        at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:753)
        at com.sun.jersey.json.impl.reader.JsonXmlStreamReader.create(JsonXmlStreamReader.java:110)
        at com.sun.jersey.json.impl.Stax2JsonFactory.createReader(Stax2JsonFactory.java:137)
        at com.sun.jersey.json.impl.Stax2JsonFactory.createReader(Stax2JsonFactory.java:127)
        at com.sun.jersey.json.impl.BaseJSONUnmarshaller.createXmlStreamReader(BaseJSONUnmarshaller.java:116)
        at com.sun.jersey.json.impl.BaseJSONUnmarshaller.unmarshalJAXBElementFromJSON(BaseJSONUnmarshaller.java:111)
        at com.sun.jersey.json.impl.BaseJSONUnmarshaller.unmarshalFromJSON(BaseJSONUnmarshaller.java:100)
        at com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider.readFrom(JSONRootElementProvider.java:154)
        at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.readFrom(AbstractRootElementProvider.java:111)
        at com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:490)
        at com.sun.jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider$EntityInjectable.getValue(EntityParamDispatchProvider.java:123)
        at com.sun.jersey.server.impl.inject.InjectableValuesProvider.getInjectableValues(InjectableValuesProvider.java:86)
        at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$EntityParamInInvoker.getParams(AbstractResourceMethodDispatchProvider.java:153)
        at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:203)
        at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
        at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
        at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
        at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
        at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
        at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
        at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)
        at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)
        at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
        at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
        at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)
        at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:540)
        at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:715)
    

2.) The 0.11 version of the jaxrs plugin is not pulling it's dependencies automatically.

I have to add the following to my BuildConfig.groovy so that it can resolve the required dependencies.

    
        String restletVersion = '2.1.4'
        String jerseyVersion = '1.18.1'

        compile "org.restlet.gae:org.restlet:$restletVersion"

        compile("org.restlet.gae:org.restlet.ext.servlet:$restletVersion") {
            excludes 'org.restlet', 'servlet-api'
        }

        compile("com.sun.jersey:jersey-core:$jerseyVersion") {
            excludes 'jaxb-api', 'jsr311-api', 'junit', 'mail', 'org.osgi.core'
        }

        compile("com.sun.jersey:jersey-servlet:$jerseyVersion") {
            excludes 'ant', 'commons-io', 'javax.ejb', 'javax.servlet-api', 'jsp-api', 'junit', 'osgi_R4_core',
                    'persistence-api', 'weld-osgi-bundle'
        }

        compile("com.sun.jersey:jersey-server:$jerseyVersion") {
            excludes 'asm', 'commons-io', 'jaxb-api', 'jsr250-api', 'junit', 'mail', 'osgi_R4_core'
        }

        compile("com.sun.jersey:jersey-json:$jerseyVersion") {
            excludes 'jackson-core-asl', 'jackson-jaxrs', 'jackson-mapper-asl', 'jackson-xc', 'jaxb-impl', 'jettison', 'junit', 'org.eclipse.persistence.moxy'
        }

        compile("com.sun.jersey.contribs:jersey-spring:$jerseyVersion") {
            excludes 'jaxb-impl', 'jsr250-api', 'junit', 'servlet-api', 'testng', 'spring-core', 'spring-beans',
                    'spring-context', 'spring-web', 'spring-aop'
        }

        compile('javax.ws.rs:jsr311-api:1.1.1') {
            excludes 'junit'
        }
    
abhisheksahay commented 9 years ago

I tried adding all these dependencies in dependency.resolution block but then also its not working .
Can you please tell me where exactly I will have to add this piece of code in buildconfig.groovy

deschaefer commented 9 years ago

Hey - ran into the same issue.. Still new to the dependency strategies in grails and am struggling to make sense of it. Would I be better served to use a local build?

slackfarmer commented 9 years ago

I cloned the project from github, made some dependency updates, then deployed the plugin to my local artifactory repository.

If you go the artifactory route the "publish-plugin" command is really awesome.

All you need to do is add something like this to the bottom of your BuildConfig.groovy


grails.project.repos.myRepo.url = "http://mysite.internal.some.com:4280/artifactory/simple/plugins-release-local"
grails.project.repos.myRepo.type = "maven"
grails.project.repos.myRepo.username = "yourUsername"
grails.project.repos.myRepo.password = "yourPassword"
grails.project.repos.default = "myRepo"

then run: "grails publish-plugin" from the cloned jaxrs project folder.

slackfarmer commented 9 years ago

@abhisheksahay It should go in BuildConfig.groovy in the following spot


    dependencies {
        String restletVersion = '2.1.4'
        String jerseyVersion = '1.18.3'
        compile('com.wordnik:swagger-jaxrs_2.10:1.3.12'){
            exclude 'jackson-jaxrs-json-provider'
        }
        compile "org.restlet.gae:org.restlet:$restletVersion"
        compile("org.restlet.gae:org.restlet.ext.servlet:$restletVersion") {
            excludes 'org.restlet', 'servlet-api'
        }
        compile("com.sun.jersey:jersey-client:$jerseyVersion")
        compile("com.sun.jersey:jersey-core:$jerseyVersion") {
            excludes 'jaxb-api', 'jsr311-api', 'junit', 'mail', 'org.osgi.core'
        }
        compile("com.sun.jersey:jersey-servlet:$jerseyVersion") {
            excludes 'ant', 'commons-io', 'javax.ejb', 'javax.servlet-api', 'jsp-api', 'junit', 'osgi_R4_core',
                    'persistence-api', 'weld-osgi-bundle'
        }
        compile("com.sun.jersey:jersey-server:$jerseyVersion") {
            excludes 'asm', 'commons-io', 'jaxb-api', 'jsr250-api', 'junit', 'mail', 'osgi_R4_core'
        }
        compile("com.sun.jersey:jersey-json:$jerseyVersion") {
            excludes 'jackson-core-asl', 'jackson-jaxrs', 'jackson-mapper-asl', 'jackson-xc', 'jaxb-impl', 'jettison', 'junit', 'org.eclipse.persistence.moxy'
        }
        compile("com.sun.jersey.contribs:jersey-spring:$jerseyVersion") {
            excludes 'jaxb-impl', 'jsr250-api', 'junit', 'servlet-api', 'testng', 'spring-core', 'spring-beans',
                    'spring-context', 'spring-web', 'spring-aop'
        }
        compile("com.sun.jersey.contribs:jersey-multipart:$jerseyVersion") {
        }
        compile('javax.ws.rs:jsr311-api:1.1.1') {
            excludes 'junit'
        }
    }

budjb commented 8 years ago

This issue was moved to budjb/grails-jaxrs#20