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.

The best way to check the server classpath is to use the command line.

Example:

[jetty-distribution]$ java -jar start.jar --version
Use "java -jar start.jar --help" for more information.
Active Options: [Server, annotations, client, ext, jaas, jmx, jndi, jndi.demo, jsp, plus, resources, rewrite, websocket]
Version Information on 36 entries in the classpath.
Note: order presented here is how they would appear on the classpath.
      changes to the OPTIONS=[option,option,...] command line option will be reflected here.
 0:      9.0.3.v20130506 | ${jetty.home}/lib/jetty-xml-9.0.3.v20130506.jar
 1:  3.0.0.v201112011016 | ${jetty.home}/lib/servlet-api-3.0.jar
 2:      9.0.3.v20130506 | ${jetty.home}/lib/jetty-http-9.0.3.v20130506.jar
 3:      9.0.3.v20130506 | ${jetty.home}/lib/jetty-continuation-9.0.3.v20130506.jar
 4:      9.0.3.v20130506 | ${jetty.home}/lib/jetty-server-9.0.3.v20130506.jar
 5:      9.0.3.v20130506 | ${jetty.home}/lib/jetty-security-9.0.3.v20130506.jar
 6:      9.0.3.v20130506 | ${jetty.home}/lib/jetty-servlet-9.0.3.v20130506.jar
 7:      9.0.3.v20130506 | ${jetty.home}/lib/jetty-webapp-9.0.3.v20130506.jar
 8:      9.0.3.v20130506 | ${jetty.home}/lib/jetty-deploy-9.0.3.v20130506.jar
 9:      9.0.3.v20130506 | ${jetty.home}/lib/jetty-annotations-9.0.3.v20130506.jar
10:  1.1.0.v201108011116 | ${jetty.home}/lib/annotations/javax.annotation-1.1.0.v201108011116.jar
11:  3.1.0.v200803061910 | ${jetty.home}/lib/annotations/org.objectweb.asm-3.1.0.v200803061910.jar
12:      9.0.3.v20130506 | ${jetty.home}/lib/jetty-client-9.0.3.v20130506.jar
13:      9.0.3.v20130506 | ${jetty.home}/lib/jetty-jaas-9.0.3.v20130506.jar
14:      9.0.3.v20130506 | ${jetty.home}/lib/jetty-jmx-9.0.3.v20130506.jar
15:      9.0.3.v20130506 | ${jetty.home}/lib/jetty-jndi-9.0.3.v20130506.jar
16:      9.0.3.v20130506 | ${jetty.home}/lib/jetty-plus-9.0.3.v20130506.jar
17:  1.1.0.v201105071233 | ${jetty.home}/lib/jndi/javax.activation-1.1.0.v201105071233.jar
18:  1.4.1.v201005082020 | ${jetty.home}/lib/jndi/javax.mail.glassfish-1.4.1.v201005082020.jar
19:                1.1.1 | ${jetty.home}/lib/jndi/javax.transaction-1.1.1.v201105210645.jar
20:      9.0.3.v20130506 | ${jetty.home}/lib/jndi.demo/test-mock-resources-9.0.3.v20130506.jar
21:  2.2.0.v201303151357 | ${jetty.home}/lib/jsp/com.sun.el-2.2.0.v201303151357.jar
22:  2.2.0.v201303151357 | ${jetty.home}/lib/jsp/javax.el-2.2.0.v201303151357.jar
23:  1.2.0.v201105211821 | ${jetty.home}/lib/jsp/javax.servlet.jsp.jstl-1.2.0.v201105211821.jar
24:  2.2.0.v201112011158 | ${jetty.home}/lib/jsp/javax.servlet.jsp-2.2.0.v201112011158.jar
25:  2.2.2.v201112011158 | ${jetty.home}/lib/jsp/org.apache.jasper.glassfish-2.2.2.v201112011158.jar
26:  1.2.0.v201112081803 | ${jetty.home}/lib/jsp/org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar
27: 3.8.2.v20130121-145325 | ${jetty.home}/lib/jsp/org.eclipse.jdt.core-3.8.2.v20130121.jar
28:                (dir) | ${jetty.home}/resources
29:      9.0.3.v20130506 | ${jetty.home}/lib/jetty-rewrite-9.0.3.v20130506.jar
30:      9.0.3.v20130506 | ${jetty.home}/lib/websocket/websocket-api-9.0.3.v20130506.jar
31:      9.0.3.v20130506 | ${jetty.home}/lib/websocket/websocket-common-9.0.3.v20130506.jar
32:      9.0.3.v20130506 | ${jetty.home}/lib/websocket/websocket-server-9.0.3.v20130506.jar
33:      9.0.3.v20130506 | ${jetty.home}/lib/websocket/websocket-servlet-9.0.3.v20130506.jar
34:      9.0.3.v20130506 | ${jetty.home}/lib/jetty-util-9.0.3.v20130506.jar
35:      9.0.3.v20130506 | ${jetty.home}/lib/jetty-io-9.0.3.v20130506.jar

This is the best way to see what your start.ini + start.d + command line will result in on the server classpath.


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


On Wed, Jun 5, 2013 at 9:39 AM, Ranjith Koduri <nanikpranjith9@xxxxxxxxx> wrote:
I am not sure if jetty-rewrite.jar has been added to the classpath
 - check your .classpath file for jetty-rewrite

Thanks & Regards,
Ranjith
MS-MIS, Univ Of Illinois at Chicago.





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




Thank you Joakim & Thomas. How do I add jetty-rewrite.jar
to the class path?

I first added the following to the end
of my start.ini:

OPTIONS=rewrite
etc/jetty-rewrite.xml

            Without any
modifications to jetty-rewrite.xml, I do not get any exceptions. However, I am
not sure if jetty-rewrite.jar has been added to the classpath. According to the
link you sent me, I did:

java -jar start.jar --dry-run

The output of this did not seem to have jetty-rewrite.jar.
It did however have a number of jars in the lib directory. Any clues on how to add
jetty-rewrite.jar to the class path?

Thank you,
O. O.


________________________________
De: Joakim Erdfelt <joakim@xxxxxxxxxxx>
Para: O. Olson <olson_ot@xxxxxxxxx>; JETTY user mailing list <jetty-users@xxxxxxxxxxx>
Enviado: Miércoles, 5 de junio, 2013 10:52 A.M.
Asunto: Re: [jetty-users] Jetty 9 Redirect from Root to Sub-Directory.



Correction ...

OPTIONS=rewrite

to the end of the ${jetty.home}/start.ini


--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
webtide.com
Developer advice, services and support
from the Jetty & CometD experts
eclipse.org/jetty - cometd.org


On Wed, Jun 5, 2013 at 8:51 AM, Joakim Erdfelt <joakim@xxxxxxxxxxx> wrote:

Add OPTION=rewrite to your ${jetty.home/start.ini
>
>
>--
>Joakim Erdfelt <joakim@xxxxxxxxxxx>
>webtide.com
>Developer advice, services and support
>from the Jetty & CometD experts
>eclipse.org/jetty - cometd.org
>
>
>
>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
>>
>      
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users


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



Back to the top