cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Cébélieu <gilles.cebel...@ign.fr>
Subject how to use the servlet service framework
Date Mon, 28 Apr 2008 15:57:05 GMT
Hello,


I'm using cocoon 2.2 and I want to use the servlet service framework to 
wrap POST calls to external webapps from within my cocoon webapp (as 
suggested in [1]).


As a beginning, I wrote a servlet that just outputs XML like this :

-----
public class WrapperServlet extends HttpServlet {

     public void doPost(HttpServletRequest request, HttpServletResponse 
response) throws ServletException, IOException
     {
     	response.setContentType("text/xml") ;
     	response.getWriter().write("<?xml version=\"1.0\"?>\n<data>POST 
!</data>") ;
     	
     }	

     public void doGet(HttpServletRequest request, HttpServletResponse 
response) throws ServletException, IOException
     {
     	response.setContentType("text/xml") ;
     	response.getWriter().write("<?xml version=\"1.0\"?>\n<data>GET 
!</data>") ;
      }		
}
------

I mount my servlet in my cocoon webapp in my servlet-service.xml 
declaration as follows (I'm just using one block) :

------
   <bean id="service" class="org.apache.cocoon.sitemap.SitemapServlet">
     <servlet:context mount-path="/" context-path="blockcontext:/block/">
       <servlet:connections>
         <entry key="servlet-wrapper" value-ref="servlet-wrapper"/>
       </servlet:connections>
     </servlet:context>

   </bean>

   <bean id="servlet-wrapper" class="WrapperServlet">
     <servlet:context mount-path="/servlet-wrapper"
                      context-path="blockcontext:/block/"/>
   </bean>
------

when I directly call the servlet, (eg : GET 
http://localhost:8888/servlet-wrapper), I have the response I expect.

But I don't manage to call the servlet from within the sitemap.
The following call :

----
        <map:match pattern="servlet">
         <map:generate src="servlet:/servlet-wrapper"/>
         <map:serialize type="xml"/>
       </map:match>
----


returns me exceptions like this :

--------
2008-04-28 17:47:51.439:/:INFO:  Apache Cocoon Spring Configurator 
v1.0.1 is running in mode 'dev'.
javax.servlet.ServletException: org.apache.cocoon.ProcessingException: 
Failed to process pipeline
	at [SAXParseException] - servlet:/rsc3-servlet-wrapper:1:55
	at <map:serialize type="xml"> - 
file:///home/gilles/workspace/cswisoap-block/./src/main/resources/COB-INF/sitemap.xmap:158:36
	at <map:generate> - 
file:///home/gilles/workspace/cswisoap-block/./src/main/resources/COB-INF/sitemap.xmap:157:60
	at <map:match> - 
file:///home/gilles/workspace/cswisoap-block/./src/main/resources/COB-INF/sitemap.xmap:153:37
	at 
org.apache.cocoon.servlet.RequestProcessor.service(RequestProcessor.java:232)
	at org.apache.cocoon.sitemap.SitemapServlet.service(SitemapServlet.java:64)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at 
org.apache.cocoon.servletservice.ServletServiceContext$PathDispatcher.forward(ServletServiceContext.java:567)
	at 
org.apache.cocoon.servletservice.ServletServiceContext$PathDispatcher.forward(ServletServiceContext.java:544)
	at 
org.apache.cocoon.servletservice.spring.ServletFactoryBean$ServiceInterceptor.invoke(ServletFactoryBean.java:230)
	at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
	at 
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
	at $Proxy5.service(Unknown Source)
	at 
org.apache.cocoon.servletservice.DispatcherServlet.service(DispatcherServlet.java:102)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at 
org.apache.cocoon.tools.rcl.wrapper.servlet.ReloadingServlet.service(ReloadingServlet.java:89)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
	at 
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
	at 
org.apache.cocoon.servlet.multipart.MultipartFilter.doFilter(MultipartFilter.java:119)
	at 
org.apache.cocoon.tools.rcl.wrapper.servlet.ReloadingServletFilter.doFilter(ReloadingServletFilter.java:50)
	at 
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.apache.cocoon.servlet.DebugFilter.doFilter(DebugFilter.java:169)
	at 
org.apache.cocoon.tools.rcl.wrapper.servlet.ReloadingServletFilter.doFilter(ReloadingServletFilter.java:50)
	at 
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at 
org.apache.cocoon.tools.rcl.wrapper.servlet.ReloadingSpringFilter.doFilter(ReloadingSpringFilter.java:69)
	at 
org.apache.cocoon.tools.rcl.wrapper.servlet.ReloadingServletFilter.doFilter(ReloadingServletFilter.java:50)
	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.cocoon.ProcessingException: Failed to process pipeline
	at [SAXParseException] - servlet:/rsc3-servlet-wrapper:1:55
	at <map:serialize type="xml"> - 
file:///home/gilles/workspace/cswisoap-block/./src/main/resources/COB-INF/sitemap.xmap:158:36
	at <map:generate> - 
file:///home/gilles/workspace/cswisoap-block/./src/main/resources/COB-INF/sitemap.xmap:157:60
	at <map:match> - 
file:///home/gilles/workspace/cswisoap-block/./src/main/resources/COB-INF/sitemap.xmap:153:37
	at 
org.apache.cocoon.ProcessingException.throwLocated(ProcessingException.java:143)
	at 
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.handleException(AbstractProcessingPipeline.java:921)
	at 
org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline.processXMLPipeline(AbstractCachingProcessingPipeline.java:382)
	at 
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.process(AbstractProcessingPipeline.java:437)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at 
org.apache.cocoon.core.container.spring.avalon.PoolableProxyHandler.invoke(PoolableProxyHandler.java:72)
	at $Proxy8.process(Unknown Source)
	at 
org.apache.cocoon.components.treeprocessor.sitemap.SerializeNode.invoke(SerializeNode.java:144)
	at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:55)
	at 
org.apache.cocoon.components.treeprocessor.sitemap.MatchNode.invoke(MatchNode.java:87)
	at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:77)
	at 
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:151)
	at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:77)
	at 
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:93)
	at 
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:240)
	at 
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:171)
	at 
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:251)
	at 
org.apache.cocoon.servlet.RequestProcessor.process(RequestProcessor.java:357)
	at 
org.apache.cocoon.servlet.RequestProcessor.service(RequestProcessor.java:171)
	... 38 more
Caused by: org.xml.sax.SAXParseException: White spaces are required 
between publicId and systemId.
	at 
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown 
Source)
	at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
	at org.apache.xerces.impl.XMLScanner.scanExternalID(Unknown Source)
	at 
org.apache.xerces.impl.XMLDocumentScannerImpl.scanDoctypeDecl(Unknown 
Source)
	at 
org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown 
Source)
	at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at 
org.apache.cocoon.core.xml.impl.JaxpSAXParser.parse(JaxpSAXParser.java:196)
	at 
org.apache.cocoon.core.xml.impl.JaxpSAXParser.parse(JaxpSAXParser.java:204)
	at 
org.apache.cocoon.components.source.util.SourceUtil.parse(SourceUtil.java:297)
	at 
org.apache.cocoon.generation.FileGenerator.generate(FileGenerator.java:144)
	at 
org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline.processXMLPipeline(AbstractCachingProcessingPipeline.java:363)
	... 57 more
-----



The question is : I am processing right ?

Thanks in advance.


Gilles


----------------------
[1] http://www.mail-archive.com/users@cocoon.apache.org/msg39592.html


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message