PAX-WEB: how to make jetty read static content outside war according to certain context

149 views
Skip to first unread message

iJava

unread,
Aug 17, 2016, 3:38:30 PM8/17/16
to OPS4J
I have a folder outside war /temp/mydata and I want static servlet read files from this folder when web context is /static/filestorage.
Besides I have other not default servlets, for example 5 servlets. And I need them also to work.

I've found solution in internet:
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="handler">
        <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
            <Set name="handlers">
                <Array type="org.eclipse.jetty.server.Handler">
                    <Item>
                        <Set name="handler">
                            <New class="org.eclipse.jetty.servlet.ServletContextHandler">
                                <Set name="contextPath">/static/filestorage</Set>
                                <Set name="handler">
                                    <New class="org.eclipse.jetty.server.handler.ResourceHandler">
                                        <Set name="resourceBase">/temp/mydata</Set>
                                    </New>
                                </Set>
                            </New>       
                        </Set>
                    </Item>
                </Array>
            </Set>
        </New>
    </Set>
</Configure>
However, it throws Config error at [Set:null] exception - BTW - what does it mean????. I have tried different ways to make arrays of handlers but the same result.
is it possible?

The following code works, but only static content from /temp/data. Other 5 servlets don't work. How to solve such problem?
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="handler">
    <New class="org.eclipse.jetty.servlet.ServletContextHandler">
        <Set name="contextPath">/static/filestorage</Set>
        <Set name="handler">
            <New class="org.eclipse.jetty.server.handler.ResourceHandler">
                <Set name="resourceBase">/temp/mydata</Set>
            </New>
        </Set>
    </New>      
</Set>
</Configure>

Achim Nierbeck

unread,
Aug 17, 2016, 4:12:44 PM8/17/16
to op...@googlegroups.com
Hi, 

regarding context handlers, take a look at the documentation. [1] 
As the Jetty file is interpreted after the server is started it needs special attention. 

regards, Achim 



--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master 

Reply all
Reply to author
Forward
0 new messages