Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-999

Guice: arbitrary order of binding declarations may lead to a problem during the initialization due to missing conversion dependencies

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 3.0.6.Final
    • 3.0.4.Final
    • None
    • None
    • Compatibility/Configuration
    • Workaround Exists
    • Hide

      Design the order of registered modules in a way so that @Provider classes are bound before the resources that use them.

      Show
      Design the order of registered modules in a way so that @Provider classes are bound before the resources that use them.

    Description

      Parameter converters are not found, during resource factory initialization, if bindings are not strictly ordered.

      Example:

      • Resource R uses type T as QueryParam or PathParam
      • Type T does not have a constructor with String parameters or valueOf(String) method
      • ParamConverter C is can convert from String to T and vice versa and is defined via a ParamConverterProvider P

      If the binding order is

      1. bind(P.class)
      2. bind(R.class)

      everything works just fine, but, if the resource class is bound before the converter provider, the standard exception regarding missing conversion information is shown

      java.lang.RuntimeException: Unable to find a constructor that takes a String param or a valueOf() or fromString() method for javax.ws.rs.QueryParam("<paramName>") on public <className>.<methodName>(<methodParams>) for basetype: <typeName>
      	at org.jboss.resteasy.core.StringParameterInjector.initialize(StringParameterInjector.java:217)
      	at org.jboss.resteasy.core.StringParameterInjector.<init>(StringParameterInjector.java:61)
      	at org.jboss.resteasy.core.QueryParamInjector.<init>(QueryParamInjector.java:28)
      	at org.jboss.resteasy.core.InjectorFactoryImpl.createParameterExtractor(InjectorFactoryImpl.java:85)
      	at org.jboss.resteasy.core.MethodInjectorImpl.<init>(MethodInjectorImpl.java:41)
      	at org.jboss.resteasy.core.InjectorFactoryImpl.createMethodInjector(InjectorFactoryImpl.java:76)
      	at org.jboss.resteasy.core.ResourceMethodInvoker.<init>(ResourceMethodInvoker.java:97)
      	at org.jboss.resteasy.core.ResourceMethodRegistry.processMethod(ResourceMethodRegistry.java:280)
      	at org.jboss.resteasy.core.ResourceMethodRegistry.register(ResourceMethodRegistry.java:251)
      	at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:221)
      	at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:193)
      	at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:179)
      	at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:156)
      	at org.jboss.resteasy.plugins.guice.ModuleProcessor.processInjector(ModuleProcessor.java:41)
      	at org.jboss.resteasy.plugins.guice.GuiceContextTest.testArbitraryInjection(GuiceContextTest.java:93)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
      	at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
      	at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
      	at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
      	at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
      	at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
      	at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
      	at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
      	at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
      	at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
      	at org.junit.runner.JUnitCore.run(JUnitCore.java:121)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
      	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
      

      Attachments

        Activity

          People

            patriot1burke@gmail.com Bill Burke (Inactive)
            kariem_jira Kariem Hussein (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: