1
votes

We have an maven+springMVC application that uses maven jetty plugin to start the app up when we do development. We use a jetty-env.xml file to set a context and JNDI config. The application will be part of a bigger portal.

We are using maven jetty plugin

<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.2.0.v20101020</version>

with config

<webAppConfig>
  <contextPath>/ASX/mainApp</contextPath>
  <jettyEnvXml>src/main/resources/jetty-env.xml</jettyEnvXml>
</webAppConfig>

and use jetty-env.xml

<Configure id='jms-webapp-wac' class="org.eclipse.jetty.webapp.WebAppContext">
    <Set name="contextPath">/ASX/mainApp</Set>
    ...
    ...
</Configure>

Our dir structure is:

MainApp
  /forms
    page1.html
    page2.html
    etc...
  /WEB-INF
    web.xml

PortalApp
  /BAL_S
    /css
    /images
    /js
    etc...

Now the PortalApp only has static files and is not really a web application i.e. it doesn't have web.xml

The application is dependent on javaScripts from the portal. The location of some of the javaScript are like:

<script src="/BAL_S/js/portal-jquery-lib.js"></script>
<script src="/BAL_S/js/libs/foundation.js"></script>
etc...

As you can see that the location starts with /BAL_S which we are finding tricky to get working as it's like referring to another webapp context. When we start the application with jetty we get javaScript errors because it cannot find /BAL_S

If we deploy our app in tomcat and configure it, as below, the application works fine without any javaScript errors.

<Context path="/" docBase="PortalApp"/>
  1. So the question is how can I do the similar configuration in Jetty so when the application starts up it detects /BAL_S context?

  2. I guess we need to have two contexts in Jetty. How do I configure that?

  3. What is the webConfig for maven jetty plugin to refer to this config?

Hope someone can help. Example would be useful.

Thanks in advance. GM

1

1 Answers

1
votes

OK All I had to do was add to maven jetty plugin configuration, the following:

            <contextHandlers>
                <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
                    <contextPath>/</contextPath>
                    <resourceBase>src/main/PortalApp/</resourceBase>
                </contextHandler>
            </contextHandlers>

So this configures context path '/' to 'src/main/PortalApp/' and now we are able to get to /BAL_S in the tag.