Serving .xhtml files directly

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Serving .xhtml files directly

Tambet Matiisen
Hi!

We were using .xhtml files directly with Orbeon separate deployment option with no problems. But now we decided to go for integrated deployment, because we had to make changes in Orbeon anyway and having one WAR file simplifies deployment in Weblogic significantly. But now simply putting .xhtml files to xforms-jsp directory doesn't work any more. I'm getting error "Cannot load "/apps/xforms-jsp/page-flow.xml" with webapp loader".

I figured out, that this is because of orbeon-main-servlet installed for webapp context root. I cannot remove it, because then Orbeon's own css and js files are not served correctly. But I found out, that I can alter the behavior of orbeon-main-servlet in page-flow.xml. I hoped to overcome the problem by adding xhtml extension into list of files, that should be served directly:
<files path-info="(?!/([^/]+)/service/).+\.(gif|css|pdf|json|js|png|jpg|xsd|htc|ico|swf|xhtml|html|txt)" matcher="oxf:perl5-matcher"/>

Now I don't get this error any more, but the file returned is empty. After reading some docs I understood, that by "served directly" you meant "served directly from resource manager" not "served directly from webapp context root":
"With <files path-info="*.gif"/>, if a request reaches the PFC with the path images/logo.gif, the file oxf:/images/logo.gif is sent in response to that request. " (http://wiki.orbeon.com/forms/doc/developer-guide/page-flow-controller)

So I moved my files from webapp context root to WEB-INF/resources, but still no success - if I make request to http://localhost/orbeon/xforms-jsp/hello.xhtml, I get an empty page, even if I have WEB-INF/resources/xforms-jsp/hello.xhtml in place. The log contains only these lines (I have enabled debug of resources and utils):
2011-11-03 01:21:36,638 INFO  ProcessorService  - /xforms-jsp/hello.xhtml - Received request
2011-11-03 01:21:36,675 INFO  ProcessorService  - /xforms-jsp/hello.xhtml - Timing: 37 - Cache hits for cache.main: 14, fault: 5, adds: 5, expirations: 0, success rate: 73%

What I'm doing wrong and what is the preferred way to get .xhtml files working with integrated deployment?

Regards
Tambet


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Serving .xhtml files directly

Tambet Matiisen
I finally got it working. Some remarks for others following the same path:

1. Files are served directly only from RESOURCES/apps directory. I don't know why apps receives such a special treatment and if it is configurable somehow. Changing oxf.url-rewriting.app-paths property didn't have any effect and in fact it shouldn't. So after moving my files under RESOURCES/apps folder and adding this to page-flow.xml

<files path-info="(?!/(fr|([^/]+)/service)/).+\.xhtml" matcher="oxf:perl5-matcher"/>

I was able to access my form at /orbeon/apps/xforms-jsp/hello.xhtml.

2. Documentation for oxf.url-rewriting.app-prefix property says, that Orbeon should prepend value of this property (default is '/apps') to every path that is not platform path or app path. But at first it didn't seem to work. After various tests I found out, that after turning off versioned resources (oxf.resources.versioned = false) or setting application version number to empty (oxf.resources.version-number = '') it started working as advertised. But I didn't want to turn off versioning globally. Luckily there is an option in page-flow.xml, that allows turning off versioning only for certain type of files:

<files path-info="(?!/(fr|([^/]+)/service)/).+\.xhtml" matcher="oxf:perl5-matcher" versioned="false"/>

With this trick I was able to access my forms with /orbeon/xforms-jsp/hello.xhtml path.

3. My forms contained utf-8 letters that didn't show up correctly. Luckily again page-flow.xml allows me to override mime type of returned files. So my final tweak to page-flow.xml was this:

<files path-info="(?!/(fr|([^/]+)/service)/).+\.xhtml" matcher="oxf:perl5-matcher" versioned="false" mime-type="application/xhtml+xml; charset=utf-8"/>

Thanks for great documentation!

  Tambet

On 3.11.2011 1:44, Tambet Matiisen wrote:
Hi!

We were using .xhtml files directly with Orbeon separate deployment option with no problems. But now we decided to go for integrated deployment, because we had to make changes in Orbeon anyway and having one WAR file simplifies deployment in Weblogic significantly. But now simply putting .xhtml files to xforms-jsp directory doesn't work any more. I'm getting error "Cannot load "/apps/xforms-jsp/page-flow.xml" with webapp loader".

I figured out, that this is because of orbeon-main-servlet installed for webapp context root. I cannot remove it, because then Orbeon's own css and js files are not served correctly. But I found out, that I can alter the behavior of orbeon-main-servlet in page-flow.xml. I hoped to overcome the problem by adding xhtml extension into list of files, that should be served directly:
<files path-info="(?!/([^/]+)/service/).+\.(gif|css|pdf|json|js|png|jpg|xsd|htc|ico|swf|xhtml|html|txt)" matcher="oxf:perl5-matcher"/>

Now I don't get this error any more, but the file returned is empty. After reading some docs I understood, that by "served directly" you meant "served directly from resource manager" not "served directly from webapp context root":
"With <files path-info="*.gif"/>, if a request reaches the PFC with the path images/logo.gif, the file oxf:/images/logo.gif is sent in response to that request. " (http://wiki.orbeon.com/forms/doc/developer-guide/page-flow-controller)

So I moved my files from webapp context root to WEB-INF/resources, but still no success - if I make request to http://localhost/orbeon/xforms-jsp/hello.xhtml, I get an empty page, even if I have WEB-INF/resources/xforms-jsp/hello.xhtml in place. The log contains only these lines (I have enabled debug of resources and utils):
2011-11-03 01:21:36,638 INFO  ProcessorService  - /xforms-jsp/hello.xhtml - Received request
2011-11-03 01:21:36,675 INFO  ProcessorService  - /xforms-jsp/hello.xhtml - Timing: 37 - Cache hits for cache.main: 14, fault: 5, adds: 5, expirations: 0, success rate: 73%

What I'm doing wrong and what is the preferred way to get .xhtml files working with integrated deployment?

Regards
Tambet



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Serving .xhtml files directly

Erik Bruchez
Administrator
Tambet,

Great to hear that you got it working!

The idea is that everything under /apps is, well, an Orbeon Forms "application".

The top-level page flow, when receiving a request for a page (as
opposed to a resource such as images etc.) of the form /foo/bar,
delegates that to the page flow for app "foo" under /apps, so
/apps/foo/page-flow.xml. We could have chosen to require URLs having
the form /apps/foo/bar, and that would probably have simplified things
a bit, but it's been done this way for historical reasons.

Then, when you refer to resources, the same issue arose. Back in 3.8
times and earlier, if you wanted to place you resources under
/apps/foo, you then *had* to write paths of the form
/apps/foo/image.png. And that was a bit confusing because:

* paths to pages would not require the /apps prefix
* paths to resources would require the /apps prefix

So we then change things so that URL rewriting would prepend the path
if omitted. This way, you can always write paths without the /apps
prefix.

This required making a determination of special "platform" paths, so
that paths to Orbeon Forms resources wouldn't have /apps prepended
automatically. So in the end, the following properties control all
this:

<property as="xs:string"  name="oxf.url-rewriting.platform-paths"
          value="^/(ops/|config/|xbl/orbeon/|forms/orbeon/|apps/fr/|xforms-server).*$"/>
<property as="xs:string"  name="oxf.url-rewriting.app-paths"
          value="^/(apps|xbl|forms)/.*$"/>
<property as="xs:string"  name="oxf.url-rewriting.app-prefix"
          value="/apps"/>

I hope this helps,

-Erik

On Thu, Nov 3, 2011 at 7:42 AM, Tambet Matiisen
<[hidden email]> wrote:

> I finally got it working. Some remarks for others following the same path:
>
> 1. Files are served directly only from RESOURCES/apps directory. I don't
> know why apps receives such a special treatment and if it is configurable
> somehow. Changing oxf.url-rewriting.app-paths property didn't have any
> effect and in fact it shouldn't. So after moving my files under
> RESOURCES/apps folder and adding this to page-flow.xml
>
> <files path-info="(?!/(fr|([^/]+)/service)/).+\.xhtml"
> matcher="oxf:perl5-matcher"/>
>
> I was able to access my form at /orbeon/apps/xforms-jsp/hello.xhtml.
>
> 2. Documentation for oxf.url-rewriting.app-prefix property says, that Orbeon
> should prepend value of this property (default is '/apps') to every path
> that is not platform path or app path. But at first it didn't seem to work.
> After various tests I found out, that after turning off versioned resources
> (oxf.resources.versioned = false) or setting application version number to
> empty (oxf.resources.version-number = '') it started working as advertised.
> But I didn't want to turn off versioning globally. Luckily there is an
> option in page-flow.xml, that allows turning off versioning only for certain
> type of files:
>
> <files path-info="(?!/(fr|([^/]+)/service)/).+\.xhtml"
> matcher="oxf:perl5-matcher" versioned="false"/>
>
> With this trick I was able to access my forms with
> /orbeon/xforms-jsp/hello.xhtml path.
>
> 3. My forms contained utf-8 letters that didn't show up correctly. Luckily
> again page-flow.xml allows me to override mime type of returned files. So my
> final tweak to page-flow.xml was this:
>
> <files path-info="(?!/(fr|([^/]+)/service)/).+\.xhtml"
> matcher="oxf:perl5-matcher" versioned="false"
> mime-type="application/xhtml+xml; charset=utf-8"/>
>
> Thanks for great documentation!
>
>   Tambet
>
> On 3.11.2011 1:44, Tambet Matiisen wrote:
>
> Hi!
>
> We were using .xhtml files directly with Orbeon separate deployment option
> with no problems. But now we decided to go for integrated deployment,
> because we had to make changes in Orbeon anyway and having one WAR file
> simplifies deployment in Weblogic significantly. But now simply putting
> .xhtml files to xforms-jsp directory doesn't work any more. I'm getting
> error "Cannot load "/apps/xforms-jsp/page-flow.xml" with webapp loader".
>
> I figured out, that this is because of orbeon-main-servlet installed for
> webapp context root. I cannot remove it, because then Orbeon's own css and
> js files are not served correctly. But I found out, that I can alter the
> behavior of orbeon-main-servlet in page-flow.xml. I hoped to overcome the
> problem by adding xhtml extension into list of files, that should be served
> directly:
> <files
> path-info="(?!/([^/]+)/service/).+\.(gif|css|pdf|json|js|png|jpg|xsd|htc|ico|swf|xhtml|html|txt)"
> matcher="oxf:perl5-matcher"/>
>
> Now I don't get this error any more, but the file returned is empty. After
> reading some docs I understood, that by "served directly" you meant "served
> directly from resource manager" not "served directly from webapp context
> root":
> "With <files path-info="*.gif"/>, if a request reaches the PFC with the path
> images/logo.gif, the file oxf:/images/logo.gif is sent in response to that
> request. "
> (http://wiki.orbeon.com/forms/doc/developer-guide/page-flow-controller)
>
> So I moved my files from webapp context root to WEB-INF/resources, but still
> no success - if I make request to
> http://localhost/orbeon/xforms-jsp/hello.xhtml, I get an empty page, even if
> I have WEB-INF/resources/xforms-jsp/hello.xhtml in place. The log contains
> only these lines (I have enabled debug of resources and utils):
> 2011-11-03 01:21:36,638 INFO  ProcessorService  - /xforms-jsp/hello.xhtml -
> Received request
> 2011-11-03 01:21:36,675 INFO  ProcessorService  - /xforms-jsp/hello.xhtml -
> Timing: 37 - Cache hits for cache.main: 14, fault: 5, adds: 5, expirations:
> 0, success rate: 73%
>
> What I'm doing wrong and what is the preferred way to get .xhtml files
> working with integrated deployment?
>
> Regards
> Tambet
>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing
> list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws