Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Jetty 9 Redirect from Root to Sub-Directory.

Add OPTION=rewrite to your ${jetty.home/start.ini

--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Developer advice, services and support
from the Jetty & CometD experts


On Wed, Jun 5, 2013 at 8:06 AM, O. Olson <olson_ot@xxxxxxxxx> wrote:


Hi,
 
            I did not
notice this before, but I get an exception when I started Jetty on the
Commandline. I did not notice this before because I thought the exception
should have been redirected to the log file.
 
2013-06-05 09:37:03.279:WARN:oejx.XmlConfiguration:main:
Config error at <New id
="Rewrite"
class="org.eclipse.jetty.rewrite.handler.RewriteHandler"><Set
name="r
ewriteRequestURI">true</Set><Set
name="rewritePathInfo">false</Set><Set name="or
iginalPathAttribute">requestedPath</Set><Call
name="addRule"><Arg>|          <Ne
w
class="org.eclipse.jetty.rewrite.handler.RedirectPatternRule"><Set
name="patte
rn">^$</Set><Set
name="replacement">/solr</Set></New>|        </Arg></Call></New
> java.lang.ClassNotFoundException:
org.eclipse.jetty.rewrite.handler.RewriteHan
dler in file:/C:/Users/<<MyUserName>>/Documents/Jetty/Jetty9/etc/jetty.xml
java.lang.reflect.InvocationTargetException
        at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at
java.lang.reflect.Method.invoke(Unknown Source)
        at
org.eclipse.jetty.start.Main.invokeMain(Main.java:509)
        at
org.eclipse.jetty.start.Main.start(Main.java:651)
        at
org.eclipse.jetty.start.Main.main(Main.java:99)
Caused by: java.lang.ClassNotFoundException:
org.eclipse.jetty.rewrite.handler.R
ewriteHandler
        at
java.net.URLClassLoader$1.run(Unknown Source)
        at
java.net.URLClassLoader$1.run(Unknown Source)
        at
java.security.AccessController.doPrivileged(Native Method)
        at
java.net.URLClassLoader.findClass(Unknown Source)
        at
java.lang.ClassLoader.loadClass(Unknown Source)
        at
java.lang.ClassLoader.loadClass(Unknown Source)
        at
org.eclipse.jetty.util.Loader.loadClass(Loader.java:100)
        at
org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.nodeClas
s(XmlConfiguration.java:354)
        at
org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.newObj(X
mlConfiguration.java:743)
        at
org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configur
e(XmlConfiguration.java:413)
        at
org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configur
e(XmlConfiguration.java:344)
        at
org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.jav
a:262)
        at
org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:12
24)
        at
java.security.AccessController.doPrivileged(Native Method)
        at
org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:116
0)
        ... 7 more
 
Usage: java -jar start.jar [options] [properties] [configs]
       java -jar
start.jar --help  # for more information
 
 
I think this may be the reason it is failing to redirect.
O. O.



________________________________
De: O. Olson <olson_ot@xxxxxxxxx>
Para: "jetty-users@xxxxxxxxxxx" <jetty-users@xxxxxxxxxxx>
Enviado: Miércoles, 5 de junio, 2013 9:30 A.M.
Asunto: Jetty 9 Redirect from Root to Sub-Directory.



Hi,

            I have
downloaded Jetty 9, and I am curious how to do a redirect from the root to a
particular sub directory. I basically want to redirect from http://localhost:7070/ to http://localhost:7070/solr/. I looked at http://www.eclipse.org/jetty/documentation/current/jetty-handlers.html#rewrite-handler and I added the following to the bottom of my jetty.xml.

<!-- create and configure the rewrite handler -->
    <New
id="Rewrite"
class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
      <Set
name="rewriteRequestURI">true</Set>
      <Set
name="rewritePathInfo">false</Set>
      <Set
name="originalPathAttribute">requestedPath</Set>

      <!-- redirect
the response. This is a redirect which is visible to the browser.
           After the
redirect, the browser address bar will show /redirected -->
      <Call name="addRule">
        <Arg>
          <New
class="org.eclipse.jetty.rewrite.handler.RedirectPatternRule">
            <Set
name="pattern">^$</Set>
            <Set
name="replacement">/solr</Set>
          </New>
        </Arg>
      </Call>
    </New>

            <!-- add
the rewrite handler to the server -->
    <Set
name="handler"><Ref id="Rewrite" /></Set>

 Is this pattern "^$"
correct for my situation? Thank you for all your help.

O. O.
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top