You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jeff Lubetkin <je...@zillow.com> on 2005/08/04 22:54:31 UTC

Creating my own Service Encoder in Tapestry 4.0 (beta 3)

I'm trying to create my own parameterized service encoder and running
into problems.  Does anyone have an example of the necessary
hivemodule.xml items?

 

Thanks,

jeff

 

P.S.  The gruesome details for those who have deeper knowledge of this
stuff and might be able to tell what I did wrong...

 

Here's what I've tried:

I've created a class (MyServiceEncoder) that implements ServiceEncoder
(at this stage, it's an almost direct copy of PageServiceEncoder).  Then
I added the following to my hivemodule.xml:

 

  <contribution configuration-id="tapestry.url.ServiceEncoders">

      <schema>

      <element name="my-service-encoder">

        

        <attribute name="id" required="true" unique="true">

          Unique id for this encoder, used when ordering encoder order.

        </attribute>

        <attribute name="before">

          List of ids of encoders that must come before this encoder.

        </attribute>

        <attribute name="after">

          List of ids of encoders that must follow this encoder.

        </attribute>

        

        <rules>

          <create-object
class="org.apache.tapestry.services.impl.ServiceEncoderContribution"/>

          <read-attribute attribute="id" property="id"/>

          <read-attribute attribute="before" property="before"/>

          <read-attribute attribute="after" property="after"/>

          <invoke-parent method="addElement"/>

          

          <create-object
class="com.zillow.web.services.MyServiceEncoder"/>

          <invoke-parent method="setEncoder"/>          

        </rules>        

      </element>

      </schema>

</contribution>   

 

When I attempt to hit any page, I get a bunch of exceptions.  After
digging through a bunch of rethrows, I found the root cause.  Basically,
Tapestry/Hivemind is trying to construct some services from the Tapestry
modules, and the classloader can't find them.  In this case it's trying
to construct "impl.RequestCycleFactoryImpl".  Looks to me like it's
missing the "org.apache.tapestry.services" piece.  Here's the stack
trace:

 

Thread [http-8080-Processor24] (Suspended (exception
ClassNotFoundException))

            URLClassLoader$1.run() line: not available

            AccessController.doPrivileged(PrivilegedExceptionAction<T>,
AccessControlContext) line: not available [native method]

            Launcher$ExtClassLoader(URLClassLoader).findClass(String)
line: not available

            Launcher$ExtClassLoader(ClassLoader).loadClass(String,
boolean) line: not available

            Launcher$AppClassLoader(ClassLoader).loadClass(String,
boolean) line: not available

            Launcher$AppClassLoader.loadClass(String, boolean) line: not
available

            Launcher$AppClassLoader(ClassLoader).loadClass(String) line:
not available

            WebappClassLoader.loadClass(String, boolean) line: 1247

            WebappClassLoader.loadClass(String) line: 1181

            WebappClassLoader(ClassLoader).loadClassInternal(String)
line: not available

            Class<T>.forName0(String, boolean, ClassLoader) line: not
available [native method]

            Class<T>.forName(String, boolean, ClassLoader) line: not
available

            DefaultClassResolver.lookupClass(String) line: 101

            DefaultClassResolver.checkForClass(String) line: 108

            ModuleImpl.resolveType(String) line: 191

            BuilderFactoryLogic.instantiateCoreServiceInstance() line:
100

            BuilderFactoryLogic.createService() line: 75

 
BuilderFactory.createCoreServiceImplementation(ServiceImplementationFact
oryParameters) line: 42

 
InvokeFactoryServiceConstructor.constructCoreServiceImplementation()
line: 84

 
SingletonServiceModel(AbstractServiceModelImpl).constructCoreServiceImpl
ementation() line: 107

 
SingletonServiceModel(AbstractServiceModelImpl).constructNewServiceImple
mentation() line: 157

 
SingletonServiceModel(AbstractServiceModelImpl).constructServiceImplemen
tation() line: 139

            SingletonServiceModel.getActualServiceImplementation() line:
68

            $RequestCycleFactory_1058336ab42._service() line: not
available

            $RequestCycleFactory_1058336ab42.newRequestCycle(IEngine)
line: not available

            $RequestCycleFactory_1058336ab41.newRequestCycle(IEngine)
line: not available

            ZillowEngine(AbstractEngine).service(WebRequest,
WebResponse) line: 231

            InvokeEngineTerminator.service(WebRequest, WebResponse)
line: 60

            $WebRequestServicer_1058336ab8f.service(WebRequest,
WebResponse) line: not available

            DisableCachingFilter.service(WebRequest, WebResponse,
WebRequestServicer) line: 48

            $WebRequestServicerFilter_1058336ab91.service(WebRequest,
WebResponse, WebRequestServicer) line: not available

            $WebRequestServicer_1058336ab93.service(WebRequest,
WebResponse) line: not available

            $WebRequestServicer_1058336ab8b.service(WebRequest,
WebResponse) line: not available

            WebRequestServicerPipelineBridge.service(HttpServletRequest,
HttpServletResponse) line: 56

 
$ServletRequestServicer_1058336ab6f.service(HttpServletRequest,
HttpServletResponse) line: not available

            DecodedRequestInjector.service(HttpServletRequest,
HttpServletResponse, ServletRequestServicer) line: 55

 
$ServletRequestServicerFilter_1058336ab6b.service(HttpServletRequest,
HttpServletResponse, ServletRequestServicer) line: not available

 
$ServletRequestServicer_1058336ab71.service(HttpServletRequest,
HttpServletResponse) line: not available

            MultipartDecoderFilter.service(HttpServletRequest,
HttpServletResponse, ServletRequestServicer) line: 52

 
$ServletRequestServicerFilter_1058336ab69.service(HttpServletRequest,
HttpServletResponse, ServletRequestServicer) line: not available

 
$ServletRequestServicer_1058336ab71.service(HttpServletRequest,
HttpServletResponse) line: not available

            SetupRequestEncoding.service(HttpServletRequest,
HttpServletResponse, ServletRequestServicer) line: 53

 
$ServletRequestServicerFilter_1058336ab6d.service(HttpServletRequest,
HttpServletResponse, ServletRequestServicer) line: not available

 
$ServletRequestServicer_1058336ab71.service(HttpServletRequest,
HttpServletResponse) line: not available

 
$ServletRequestServicer_1058336ab63.service(HttpServletRequest,
HttpServletResponse) line: not available

            ApplicationServlet.doService(HttpServletRequest,
HttpServletResponse) line: 145

            ApplicationServlet.doGet(HttpServletRequest,
HttpServletResponse) line: 101

            ApplicationServlet(HttpServlet).service(HttpServletRequest,
HttpServletResponse) line: 740

            ApplicationServlet(HttpServlet).service(ServletRequest,
ServletResponse) line: 853

            ApplicationFilterChain.internalDoFilter(ServletRequest,
ServletResponse) line: 252

            ApplicationFilterChain.doFilter(ServletRequest,
ServletResponse) line: 173

            StandardWrapperValve.invoke(Request, Response) line: 213

            StandardContextValve.invoke(Request, Response) line: 178

            StandardHostValve.invoke(Request, Response) line: 126

            ErrorReportValve.invoke(Request, Response) line: 105

            StandardEngineValve.invoke(Request, Response) line: 107

            CoyoteAdapter.service(Request, Response) line: 148

            Http11Processor.process(InputStream, OutputStream) line: 856

 
Http11Protocol$Http11ConnectionHandler.processConnection(TcpConnection,
Object[]) line: 744

            PoolTcpEndpoint.processSocket(Socket, TcpConnection,
Object[]) line: 527

            LeaderFollowerWorkerThread.runIt(Object[]) line: 80

            ThreadPool$ControlRunnable.run() line: 684

            ThreadWithAttributes(Thread).run() line: not available


Re: Creating my own Service Encoder in Tapestry 4.0 (beta 3)

Posted by Adam Greene <ag...@iq-2000.com>.
<!-- This is what registers your "Friendly URL" encoder -->

<contribution configuration-id="tapestry.url.ServiceEncoders">
    <encoder id="my" object="service:MyServiceEncoder"/> <!-- you can 
include before="" and after="" to control at what point in the encoder chain 
to insert your encoder -->
</contribution>

<!-- This adds your service to the Application -->

<contribution configuration-id="tapestry.services.ApplicationServices">
    <service name="category" object="service:Category" />
</contribution>

<!-- Implementation of the service -->

<service-point id="Category" 
interface="org.apache.tapestry.engine.IEngineService">
    <invoke-factory>
        <construct class="impl.CategoryService">
            <set-object property="responseRenderer" 
value="infrastructure:responseRenderer" />
            <set-object property="linkFactory" 
value="infrastructure:linkFactory" />
        </construct>
    </invoke-factory>
</service-point>

<!-- Implementation of the encoder -->

<service-point id="CategoryServiceEncoder" 
interface="org.apache.tapestry.engine.ServiceEncoder">
    <invoke-factory>
        <construct class="impl.CategoryServiceEncoder">
            <set-object property="session" 
value="service:dao.HibernateSession" />
            <set property="extension" value="clnk" /> <!-- this is an 
internal thing, not required by ServiceEncoder, but good to make things 
configurable :-) -->
        </construct>
    </invoke-factory>
</service-point>

----- Original Message ----- 
From: "Jeff Lubetkin" <je...@zillow.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, August 04, 2005 5:54 PM
Subject: Creating my own Service Encoder in Tapestry 4.0 (beta 3)


I'm trying to create my own parameterized service encoder and running
into problems.  Does anyone have an example of the necessary
hivemodule.xml items?



Thanks,

jeff



P.S.  The gruesome details for those who have deeper knowledge of this
stuff and might be able to tell what I did wrong...



Here's what I've tried:

I've created a class (MyServiceEncoder) that implements ServiceEncoder
(at this stage, it's an almost direct copy of PageServiceEncoder).  Then
I added the following to my hivemodule.xml:



  <contribution configuration-id="tapestry.url.ServiceEncoders">

      <schema>

      <element name="my-service-encoder">



        <attribute name="id" required="true" unique="true">

          Unique id for this encoder, used when ordering encoder order.

        </attribute>

        <attribute name="before">

          List of ids of encoders that must come before this encoder.

        </attribute>

        <attribute name="after">

          List of ids of encoders that must follow this encoder.

        </attribute>



        <rules>

          <create-object
class="org.apache.tapestry.services.impl.ServiceEncoderContribution"/>

          <read-attribute attribute="id" property="id"/>

          <read-attribute attribute="before" property="before"/>

          <read-attribute attribute="after" property="after"/>

          <invoke-parent method="addElement"/>



          <create-object
class="com.zillow.web.services.MyServiceEncoder"/>

          <invoke-parent method="setEncoder"/>

        </rules>

      </element>

      </schema>

</contribution>



When I attempt to hit any page, I get a bunch of exceptions.  After
digging through a bunch of rethrows, I found the root cause.  Basically,
Tapestry/Hivemind is trying to construct some services from the Tapestry
modules, and the classloader can't find them.  In this case it's trying
to construct "impl.RequestCycleFactoryImpl".  Looks to me like it's
missing the "org.apache.tapestry.services" piece.  Here's the stack
trace:



Thread [http-8080-Processor24] (Suspended (exception
ClassNotFoundException))

            URLClassLoader$1.run() line: not available

            AccessController.doPrivileged(PrivilegedExceptionAction<T>,
AccessControlContext) line: not available [native method]

            Launcher$ExtClassLoader(URLClassLoader).findClass(String)
line: not available

            Launcher$ExtClassLoader(ClassLoader).loadClass(String,
boolean) line: not available

            Launcher$AppClassLoader(ClassLoader).loadClass(String,
boolean) line: not available

            Launcher$AppClassLoader.loadClass(String, boolean) line: not
available

            Launcher$AppClassLoader(ClassLoader).loadClass(String) line:
not available

            WebappClassLoader.loadClass(String, boolean) line: 1247

            WebappClassLoader.loadClass(String) line: 1181

            WebappClassLoader(ClassLoader).loadClassInternal(String)
line: not available

            Class<T>.forName0(String, boolean, ClassLoader) line: not
available [native method]

            Class<T>.forName(String, boolean, ClassLoader) line: not
available

            DefaultClassResolver.lookupClass(String) line: 101

            DefaultClassResolver.checkForClass(String) line: 108

            ModuleImpl.resolveType(String) line: 191

            BuilderFactoryLogic.instantiateCoreServiceInstance() line:
100

            BuilderFactoryLogic.createService() line: 75


BuilderFactory.createCoreServiceImplementation(ServiceImplementationFact
oryParameters) line: 42


InvokeFactoryServiceConstructor.constructCoreServiceImplementation()
line: 84


SingletonServiceModel(AbstractServiceModelImpl).constructCoreServiceImpl
ementation() line: 107


SingletonServiceModel(AbstractServiceModelImpl).constructNewServiceImple
mentation() line: 157


SingletonServiceModel(AbstractServiceModelImpl).constructServiceImplemen
tation() line: 139

            SingletonServiceModel.getActualServiceImplementation() line:
68

            $RequestCycleFactory_1058336ab42._service() line: not
available

            $RequestCycleFactory_1058336ab42.newRequestCycle(IEngine)
line: not available

            $RequestCycleFactory_1058336ab41.newRequestCycle(IEngine)
line: not available

            ZillowEngine(AbstractEngine).service(WebRequest,
WebResponse) line: 231

            InvokeEngineTerminator.service(WebRequest, WebResponse)
line: 60

            $WebRequestServicer_1058336ab8f.service(WebRequest,
WebResponse) line: not available

            DisableCachingFilter.service(WebRequest, WebResponse,
WebRequestServicer) line: 48

            $WebRequestServicerFilter_1058336ab91.service(WebRequest,
WebResponse, WebRequestServicer) line: not available

            $WebRequestServicer_1058336ab93.service(WebRequest,
WebResponse) line: not available

            $WebRequestServicer_1058336ab8b.service(WebRequest,
WebResponse) line: not available

            WebRequestServicerPipelineBridge.service(HttpServletRequest,
HttpServletResponse) line: 56


$ServletRequestServicer_1058336ab6f.service(HttpServletRequest,
HttpServletResponse) line: not available

            DecodedRequestInjector.service(HttpServletRequest,
HttpServletResponse, ServletRequestServicer) line: 55


$ServletRequestServicerFilter_1058336ab6b.service(HttpServletRequest,
HttpServletResponse, ServletRequestServicer) line: not available


$ServletRequestServicer_1058336ab71.service(HttpServletRequest,
HttpServletResponse) line: not available

            MultipartDecoderFilter.service(HttpServletRequest,
HttpServletResponse, ServletRequestServicer) line: 52


$ServletRequestServicerFilter_1058336ab69.service(HttpServletRequest,
HttpServletResponse, ServletRequestServicer) line: not available


$ServletRequestServicer_1058336ab71.service(HttpServletRequest,
HttpServletResponse) line: not available

            SetupRequestEncoding.service(HttpServletRequest,
HttpServletResponse, ServletRequestServicer) line: 53


$ServletRequestServicerFilter_1058336ab6d.service(HttpServletRequest,
HttpServletResponse, ServletRequestServicer) line: not available


$ServletRequestServicer_1058336ab71.service(HttpServletRequest,
HttpServletResponse) line: not available


$ServletRequestServicer_1058336ab63.service(HttpServletRequest,
HttpServletResponse) line: not available

            ApplicationServlet.doService(HttpServletRequest,
HttpServletResponse) line: 145

            ApplicationServlet.doGet(HttpServletRequest,
HttpServletResponse) line: 101

            ApplicationServlet(HttpServlet).service(HttpServletRequest,
HttpServletResponse) line: 740

            ApplicationServlet(HttpServlet).service(ServletRequest,
ServletResponse) line: 853

            ApplicationFilterChain.internalDoFilter(ServletRequest,
ServletResponse) line: 252

            ApplicationFilterChain.doFilter(ServletRequest,
ServletResponse) line: 173

            StandardWrapperValve.invoke(Request, Response) line: 213

            StandardContextValve.invoke(Request, Response) line: 178

            StandardHostValve.invoke(Request, Response) line: 126

            ErrorReportValve.invoke(Request, Response) line: 105

            StandardEngineValve.invoke(Request, Response) line: 107

            CoyoteAdapter.service(Request, Response) line: 148

            Http11Processor.process(InputStream, OutputStream) line: 856


Http11Protocol$Http11ConnectionHandler.processConnection(TcpConnection,
Object[]) line: 744

            PoolTcpEndpoint.processSocket(Socket, TcpConnection,
Object[]) line: 527

            LeaderFollowerWorkerThread.runIt(Object[]) line: 80

            ThreadPool$ControlRunnable.run() line: 684

            ThreadWithAttributes(Thread).run() line: not available



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org