tigeronk2
tigeronk2

Reputation: 2650

Jetty error - java.lang.IllegalStateException: No object for id=Contexts

I want to run two webapps(different ports) on two parallel jetty instances. I'm using jetty7.1.6 and following the instructions here. My jetty-cp.xml(customized jetty.xml) contains this section:

<Set name="handler">
  <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
    <Set name="handlers">
     <Array type="org.eclipse.jetty.server.Handler">
       <Item>
         <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
       </Item>
       <Item>
         <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
       </Item>
     </Array>
    </Set>
  </New>
</Set>

Now when I run one jetty instance from command line(java -Djetty.home=/opt/jetty -jar /opt/jetty/start.jar etc/jetty-cp.xml), I get the following error :

2014-01-02 18:03:47.649:WARN::Config error at <Call name="addBean"><Arg>|        <New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager"><Set name="contexts">|            <Ref id="Contexts"/>|          </Set><Call name="setContextAttribute"><Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg><Arg>.*/jsp-api-[^/]*\.jar$|.*/jsp-[^/]*\.jar$</Arg></Call><Call name="addAppProvider"><Arg>|              <New class="org.eclipse.jetty.deploy.providers.ContextProvider"><Set name="monitoredDir"><Property name="jetty.home" default="."/>/contexts</Set><Set name="scanInterval">5</Set></New>|            </Arg></Call><Call name="addAppProvider"><Arg>|              <New class="org.eclipse.jetty.deploy.providers.WebAppProvider"><Set name="monitoredDir"><Property name="jetty.home" default="."/>/webapps</Set><Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set><Set name="scanInterval">5</Set><Set name="contextXmlDir"><Property name="jetty.home" default="."/>/contexts</Set></New>|            </Arg></Call></New>|      </Arg></Call> java.lang.IllegalStateException: No object for id=Contexts
2014-01-02 18:03:47.650:WARN::EXCEPTION 
java.lang.IllegalStateException: No object for id=Contexts
at org.eclipse.jetty.xml.XmlConfiguration.refObj(XmlConfiguration.java:676)
at org.eclipse.jetty.xml.XmlConfiguration.itemValue(XmlConfiguration.java:941)

This section of config is present in /opt/jetty/etc/jetty-deploy.xml file.

What am I doing wrong? I already specified the object with id=Context in jetty-cp.xml file which I specified in command line. Why is the section in jetty-deploy.xml unable to find it?

Upvotes: 0

Views: 3490

Answers (1)

tigeronk2
tigeronk2

Reputation: 2650

start.ini had jetty-deploy.xml uncommented which caused *<Ref id="Contexts"/>* to be parsed before its definition in jetty-cp.xml.

Basically, files mentioned in start.ini get loaded even before the jetty-cp.xml I mentioned on command line. This needs to be kept in mind.

Upvotes: 1

Related Questions