0

I have a very simple webapp where I am trying to plot graphs using flot javascript library. My JSP file goes this way where I am importing the required *.js files as follows.

Relative to the hello.jsp file at WEB-INF/pages/hello.jsp, scripts directory with the relevant .js files are at ../../scripts (i.e. directly under ROOT)

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Flot Examples: Categories</title>
    <script src="http://code.jquery.com/jquery-latest.min.js"
        type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src="../../scripts/jquery.flot.js"></script>
    <script type="text/javascript">

    $(function() {
     //code draw the graph 
    </script>
</head>
<body>
        <h2>Categories</h2>
        <div id="placeholder" style="width:788px;height:400px"></div>
        <h3>End of Page</h3>
</body>
</html>

Directory structure is as follows root@domU-12-31-39-13-C5-F5:/usr/local/jetty/webapps# tree

.
|-- README.TXT
`-- ROOT
    |-- META-INF
    |   |-- MANIFEST.MF
    |   `-- maven
    |       `-- com.mkyong.common
    |           `-- SpringMVC
    |               |-- pom.properties
    |               `-- pom.xml
    |-- scripts
    |   |-- jquery.colorhelpers.js
    |   |-- jquery.flot.time.js
    |   |-- jquery.flot.time.min.js
    |   |-- jquery.js
    |   |-- jquery.min.js
    |   |-- LICENSE.txt
    |   |-- Makefile
    |   |-- NEWS.md
    |   |-- PLUGINS.md
    |   `-- README.md
    `-- WEB-INF
        |-- classes
        |   `-- com
        |       `-- mkyong
        |           `-- common
        |               `-- controller
        |                   `-- HelloController.class
        |-- hello.html
        |-- lib
        |   |-- aopalliance-1.0.jar
        |   |-- commons-logging-1.1.1.jar
        |   |-- spring-aop-3.0.5.RELEASE.jar
        |   |-- spring-asm-3.0.5.RELEASE.jar
        |   |-- spring-web-3.0.5.RELEASE.jar
        |   `-- spring-webmvc-3.0.5.RELEASE.jar
        |-- mvc-dispatcher-servlet.xml
        |-- pages
        |   |-- hello.html
        |   `-- hello.jsp
        `-- web.xml

Observations

  1. Using firefox eclipse, I can see that browser is requesting for GET http://ec2-184-73-14-57.compute-1.amazonaws.com:5809/scripts/jquery.flot.js but unable to find it hence fails with 404 Not found
  2. Moving the scripts directory to under WEB-INF and changing the relative paths is also resulting in the same error.
  3. Similar application deployed in tomcat is picking .js files from ROOT directory when referenced as /scripts/*.js
  4. Unable to reference the js files using absolute path and when I do, it tries to append the absolute path to http://ec2-184-73-14-57.compute-1.amazonaws.com:5809/ and trying to fetch it .. thus resulting in 404 error

Never used Jetty before, is this problem specific to Jetty? What is a better way to import javascript files. Please advice

Here is the dump after the start of the webapp

 2013-04-12 19:08:04.829:INFO:oejs.ServerConnector:main: Started ServerConnector@3ae0e5b7{HTTP/1.1}{0.0.0.0:5809}
    org.eclipse.jetty.server.Server@6a7ef378 - STARTING
     += qtp578065504{STARTED,10<=10<=200,i=8,q=0} - STARTED
     |   +- 12 qtp578065504-12-selector-0 RUNNABLE @ sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
     |   +- 13 qtp578065504-13-acceptor-0-ServerConnector@3ae0e5b7{HTTP/1.1}{0.0.0.0:5809} RUNNABLE @ sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
     |   +- 14 qtp578065504-14 TIMED_WAITING @ sun.misc.Unsafe.park(Native Method) IDLE
     |   +- 15 qtp578065504-15 TIMED_WAITING @ sun.misc.Unsafe.park(Native Method) IDLE
     |   +- 16 qtp578065504-16 TIMED_WAITING @ sun.misc.Unsafe.park(Native Method) IDLE
     |   +- 17 qtp578065504-17 TIMED_WAITING @ sun.misc.Unsafe.park(Native Method) IDLE
     |   +- 18 qtp578065504-18 TIMED_WAITING @ sun.misc.Unsafe.park(Native Method) IDLE
     |   +- 19 qtp578065504-19 TIMED_WAITING @ sun.misc.Unsafe.park(Native Method) IDLE
     |   +- 20 qtp578065504-20 TIMED_WAITING @ sun.misc.Unsafe.park(Native Method) IDLE
     |   +- 21 qtp578065504-21 TIMED_WAITING @ sun.misc.Unsafe.park(Native Method) IDLE
     += org.eclipse.jetty.util.thread.ScheduledExecutorScheduler@7c8b3bd8 - STARTED
     += org.eclipse.jetty.server.handler.HandlerCollection@582b0e7b - STARTED
     |   += org.eclipse.jetty.server.handler.ContextHandlerCollection@7e999262 - STARTED
     |   |   +~ org.eclipse.jetty.jmx.MBeanContainer@3a55b9b
     |   |   += o.e.j.w.WebAppContext@2f7e1b09{/,file:/usr/local/osmosix/jetty/webapps/ROOT/,AVAILABLE}{/ROOT} - STARTED
     |   |       += org.eclipse.jetty.server.session.SessionHandler@8a6bf88 - STARTED
     |   |       |   += org.eclipse.jetty.server.session.HashSessionManager@3620f49e - STARTED
     |   |       |   += org.eclipse.jetty.security.ConstraintSecurityHandler@5daa3e56 - STARTED
     |   |       |   |   +- org.eclipse.jetty.security.DefaultAuthenticatorFactory@12959ac0
     |   |       |   |   += org.eclipse.jetty.servlet.ServletHandler@72140bcb - STARTED
     |   |       |   |   |   += default@5c13d641==org.eclipse.jetty.servlet.DefaultServlet,0,false - STARTED
     |   |       |   |   |   |   +- maxCacheSize=256000000
     |   |       |   |   |   |   +- etags=true
     |   |       |   |   |   |   +- dirAllowed=true
     |   |       |   |   |   |   +- gzip=true
     |   |       |   |   |   |   +- maxCachedFileSize=200000000
     |   |       |   |   |   |   +- redirectWelcome=false
     |   |       |   |   |   |   +- acceptRanges=true
     |   |       |   |   |   |   +- welcomeServlets=false
     |   |       |   |   |   |   +- aliases=false
     |   |       |   |   |   |   +- useFileMappedBuffer=true
     |   |       |   |   |   |   +- maxCachedFiles=2048
     |   |       |   |   |   +- [/]=>default
     |   |       |   |   |   += jsp@19c47==org.apache.jasper.servlet.JspServlet,0,false - STARTED
     |   |       |   |   |   |   +- logVerbosityLevel=DEBUG
     |   |       |   |   |   |   +- fork=false
     |   |       |   |   |   |   +- scratchdir=/tmp/jetty-0.0.0.0-5809-ROOT-_-any-/jsp
     |   |       |   |   |   |   +- xpoweredBy=false
     |   |       |   |   |   +- [*.jsp, *.jspf, *.jspx, *.xsp, *.JSP, *.JSPF, *.JSPX, *.XSP]=>jsp
     |   |       |   |   |   += mvc-dispatcher@f974527a==org.springframework.web.servlet.DispatcherServlet,1,true - STARTED
     |   |       |   |   |   +- [/]=>mvc-dispatcher
     |   |       |   |   |   +~ org.eclipse.jetty.jmx.MBeanContainer@3a55b9b
     |   |       |   |   +~ org.eclipse.jetty.jmx.MBeanContainer@3a55b9b
     |   |       |   |   +~ HashLoginService[Test Realm] - STARTED
     |   |       |   |   +- org.eclipse.jetty.security.DefaultIdentityService@77df3248
     |   |       |   |   +- org.eclipse.jetty.security.authentication.BasicAuthenticator@652520bb
     |   |       |   |   |
     |   |       |   |   +> HashLoginService[Test Realm] - STARTED
     |   |       |   |   +> org.eclipse.jetty.security.DefaultIdentityService@77df3248
     |   |       |   |   +> org.eclipse.jetty.security.authentication.BasicAuthenticator@652520bb
     |   |       |   |   +> []
     |   |       |   |   +> /={TRACE={RoleInfo,F,C[]}}
     |   |       |   +~ org.eclipse.jetty.jmx.MBeanContainer@3a55b9b
     |   |       += org.eclipse.jetty.servlet.ErrorPageErrorHandler@4ec93402 - STARTED
     |   |       |   +~ org.eclipse.jetty.jmx.MBeanContainer@3a55b9b
     |   |       +~ org.eclipse.jetty.jmx.MBeanContainer@3a55b9b
     |   |       |
     |   |       +> WebAppClassLoader=Spring Web MVC Application@bf6140f
     |   |       |   +- file:/usr/local/osmosix/jetty/webapps/ROOT/WEB-INF/classes/
     |   |       |   +- file:/usr/local/osmosix/jetty/webapps/ROOT/WEB-INF/lib/spring-aop-3.0.5.RELEASE.jar
     |   |       |   +- file:/usr/local/osmosix/jetty/webapps/ROOT/WEB-INF/lib/spring-beans-3.0.5.RELEASE.jar
     |   |       |   +- file:/usr/local/osmosix/jetty/webapps/ROOT/WEB-INF/lib/spring-expression-3.0.5.RELEASE.jar
     |   |       |   +- file:/usr/local/osmosix/jetty/webapps/ROOT/WEB-INF/lib/aopalliance-1.0.jar
     |   |       |   +- file:/usr/local/osmosix/jetty/webapps/ROOT/WEB-INF/lib/spring-context-support-3.0.5.RELEASE.jar
     |   |       |   +- file:/usr/local/osmosix/jetty/webapps/ROOT/WEB-INF/lib/spring-web-3.0.5.RELEASE.jar
     |   |       |   +- file:/usr/local/osmosix/jetty/webapps/ROOT/WEB-INF/lib/spring-core-3.0.5.RELEASE.jar
     |   |       |   +- file:/usr/local/osmosix/jetty/webapps/ROOT/WEB-INF/lib/spring-webmvc-3.0.5.RELEASE.jar
     |   |       |   +- file:/usr/local/osmosix/jetty/webapps/ROOT/WEB-INF/lib/spring-asm-3.0.5.RELEASE.jar
     |   |       |   +- file:/usr/local/osmosix/jetty/webapps/ROOT/WEB-INF/lib/spring-context-3.0.5.RELEASE.jar
     |   |       |   +- file:/usr/local/osmosix/jetty/webapps/ROOT/WEB-INF/lib/commons-logging-1.1.1.jar
     |   |       |   +- startJarLoader@518cb416
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jetty-xml-9.0.0.v20130308.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/servlet-api-3.0.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jetty-http-9.0.0.v20130308.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jetty-continuation-9.0.0.v20130308.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jetty-server-9.0.0.v20130308.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jetty-security-9.0.0.v20130308.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jetty-servlet-9.0.0.v20130308.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jetty-webapp-9.0.0.v20130308.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jetty-deploy-9.0.0.v20130308.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jetty-client-9.0.0.v20130308.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jetty-jmx-9.0.0.v20130308.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jsp/com.sun.el-2.2.0.v201108011116.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jsp/javax.el-2.2.0.v201108011116.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jsp/javax.servlet.jsp.jstl-1.2.0.v201105211821.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jsp/javax.servlet.jsp-2.2.0.v201112011158.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jsp/org.apache.jasper.glassfish-2.2.2.v201112011158.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jsp/org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jsp/org.eclipse.jdt.core-3.7.1.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/resources/
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/websocket/websocket-api-9.0.0.v20130308.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/websocket/websocket-common-9.0.0.v20130308.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/websocket/websocket-server-9.0.0.v20130308.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/websocket/websocket-servlet-9.0.0.v20130308.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jetty-util-9.0.0.v20130308.jar
     |   |       |       +- file:/usr/local/osmosix/jetty/lib/jetty-io-9.0.0.v20130308.jar
     |   |       |       +- sun.misc.Launcher$AppClassLoader@e9576fd
     |   |       |           +- file:/usr/local/osmosix/jetty/start.jar
     |   |       |           +- sun.misc.Launcher$ExtClassLoader@76b6e385
     |   |       +> contextConfigLocation=/WEB-INF/mvc-dispatcher-servlet.xml
     |   |       +> javax.servlet.context.tempdir=/tmp/jetty-0.0.0.0-5809-ROOT-_-any-
     |   |       +> org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern=.*/servlet-api-[^/]*\.jar$
     |   |       +> org.springframework.web.context.support.ServletContextScope=org.springframework.web.context.support.ServletContextScope@392e8f9
     |   |       +> org.springframework.web.context.WebApplicationContext.ROOT=Root WebApplicationContext: startup date [Fri Apr 12 19:08:03 UTC 2013]; root of context hierarchy
     |   |       +> org.springframework.web.servlet.FrameworkServlet.CONTEXT.mvc-dispatcher=WebApplicationContext for namespace 'mvc-dispatcher-servlet': startup date [Fri Apr 12 19:08:04 UTC 2013]; parent: Root WebApplicationContext
     |   += org.eclipse.jetty.server.handler.DefaultHandler@423dc560 - STARTED
     |   |   +~ org.eclipse.jetty.jmx.MBeanContainer@3a55b9b
     |   += org.eclipse.jetty.server.handler.RequestLogHandler@70a6302b - STARTED
     |   |   += org.eclipse.jetty.server.NCSARequestLog@6dbe7935 - STARTED
     |   |   +~ org.eclipse.jetty.jmx.MBeanContainer@3a55b9b
     |   +~ org.eclipse.jetty.jmx.MBeanContainer@3a55b9b
     += HashLoginService[Test Realm] - STARTED
     +- org.eclipse.jetty.jmx.MBeanContainer@3a55b9b
     |   +- org.eclipse.jetty.security.ConstraintSecurityHandler@5daa3e56=org.eclipse.jetty.security:context=ROOT,type=constraintsecurityhandler,id=0
     |   +- org.eclipse.jetty.security.DefaultAuthenticatorFactory@12959ac0=org.eclipse.jetty.security:context=ROOT,type=defaultauthenticatorfactory,id=0
     |   +- qtp578065504{STARTED,10<=10<=200,i=8,q=0}=org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0
     |   +- [*.jsp, *.jspf, *.jspx, *.xsp, *.JSP, *.JSPF, *.JSPX, *.XSP]=>jsp=org.eclipse.jetty.servlet:context=ROOT,type=servletmapping,name=jsp,id=0
     |   +- org.eclipse.jetty.server.Server@6a7ef378=org.eclipse.jetty.server:type=server,id=0
     |   +- org.eclipse.jetty.deploy.providers.WebAppProvider@3e9985a5=org.eclipse.jetty.deploy.providers:type=webappprovider,id=0
     |   +- HttpConnectionFactory@33192410{HTTP/1.1}=org.eclipse.jetty.server:context=HTTP/1.1@3ae0e5b7,type=httpconnectionfactory,id=0
     |   +- default@5c13d641==org.eclipse.jetty.servlet.DefaultServlet,0,false=org.eclipse.jetty.servlet:context=ROOT,type=servletholder,name=default,id=0
     |   +- org.eclipse.jetty.server.handler.DefaultHandler@423dc560=org.eclipse.jetty.server.handler:type=defaulthandler,id=0
     |   +- [/]=>default=org.eclipse.jetty.servlet:context=ROOT,type=servletmapping,name=default,id=0
     |   +- org.eclipse.jetty.server.handler.RequestLogHandler@70a6302b=org.eclipse.jetty.server.handler:type=requestloghandler,id=0
     |   +- org.eclipse.jetty.servlet.ServletHandler@72140bcb=org.eclipse.jetty.servlet:context=ROOT,type=servlethandler,id=0
     |   +- org.eclipse.jetty.server.handler.ContextHandlerCollection@7e999262=org.eclipse.jetty.server.handler:type=contexthandlercollection,id=0
     |   +- org.eclipse.jetty.server.session.HashSessionIdManager@434d3d4f=org.eclipse.jetty.server.session:type=hashsessionidmanager,id=0
     |   +- org.eclipse.jetty.jmx.MBeanContainer@3a55b9b=org.eclipse.jetty.jmx:type=mbeancontainer,id=0
     |   +- HashLoginService[Test Realm]=org.eclipse.jetty.security:type=hashloginservice,id=0
     |   +- jsp@19c47==org.apache.jasper.servlet.JspServlet,0,false=org.eclipse.jetty.servlet:context=ROOT,type=servletholder,name=jsp,id=0
     |   +- o.e.j.w.WebAppContext@2f7e1b09{/,file:/usr/local/osmosix/jetty/webapps/ROOT/,AVAILABLE}{/ROOT}=org.eclipse.jetty.webapp:context=ROOT,type=webappcontext,id=0
     |   +- HttpConfiguration@3636d04a{32768,8192/8192,https://:5809,[]}=org.eclipse.jetty.server:context=HTTP/1.1@3ae0e5b7,type=httpconfiguration,id=0
     |   +- org.eclipse.jetty.security.DefaultIdentityService@77df3248=org.eclipse.jetty.security:context=ROOT,type=defaultidentityservice,id=0
     |   +- org.eclipse.jetty.io.ArrayByteBufferPool@bba4cd7=org.eclipse.jetty.io:context=HTTP/1.1@3ae0e5b7,type=arraybytebufferpool,id=0
     |   +- sun.nio.ch.ServerSocketChannelImpl[/0:0:0:0:0:0:0:0:5809]=sun.nio.ch:context=HTTP/1.1@3ae0e5b7,type=serversocketchannelimpl,id=0
     |   +- org.eclipse.jetty.security.authentication.BasicAuthenticator@652520bb=org.eclipse.jetty.security.authentication:context=ROOT,type=basicauthenticator,id=0
     |   +- mvc-dispatcher@f974527a==org.springframework.web.servlet.DispatcherServlet,1,true=org.eclipse.jetty.servlet:context=ROOT,type=servletholder,name=mvc-dispatcher,id=0
     |   +- org.eclipse.jetty.server.session.SessionHandler@8a6bf88=org.eclipse.jetty.server.session:context=ROOT,type=sessionhandler,id=0
     |   +- [/]=>mvc-dispatcher=org.eclipse.jetty.servlet:context=ROOT,type=servletmapping,name=mvc-dispatcher,id=0
     |   +- org.eclipse.jetty.server.handler.HandlerCollection@582b0e7b=org.eclipse.jetty.server.handler:type=handlercollection,id=0
     |   +- org.eclipse.jetty.deploy.DeploymentManager@76bb5e95=org.eclipse.jetty.deploy:type=deploymentmanager,id=0
     |   +- org.eclipse.jetty.server.session.HashSessionManager@3620f49e=org.eclipse.jetty.server.session:context=ROOT,type=hashsessionmanager,id=0
     |   +- ServerConnector@3ae0e5b7{HTTP/1.1}{0.0.0.0:5809}=org.eclipse.jetty.server:context=HTTP/1.1@3ae0e5b7,type=serverconnector,id=0
     |   +- org.eclipse.jetty.util.log.Log@3daf611c=org.eclipse.jetty.util.log:type=log,id=0
     |   +- org.eclipse.jetty.server.ServerConnector$ServerConnectorManager@3b195903=org.eclipse.jetty.server:context=HTTP/1.1@3ae0e5b7,type=serverconnector$serverconnectormanager,id=0
     |   +- org.eclipse.jetty.servlet.ErrorPageErrorHandler@4ec93402=org.eclipse.jetty.servlet:context=ROOT,type=errorpageerrorhandler,id=0
     |   +- org.eclipse.jetty.server.NCSARequestLog@6dbe7935=org.eclipse.jetty.server:type=ncsarequestlog,id=0
     |   +- org.eclipse.jetty.util.thread.ScheduledExecutorScheduler@7c8b3bd8=org.eclipse.jetty.util.thread:type=scheduledexecutorscheduler,id=0
     +- org.eclipse.jetty.util.log.Log@3daf611c
     += ServerConnector@3ae0e5b7{HTTP/1.1}{0.0.0.0:5809} - STARTED
     |   +~ org.eclipse.jetty.server.Server@6a7ef378 - STARTING
     |   +~ qtp578065504{STARTED,10<=10<=200,i=8,q=0} - STARTED
     |   +~ org.eclipse.jetty.util.thread.ScheduledExecutorScheduler@7c8b3bd8 - STARTED
     |   +- org.eclipse.jetty.io.ArrayByteBufferPool@bba4cd7
     |   += HttpConnectionFactory@33192410{HTTP/1.1} - STARTED
     |   |   +- HttpConfiguration@3636d04a{32768,8192/8192,https://:5809,[]}
     |   |   +~ org.eclipse.jetty.jmx.MBeanContainer@3a55b9b
     |   += org.eclipse.jetty.server.ServerConnector$ServerConnectorManager@3b195903 - STARTED
     |   |   +- org.eclipse.jetty.io.SelectorManager$ManagedSelector@6436babd keys=0 selected=0 id=0
     |   |       +- org.eclipse.jetty.io.SelectorManager$ManagedSelector.select(SelectorManager.java:443)
     |   |       +- sun.nio.ch.EPollSelectorImpl@27f703ba keys=0
     |   +~ org.eclipse.jetty.jmx.MBeanContainer@3a55b9b
     |   +- sun.nio.ch.ServerSocketChannelImpl[/0:0:0:0:0:0:0:0:5809]
     += org.eclipse.jetty.deploy.DeploymentManager@76bb5e95 - STARTED
     |   +~ org.eclipse.jetty.deploy.providers.WebAppProvider@3e9985a5 - STARTED
     |   +~ org.eclipse.jetty.jmx.MBeanContainer@3a55b9b
     += org.eclipse.jetty.server.session.HashSessionIdManager@434d3d4f - STARTED
     |
     +> startJarLoader@518cb416
         +- file:/usr/local/osmosix/jetty/lib/jetty-xml-9.0.0.v20130308.jar
         +- file:/usr/local/osmosix/jetty/lib/servlet-api-3.0.jar
         +- file:/usr/local/osmosix/jetty/lib/jetty-http-9.0.0.v20130308.jar
         +- file:/usr/local/osmosix/jetty/lib/jetty-continuation-9.0.0.v20130308.jar
         +- file:/usr/local/osmosix/jetty/lib/jetty-server-9.0.0.v20130308.jar
         +- file:/usr/local/osmosix/jetty/lib/jetty-security-9.0.0.v20130308.jar
         +- file:/usr/local/osmosix/jetty/lib/jetty-servlet-9.0.0.v20130308.jar
         +- file:/usr/local/osmosix/jetty/lib/jetty-webapp-9.0.0.v20130308.jar
         +- file:/usr/local/osmosix/jetty/lib/jetty-deploy-9.0.0.v20130308.jar
         +- file:/usr/local/osmosix/jetty/lib/jetty-client-9.0.0.v20130308.jar
         +- file:/usr/local/osmosix/jetty/lib/jetty-jmx-9.0.0.v20130308.jar
         +- file:/usr/local/osmosix/jetty/lib/jsp/com.sun.el-2.2.0.v201108011116.jar
         +- file:/usr/local/osmosix/jetty/lib/jsp/javax.el-2.2.0.v201108011116.jar
         +- file:/usr/local/osmosix/jetty/lib/jsp/javax.servlet.jsp.jstl-1.2.0.v201105211821.jar
         +- file:/usr/local/osmosix/jetty/lib/jsp/javax.servlet.jsp-2.2.0.v201112011158.jar
         +- file:/usr/local/osmosix/jetty/lib/jsp/org.apache.jasper.glassfish-2.2.2.v201112011158.jar
         +- file:/usr/local/osmosix/jetty/lib/jsp/org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar
         +- file:/usr/local/osmosix/jetty/lib/jsp/org.eclipse.jdt.core-3.7.1.jar
         +- file:/usr/local/osmosix/jetty/resources/
         +- file:/usr/local/osmosix/jetty/lib/websocket/websocket-api-9.0.0.v20130308.jar
         +- file:/usr/local/osmosix/jetty/lib/websocket/websocket-common-9.0.0.v20130308.jar
         +- file:/usr/local/osmosix/jetty/lib/websocket/websocket-server-9.0.0.v20130308.jar
         +- file:/usr/local/osmosix/jetty/lib/websocket/websocket-servlet-9.0.0.v20130308.jar
         +- file:/usr/local/osmosix/jetty/lib/jetty-util-9.0.0.v20130308.jar
         +- file:/usr/local/osmosix/jetty/lib/jetty-io-9.0.0.v20130308.jar
         +- sun.misc.Launcher$AppClassLoader@e9576fd
             +- file:/usr/local/osmosix/jetty/start.jar
             +- sun.misc.Launcher$ExtClassLoader@76b6e385
Ram
  • 3,034
  • 11
  • 38
  • 46
  • Your application pages probably look something like `http://your.host/appname/something`. Your JS files need to be referenced with "/appname/scripts/scriptname.js". – Pointy Apr 12 '13 at 13:11
  • 1
    @Pointy His application is using `${jetty.home}/webapps/ROOT`, a special directory name, which should deploy as context `http://machine/` (aka root context) – Joakim Erdfelt Apr 12 '13 at 13:13
  • Try GET on `http://ec2-184-73-14-57.compute-1.amazonaws.com:5809/ROOT/scripts/jquery.flot.js` – Joakim Erdfelt Apr 12 '13 at 13:14
  • Also, which version of Jetty? – Joakim Erdfelt Apr 12 '13 at 13:14
  • @JoakimErdfelt ah OK, I didn't notice that. – Pointy Apr 12 '13 at 13:14
  • Shouldn't it be `../scripts/` instead of `../../scripts`? as in relative to the main hello.html page (in WEB-INF dir)? – Elias Van Ootegem Apr 12 '13 at 13:20
  • @JoakimErdfelt I tried with root also .. hitting the same error. I am using jetty-9.0.0.v20130308 (released on 08 March 2013) – Ram Apr 12 '13 at 14:41
  • @EliasVanOotegem I tried that too .. no matter what I have like ../scripts or ../../scripts or /scripts, its always trying to GET http://ec2-184-73-14-57.compute-1.amazonaws.com:5809/scripts/jquery.flot.js – Ram Apr 12 '13 at 14:46
  • @ram which version of jetty? also, are you using the distribution from eclipse, or one from amazon, or one from a linux distribution? – Joakim Erdfelt Apr 12 '13 at 17:09
  • @JoakimErdfelt I am using the one from Eclipse - I downloaded it from http://mirrors.neusoft.edu.cn/eclipse/jetty/stable-9/dist/jetty-distribution-9.0.0.v20130308.tar.gz – Ram Apr 12 '13 at 17:25
  • @ram stop your server, edit `etc/jetty.xml`, set `dumpAfterStart` (found at end of `etc/jetty.xml`) to **true** and start the server. find the dump in your `logs/jetty.log` and paste it into your question above. It should look something like this http://wiki.eclipse.org/Jetty/Howto/Use_the_Dump_Feature#Examining_a_Jetty_Hightide_Dump – Joakim Erdfelt Apr 12 '13 at 18:04
  • @JoakimErdfelt, I have updated the question with the dump. I couldn't get jetty.log, logging the dum. I just copied it from the STDOUT. For now I kept those .js files in a http location and got it working but the dump above is for ../../scripts case – Ram Apr 12 '13 at 19:15

1 Answers1

0

You have a bad servlet-mapping setup.

The servlet named mvc-dispatcher is setup at url-pattern of "/", also known as the servlet spec default servlet path spec. Something that the web container itself provides to allow it to serve static content (like css and javascript files).

With your mvc-dispatcher at "/" that means the Default Servlet itself cannot serve static content.

That also means that org.springframework.web.servlet.DispatcherServlet is now responsible for serving all content from the WebApp. This is an atypical servlet-mapping and I doubt that's the role of the spring DispatcherServlet.

Consider using a suffix based servlet path spec like "*.html" or a prefix based servlet path spec like "/*" (this is outlined in the Section 12 of the Servlet Spec)

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136