Relative views in view states in a stream loaded from a jar file

I have a question regarding Spring Web Flow with JSF: How can I teach Spring Web Flow to load relative views like view = "pages / view.xhtml" to jar in the tomcat webapp classpath? After some research via google, I think Web Flow does not support this constellation out of the box.

Maybe some context to understand my question: - Streams are registered in multiple FlowRegistries (I solved this problem by doing my own implementation that finds all flowRegistries in the Spring context) - Streams can be either as a file resource outside of the path to classes, or in a jar in the classpath, that is, the streams of the source file are somewhere in WEB-INF / conf , and they are in the same position in the jar files, - Views in stream definitions are addressed relative to the stream description file

Now you can ask the question why we have both constellations, where the streams can be. At the moment we are trying to extract from a large group of webapp modules that contain all the functionality belonging to a specific domain. The approach is to bundle all the artifacts related to them within a single project, which can be built as a jar and then added to a webapp.

While there is no load of loading Spring beans for each jar, not knowing where our config files are located, the web thread causes some problems.

The first problem was that the flowRegistry is a monolith that cannot be split without doing anything in front of itself. This issue is addressed by using a custom thread registry.

But now I have come to the second problem: inside view states, we refer to pages regarding flow definition, as described in the documentation :

<view-state id="some-id" view="pages/somepage.xhtml"> ... </view-state>


Now, when I enter such a view state, the web thread throws an exception that tells me that this way is not supported:

A ContextResource is required to get relative view paths within this context;
the resource was ...


Search Engine Optimization Helped Solve This Problem: A Workaround for Banking Web Streams

But this workaround doesn't work as it has problems with my many thread registries.

Another option might be to not put everything in the jar, but I'm not sure if this is the best idea. There is probably everything that can be loaded from the classpath in the jar, and the rest are as clean files in a specific structure.

Any ideas? Thank you very much for your efforts and advice.


source to share

1 answer

I found a slightly different solution on my own after hours of trying and debugging my application on how to achieve the goal of the question.

  • The first step was to migrate from Tomcat 6 to Tomcat 7 due to a change in the Servlet API specification, which allowed me to solve my problem with minor changes.
  • I switched from relative link in view states to absolute addressing
  • I changed the directory structure of my jar file to match the new Servlet API: all file resources needed for JSF or Spring Webflow needed to be placed in META-INF / resources (see the Javadoc of ServletContext look for the getResource method, it indicates that I need)

These three steps allowed me to completely package the web streams and their resources in jar files.



All Articles