You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Michel Erard <mi...@corix.ch> on 2008/04/16 12:02:07 UTC

Problem with Proxy

Hello, 

Im using cocoon 2.2 and have currently some problems, if there is a proxy in front of my application.

The application is deployed in a jetty and in my environement I'm usinga a apache httpd as proxy in front of the application with this configuraion:

<Location /APP_NAME/cocoon-forms-impl>
   ProxyPass        http://localhost:8888/APP_NAME/cocoon-forms-impl
   ProxyPassReverse http://localhost:8888/APP_NAME/cocoon-forms-impl
   ProxyPassReverseCookiePath / /
   Allow from all
</Location>

<Location /APP_NAME/cocoon-ajax-impl>
   ProxyPass        http://localhost:8888/APP_NAME/cocoon-ajax-impl
   ProxyPassReverse http://localhost:8888/APP_NAME/cocoon-ajax-impl
   ProxyPassReverseCookiePath / /
   Allow from all
</Location>

<Location /APP_NAME>
   ProxyPass        http://localhost:8888/APP_NAME
   ProxyPassReverse http://localhost:8888/APP_NAME
   ProxyPassReverseCookiePath / /
   Allow from all
</Location>

This works fine. In my sitemap I make the forms transformation like this:

<map:transform src="stylesheets/forms-style.xsl">
      <map:parameter name="dojo-resources" value="{servlet:ajax:/resource/external/dojo}" />
      <map:parameter name="forms-resources" value="{servlet:forms:/resource/external/forms}" />
</map:transform>

But know my Problem. In the productive installation I've another Proxy in front of the machine. The users are using an url like this:

https://www.HOST_NAME.com/LOGIN_PATH/APP_NAME/[...]

And now the dojo an forms resources aren't found any more. Because cocoon works internally with the webapp's name '/APP_NAME/cocoon-forms/...' and this url https://www.HOST_NAME.com/APP_NAME/cocoon-forms/.. is blocked by this WEB-Entry-Server.

My Solution for this problem was to set the dojo and forms resources relative:

<map:transform src="stylesheets/forms-style.xsl">
      <map:parameter name="dojo-resources" value="../cocoon-ajax-impl/resource/external/dojo" />
      <map:parameter name="forms-resources" value="../corix-forms-impl/resource/external/forms" />
</map:transform>

so the links to the javascripts in the generated html is now: https://www.HOST_NAME.com/LOGIN_PATH/APP_NAME/main/../cocoon-forms/[...]

this solution works nearly. The dojo.js for example is found by the browser. But when he makes a request to 

/APP_NAME/cocoon-ajax-impl/resource/external/dojo/__package__.js

I'm getting an error in the jetty. So the requests passes correctly through all the proxys, but cannot be processed by cocoon:

2008-04-16 11:33:49.313::WARN:  /debol2/cocoon-ajax-impl/resource/external/dojo/__package__.js
org.apache.cocoon.ResourceNotFoundException: Error during resolving of the input stream
        at <map:read> - file:///tmp/Jetty_0_0_0_0_8423_debol2-webapplication-1.3.war__debol2__-5lbx6w_28157/blocks/cocoon-ajax-impl/sitemap.xmap:32:74
        at <map:match> - file:///tmp/Jetty_0_0_0_0_8423_debol2-webapplication-1.3.war__debol2__-5lbx6w_28157/blocks/cocoon-ajax-impl/sitemap.xmap:31:54
        at org.apache.cocoon.components.source.util.SourceUtil.handle(SourceUtil.java:347)
        at org.apache.cocoon.reading.ResourceReader.generate(ResourceReader.java:390)
        at org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline.processReader(AbstractCachingProcessingPipeline.java:892)
        at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.process(AbstractProcessingPipeline.java:429)
        at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
        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 $Proxy21.process(Unknown Source)
        at org.apache.cocoon.components.treeprocessor.sitemap.ReadNode.invoke(ReadNode.java:94)
        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)
        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.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:491)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:367)
        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:185)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:689)
        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:391)
        at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:146)
        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:285)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:457)
        at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:751)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:500)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:209)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:357)
        at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:329)
        at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)
Caused by: org.apache.excalibur.source.SourceNotFoundException: resource://org/apache/cocoon/dojo/resources/__package__.js
        at org.apache.excalibur.source.impl.ResourceSource.getInputStream(ResourceSource.java:125)
        at org.apache.cocoon.reading.ResourceReader.generate(ResourceReader.java:388)
        ... 46 more

Does someone see a solution for this problem?

Regards, 

Mike


Re: Problem with Proxy

Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Michel Erard pisze:
> Hello,
> 
> Im using cocoon 2.2 and have currently some problems, if there is a 
> proxy in front of my application.
> 
> The application is deployed in a jetty and in my environement I'm usinga 
> a apache httpd as proxy in front of the application with this configuraion:
> 
> <Location /APP_NAME/cocoon-forms-impl>
>    ProxyPass        http://localhost:8888/APP_NAME/cocoon-forms-impl
>    ProxyPassReverse http://localhost:8888/APP_NAME/cocoon-forms-impl
>    ProxyPassReverseCookiePath / /
>    Allow from all
> </Location>
> 
> <Location /APP_NAME/cocoon-ajax-impl>
>    ProxyPass        http://localhost:8888/APP_NAME/cocoon-ajax-impl
>    ProxyPassReverse http://localhost:8888/APP_NAME/cocoon-ajax-impl
>    ProxyPassReverseCookiePath / /
>    Allow from all
> </Location>
> 
> <Location /APP_NAME>
>    ProxyPass        http://localhost:8888/APP_NAME
>    ProxyPassReverse http://localhost:8888/APP_NAME
>    ProxyPassReverseCookiePath / /
>    Allow from all
> </Location>
> 
> This works fine. In my sitemap I make the forms transformation like this:
> 
> <map:transform src="stylesheets/forms-style.xsl">
>       <map:parameter name="dojo-resources" 
> value="{servlet:ajax:/resource/external/dojo}" />
>       <map:parameter name="forms-resources" 
> value="{servlet:forms:/resource/external/forms}" />
> </map:transform>
> 
> But know my Problem. In the productive installation I've another Proxy 
> in front of the machine. The users are using an url like this:
> 
> https://www.HOST_NAME.com/LOGIN_PATH/APP_NAME/[...]
> 
> And now the dojo an forms resources aren't found any more. Because 
> cocoon works internally with the webapp's name 
> '/APP_NAME/cocoon-forms/...' and this url 
> https://www.HOST_NAME.com/APP_NAME/cocoon-forms/.. is blocked by this 
> WEB-Entry-Server.
> 
> My Solution for this problem was to set the dojo and forms resources 
> relative:
> 
> <map:transform src="stylesheets/forms-style.xsl">
>       <map:parameter name="dojo-resources" 
> value="../cocoon-ajax-impl/resource/external/dojo" />
>       <map:parameter name="forms-resources" 
> value="../corix-forms-impl/resource/external/forms" />
> </map:transform>
> 
> so the links to the javascripts in the generated html is now: 
> https://www.HOST_NAME.com/LOGIN_PATH/APP_NAME/main/../cocoon-forms/[...]
> 
> this solution works nearly. The dojo.js for example is found by the 
> browser. But when he makes a request to
> 
> /APP_NAME/cocoon-ajax-impl/resource/external/dojo/__package__.js
> 
> I'm getting an error in the jetty. So the requests passes correctly 
> through all the proxys, but cannot be processed by cocoon:

Your problem comes from the mismatch of URLs and this can't be fixed by relative URLs or other 
tricks like that. There are many cases where Cocoon uses absolute URLs (like one you mention above) 
because only such make sense. They are constructed using following pattern:

   /[DispatcherServletMountPath]/[SitemapServletMountPath]/[TheRest]

Where [DispatcherServletMountPath] is being configured in web.xml file from 
myCocoonWebapp/src/main/webapp/WEB-INF (assuming myCocoonWebapp has been created using archetype). 
The declaration looks following:

   <servlet-mapping>
     <servlet-name>DispatcherServlet</servlet-name>
     <url-pattern>/*</url-pattern>
   </servlet-mapping>

The [SitemapServletMountPath] part comes from SitemapServlet bean configuration (mountPath) and 
usually contains block's name. The rest is actual path relative to block's context.

If you want to prefix all absolute URLs with LOGIN_PATH then I would advise to change configuration 
of DispatcherServlet to:

   <servlet-mapping>
     <servlet-name>DispatcherServlet</servlet-name>
     <url-pattern>/LOGIN_PATH/*</url-pattern>
   </servlet-mapping>

And configuration of proxy, accordingly. General advice is to always have 1-1 mapping between 
absolute paths. This way you can be sure that you don't run into some nasty problems.

I hope that helps you.

-- 
Best regards,
Grzegorz Kossakowski

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