Tapestry
  1. Tapestry
  2. TAPESTRY-2258

Error while autobuilding BeanEditForm's bean

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.11
    • Fix Version/s: 5.0.12
    • Component/s: tapestry-core
    • Labels:
      None
    • Environment:
      archlinux, sun jdk 1.6.0_03, jetty 6, tapestry 5.0.11

      Description

      The error is consequence of new feauture https://issues.apache.org/jira/browse/TAPESTRY-2202.

      The model bean User is typical hibernate entity:

      @Entity
      @Table(name = "user")
      public class User {

      public User() {
      }

      public User(Integer id)

      { ... }

      ...
      }

      Exception while autobuild:

      [ERROR] RequestExceptionHandler Processing of request failed with uncaught exception: Render queue error in SetupRender[admin/User:beaneditform.editor]: Exception instantiating instance of xx.model.User (for component 'admin/User:beaneditform.editor'): Error invoking constructor xx.model.User(Integer) (at User.java:51) (for service 'BeanModelSource'): No service implements the interface java.lang.Integer.
      org.apache.tapestry.internal.services.RenderQueueException: Render queue error in SetupRender[admin/User:beaneditform.editor]: Exception instantiating instance of xx.model.User (for component 'admin/User:beaneditform.editor'): Error invoking constructor xx.model.User(Integer) (at User.java:51) (for service 'BeanModelSource'): No service implements the interface java.lang.Integer. [at classpath:org/apache/tapestry/corelib/components/BeanEditForm.tml, line 8, column 81]
      at org.apache.tapestry.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:75)
      at org.apache.tapestry.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:84)
      at $PageRenderQueue_118ad47de45.render($PageRenderQueue_118ad47de45.java)
      at $PageRenderQueue_118ad47de3e.render($PageRenderQueue_118ad47de3e.java)
      at org.apache.tapestry.services.TapestryModule$19.renderMarkup(TapestryModule.java:1293)
      at org.apache.tapestry.services.TapestryModule$23.renderMarkup(TapestryModule.java:1402)
      at $MarkupRenderer_118ad47de46.renderMarkup($MarkupRenderer_118ad47de46.java)
      at org.apache.tapestry.services.TapestryModule$22.renderMarkup(TapestryModule.java:1383)
      at $MarkupRenderer_118ad47de46.renderMarkup($MarkupRenderer_118ad47de46.java)
      at org.apache.tapestry.services.TapestryModule$21.renderMarkup(TapestryModule.java:1365)
      at $MarkupRenderer_118ad47de46.renderMarkup($MarkupRenderer_118ad47de46.java)
      at org.apache.tapestry.services.TapestryModule$20.renderMarkup(TapestryModule.java:1347)
      at $MarkupRenderer_118ad47de46.renderMarkup($MarkupRenderer_118ad47de46.java)
      at $MarkupRenderer_118ad47de43.renderMarkup($MarkupRenderer_118ad47de43.java)
      at org.apache.tapestry.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:55)
      at $PageMarkupRenderer_118ad47de41.renderPageMarkup($PageMarkupRenderer_118ad47de41.java)
      at org.apache.tapestry.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:57)
      at $PageResponseRenderer_118ad47dd7e.renderPageResponse($PageResponseRenderer_118ad47dd7e.java)
      at org.apache.tapestry.internal.services.PageRenderRequestHandlerImpl.handle(PageRenderRequestHandlerImpl.java:59)
      at org.apache.tapestry.services.TapestryModule$29.handle(TapestryModule.java:1607)
      at $PageRenderRequestHandler_118ad47dd7f.handle($PageRenderRequestHandler_118ad47dd7f.java)
      at $PageRenderRequestHandler_118ad47dd72.handle($PageRenderRequestHandler_118ad47dd72.java)
      at org.apache.tapestry.internal.services.PageRenderDispatcher.process(PageRenderDispatcher.java:97)
      at org.apache.tapestry.internal.services.PageRenderDispatcher.dispatch(PageRenderDispatcher.java:73)
      at $Dispatcher_118ad47dd79.dispatch($Dispatcher_118ad47dd79.java)
      at $Dispatcher_118ad47dd6b.dispatch($Dispatcher_118ad47dd6b.java)
      at org.apache.tapestry.services.TapestryModule$13.service(TapestryModule.java:944)
      at xx.app.RequestFilter.service(EduRequestFilter.java:36)
      at $RequestHandler_118ad47dd6c.service($RequestHandler_118ad47dd6c.java)
      at org.apache.tapestry.internal.services.LocalizationFilter.service(LocalizationFilter.java:42)
      at $RequestHandler_118ad47dd6c.service($RequestHandler_118ad47dd6c.java)
      at org.apache.tapestry.services.TapestryModule$3.service(TapestryModule.java:553)
      at $RequestHandler_118ad47dd6c.service($RequestHandler_118ad47dd6c.java)
      at org.apache.tapestry.services.TapestryModule$2.service(TapestryModule.java:520)
      at $RequestHandler_118ad47dd6c.service($RequestHandler_118ad47dd6c.java)
      at org.apache.tapestry.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79)
      at $RequestHandler_118ad47dd6c.service($RequestHandler_118ad47dd6c.java)
      at org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93)
      at org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84)
      at org.apache.tapestry.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:77)
      at org.apache.tapestry.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:106)
      at $RequestHandler_118ad47dd6c.service($RequestHandler_118ad47dd6c.java)
      at $RequestHandler_118ad47dd65.service($RequestHandler_118ad47dd65.java)
      at org.apache.tapestry.services.TapestryModule$12.service(TapestryModule.java:924)
      at org.apache.tapestry.upload.internal.services.MultipartServletRequestFilter.service(MultipartServletRequestFilter.java:43)
      at $HttpServletRequestHandler_118ad47dd66.service($HttpServletRequestHandler_118ad47dd66.java)
      at org.apache.tapestry.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
      at $HttpServletRequestFilter_118ad47dd64.service($HttpServletRequestFilter_118ad47dd64.java)
      at $HttpServletRequestHandler_118ad47dd66.service($HttpServletRequestHandler_118ad47dd66.java)
      at $HttpServletRequestHandler_118ad47dd60.service($HttpServletRequestHandler_118ad47dd60.java)
      at org.apache.tapestry.TapestryFilter.doFilter(TapestryFilter.java:168)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
      at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
      at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
      at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
      at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211)
      at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
      at org.mortbay.jetty.Server.handle(Server.java:313)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
      at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:830)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
      at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
      at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
      Caused by: org.apache.tapestry.ioc.internal.util.TapestryException: Exception instantiating instance of xx.model.User (for component 'admin/User:beaneditform.editor'): Error invoking constructor xx.model.User(Integer) (at User.java:51) (for service 'BeanModelSource'): No service implements the interface java.lang.Integer. [at classpath:org/apache/tapestry/corelib/components/BeanEditForm.tml, line 8, column 81]
      at org.apache.tapestry.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:884)
      at org.apache.tapestry.internal.structure.ComponentPageElementImpl.access$100(ComponentPageElementImpl.java:54)
      at org.apache.tapestry.internal.structure.ComponentPageElementImpl$13.render(ComponentPageElementImpl.java:482)
      at org.apache.tapestry.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:63)
      ... 70 more
      Caused by: org.apache.tapestry.ioc.internal.util.TapestryException: Exception instantiating instance of xx.model.User (for component 'admin/User:beaneditform.editor'): Error invoking constructor xx.model.User(Integer) (at User.java:51) (for service 'BeanModelSource'): No service implements the interface java.lang.Integer. [at classpath:org/apache/tapestry/corelib/components/BeanEditForm.tml, line 8, column 81]
      at org.apache.tapestry.corelib.components.BeanEditor.doPrepare(BeanEditor.java:163)
      at org.apache.tapestry.corelib.components.BeanEditor$Prepare.execute(BeanEditor.java:47)
      at org.apache.tapestry.corelib.components.BeanEditor$Prepare.execute(BeanEditor.java:41)
      at org.apache.tapestry.corelib.internal.FormSupportImpl.storeAndExecute(FormSupportImpl.java:116)
      at org.apache.tapestry.corelib.components.BeanEditor.setupRender(BeanEditor.java:135)
      at org.apache.tapestry.corelib.components.BeanEditor.setupRender(BeanEditor.java)
      at org.apache.tapestry.internal.structure.ComponentPageElementImpl$13$1.run(ComponentPageElementImpl.java:478)
      at org.apache.tapestry.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:874)
      ... 73 more
      Caused by: java.lang.RuntimeException: Error invoking constructor xx.model.User(Integer) (at User.java:51) (for service 'BeanModelSource'): No service implements the interface java.lang.Integer.
      at org.apache.tapestry.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:62)
      at org.apache.tapestry.ioc.internal.ServiceResourcesImpl.autobuild(ServiceResourcesImpl.java:123)
      at org.apache.tapestry.internal.beaneditor.BeanModelImpl.newInstance(BeanModelImpl.java:75)
      at org.apache.tapestry.corelib.components.BeanEditor.doPrepare(BeanEditor.java:156)
      ... 80 more
      Caused by: java.lang.RuntimeException: No service implements the interface java.lang.Integer.
      at org.apache.tapestry.ioc.internal.RegistryImpl.getService(RegistryImpl.java:517)
      at org.apache.tapestry.ioc.internal.services.MasterObjectProviderImpl.provide(MasterObjectProviderImpl.java:46)
      at $MasterObjectProvider_118ad47dd3c.provide($MasterObjectProvider_118ad47dd3c.java)
      at org.apache.tapestry.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:621)
      at org.apache.tapestry.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:675)
      at org.apache.tapestry.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:50)
      at org.apache.tapestry.ioc.internal.util.InternalUtils.calculateParameterValue(InternalUtils.java:209)
      at org.apache.tapestry.ioc.internal.util.InternalUtils.calculateParameters(InternalUtils.java:239)
      at org.apache.tapestry.ioc.internal.util.InternalUtils.calculateParametersForConstructor(InternalUtils.java:227)
      at org.apache.tapestry.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:46)
      ... 83 more

        Activity

        Hide
        Igor Drobiazko added a comment -

        The problem is the different strategy for creating entities and services. Your solution is not acceptable because it will break almost everything in Tapestry itself and in all Tapestry apps. The constructor of a service with most parameters is chosen to create an instance of the service.

        What do you think about annotating your entities with your annotation? You would then tell Tapestry which annotation should be searched instead of @Inject. If this solution is acceptable for you, please fill a new issue for that.

        Show
        Igor Drobiazko added a comment - The problem is the different strategy for creating entities and services. Your solution is not acceptable because it will break almost everything in Tapestry itself and in all Tapestry apps. The constructor of a service with most parameters is chosen to create an instance of the service. What do you think about annotating your entities with your annotation? You would then tell Tapestry which annotation should be searched instead of @Inject. If this solution is acceptable for you, please fill a new issue for that.
        Hide
        Javarotti added a comment - - edited

        [Deleted] Thanks for the quick response!

        Show
        Javarotti added a comment - - edited [Deleted] Thanks for the quick response!
        Hide
        Howard M. Lewis Ship added a comment -

        You can now mark the constructor to use for injection by using the @Inject annotation on the constructor.

        @Inject and a few related annotations have moved from tapestry-ioc to tapestry-annotations.

        Show
        Howard M. Lewis Ship added a comment - You can now mark the constructor to use for injection by using the @Inject annotation on the constructor. @Inject and a few related annotations have moved from tapestry-ioc to tapestry-annotations.
        Hide
        Slava Shushkanov added a comment -

        we'v done like this but we think the feauture is useless. It forces us to write extra code & affects simplicity

        Show
        Slava Shushkanov added a comment - we'v done like this but we think the feauture is useless. It forces us to write extra code & affects simplicity
        Hide
        Howard M. Lewis Ship added a comment -

        The workaround here is to provide event handlers for the "prepare" event, and to explicitly instantiate the bean in code, rather than relying on Tapestry to do it.

        Show
        Howard M. Lewis Ship added a comment - The workaround here is to provide event handlers for the "prepare" event, and to explicitly instantiate the bean in code, rather than relying on Tapestry to do it.
        Hide
        Howard M. Lewis Ship added a comment -

        Seems like in this case, we need to give the BeanEditForm a little bit more information about which constructor to use. The default behavior for ObjectLocator is to use the constructor with the most parameters. I think we need another annotation for this purpose.

        Show
        Howard M. Lewis Ship added a comment - Seems like in this case, we need to give the BeanEditForm a little bit more information about which constructor to use. The default behavior for ObjectLocator is to use the constructor with the most parameters. I think we need another annotation for this purpose.
        Hide
        Slava Shushkanov added a comment -

        i think https://issues.apache.org/jira/browse/TAPESTRY-2202 is not a good idea at all
        services weaving to model beans is not beaneditform task

        Show
        Slava Shushkanov added a comment - i think https://issues.apache.org/jira/browse/TAPESTRY-2202 is not a good idea at all services weaving to model beans is not beaneditform task

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Slava Shushkanov
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development