Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9181287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:16:34+00:00 2026-06-17T18:16:34+00:00

I am trying to port some code from the Dropwizard examples from java to

  • 0

I am trying to port some code from the Dropwizard examples from java to groovy.

I see that within java, I can use the following code without any issues:

package com.example.helloworld;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

@Produces(MediaType.APPLICATION_JSON)
public class HelloWorldService{  

}

However, with the groovy compiler ( both 1.8 and 2.0.6 ), the class fails to compile with a noClassFoundException around MediaType.APPLICATION_JSON

If I change this code to use the actual string value

@Produces('application/json')
public class HelloWorldService{  

}

everything works perfectly.

Are there any differences between the way groovy resolves annotations and the way that java does?

For completeness, this is part of a gradle project and here is my build.gradle ( the file goes under src/groovy/com/example/helloworld )

apply plugin: 'groovy'

// Set our project variables
project.ext {
    dropwizardVersion = '0.6.1'
}

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'com.yammer.dropwizard', name: 'dropwizard-core', version: dropwizardVersion
    groovy group: 'org.codehaus.groovy', name: 'groovy-all', version: '1.8.7'
}

The compilation error is:

Caused by: java.lang.RuntimeException:
java.lang.ClassNotFoundException:
com.sun.ws.rs.ext.RuntimeDelegateImpl … 17 more Caused by:
java.lang.ClassNotFoundException:
com.sun.ws.rs.ext.RuntimeDelegateImpl at
org.gradle.api.internal.tasks.compile.TransformingClassLoader.findClass(TransformingClassLoader.java:47)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:16:35+00:00Added an answer on June 17, 2026 at 6:16 pm

    The problem is caused by an unfortunate limitation of the Groovy compiler, namely that it uses reflection to access classes on the compile class path. This may in turn trigger other classes to get loaded, which may not be available on the compile class path. Typically (but not always) these are runtime dependencies.

    In the concrete case, the Groovy compiler loads javax.ws.rs.core.MediaType via reflection, which ultimately results in com.sun.ws.rs.ext.RuntimeDelegateImpl being loaded via Class.forName (triggered by a static initializer), which isn’t on the compile class path. The solution is to put that class on the compile class path. (In the longer run, the solution is to fix the standalone Groovy compiler not to use reflection, and from what I know this is already in the queue.) If your module’s transitive dependencies aren’t an issue, the simplest way to achieve this is:

    dependencies {
        compile "com.sun.jersey:jersey-client:1.15" 
    }
    

    I suspect that the Eclipse Groovy compiler doesn’t have this problem because it doesn’t use reflection to access the compile class path. I’d expect GMaven to blow up like Gradle, unless it is configured to use the Eclipse compiler (which isn’t currently supported by Gradle).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to port some code form java do F# that generates a
I am trying to port some code from a regular Java program into the
I'm trying to port some code from Play Framework Java to Play Framework Scala
I'm trying to port some code from Java to Node.js, and I've run into
I am trying to port some code from java to C#, I have faced
I have some code that I am trying to port from Grails 1.3.7 to
I am trying to port some of my WebDriver tests from JAVA to C#.
I am trying to port some C++ code from Windows to Solaris(Unix). There are
I'm trying to port some code from VC9 to G++, however Ive run into
I'm trying to port some windows code that uses HidD_GetInputReport to linux using libusb.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.