Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2425

Improve error message when trying to use an abstract class as a service implementation

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 5.4
    • 5.4
    • tapestry-ioc
    • None

    Description

      When binding an abstract class as a service implementation using ServiceBinder.bind(Class, Class), the exception is not very helpful:

      [ERROR] Registry [ 2] Invoking constructor public org.apache.tapestry5.ioc.AbstractGreeter() (for service 'AbstractGreeter')
      org.apache.tapestry5.ioc.internal.OperationException: Error invoking constructor public org.apache.tapestry5.ioc.AbstractGreeter(): java.lang.InstantiationException
      	at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.logAndRethrow(OperationTrackerImpl.java:184)
      	at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:90)
      	at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:72)
      	at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1258)
      	at org.apache.tapestry5.ioc.internal.util.ConstructionPlan.createObject(ConstructionPlan.java:61)
      	at org.apache.tapestry5.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:62)
      	at org.apache.tapestry5.ioc.internal.ReloadableServiceImplementationObjectCreator.createInstance(ReloadableServiceImplementationObjectCreator.java:54)
      	at org.apache.tapestry5.ioc.internal.AbstractReloadableObjectCreator$1.invoke(AbstractReloadableObjectCreator.java:136)
      	at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:82)
      	at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:72)
      	at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1258)
      	at org.apache.tapestry5.ioc.internal.AbstractReloadableObjectCreator.createInstance(AbstractReloadableObjectCreator.java:129)
      	at org.apache.tapestry5.ioc.internal.AbstractReloadableObjectCreator.createObject(AbstractReloadableObjectCreator.java:121)
      	at $Greeter_1eb73c5d7c1.delegate(Unknown Source)
      	at $Greeter_1eb73c5d7c1.getGreeting(Unknown Source)
      	at $Greeter_1eb73c5d7bf.getGreeting(Unknown Source)
      	at org.apache.tapestry5.ioc.Greeter$getGreeting.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
      	at ioc.specs.ServiceBinderSpec.$spock_feature_1_1(ServiceBinderSpec.groovy:25)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:138)
      	at org.spockframework.runtime.BaseSpecRunner.invokeRaw(BaseSpecRunner.java:330)
      	at org.spockframework.runtime.BaseSpecRunner.invoke(BaseSpecRunner.java:311)
      	at org.spockframework.runtime.BaseSpecRunner.invokeFeatureMethod(BaseSpecRunner.java:285)
      	at org.spockframework.runtime.BaseSpecRunner.doRunIteration(BaseSpecRunner.java:256)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:138)
      	at org.spockframework.runtime.BaseSpecRunner.invokeRaw(BaseSpecRunner.java:330)
      	at org.spockframework.runtime.BaseSpecRunner.invoke(BaseSpecRunner.java:311)
      	at org.spockframework.runtime.BaseSpecRunner.runIteration(BaseSpecRunner.java:223)
      	at org.spockframework.runtime.BaseSpecRunner.initializeAndRunIteration(BaseSpecRunner.java:214)
      	at org.spockframework.runtime.BaseSpecRunner.runSimpleFeature(BaseSpecRunner.java:205)
      	at org.spockframework.runtime.BaseSpecRunner.doRunFeature(BaseSpecRunner.java:199)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:138)
      	at org.spockframework.runtime.BaseSpecRunner.invokeRaw(BaseSpecRunner.java:330)
      	at org.spockframework.runtime.BaseSpecRunner.invoke(BaseSpecRunner.java:311)
      	at org.spockframework.runtime.BaseSpecRunner.runFeature(BaseSpecRunner.java:175)
      	at org.spockframework.runtime.BaseSpecRunner.runFeatures(BaseSpecRunner.java:152)
      	at org.spockframework.runtime.BaseSpecRunner.doRunSpec(BaseSpecRunner.java:112)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:138)
      	at org.spockframework.runtime.BaseSpecRunner.invokeRaw(BaseSpecRunner.java:330)
      	at org.spockframework.runtime.BaseSpecRunner.invoke(BaseSpecRunner.java:311)
      	at org.spockframework.runtime.BaseSpecRunner.runSpec(BaseSpecRunner.java:91)
      	at org.spockframework.runtime.BaseSpecRunner.run(BaseSpecRunner.java:82)
      	at org.spockframework.runtime.Sputnik.run(Sputnik.java:63)
      	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
      Caused by: java.lang.RuntimeException: Error invoking constructor public org.apache.tapestry5.ioc.AbstractGreeter(): java.lang.InstantiationException
      	at org.apache.tapestry5.ioc.internal.util.ConstructorInvoker.invoke(ConstructorInvoker.java:59)
      	at org.apache.tapestry5.ioc.internal.util.LoggingInvokableWrapper.invoke(LoggingInvokableWrapper.java:43)
      	at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:82)
      	... 65 more
      Caused by: java.lang.InstantiationException
      	at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
      	at org.apache.tapestry5.ioc.internal.util.ConstructorInvoker.invoke(ConstructorInvoker.java:50)
      	... 67 more
      

      ServiceBinderImpl should detect this case and fail early.

      Attachments

        Activity

          People

            jkemnade Jochen Kemnade
            jkemnade Jochen Kemnade
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: