How do I get the Jetty 6 FileServerXml example to work?

Posted by Norm on Stack Overflow See other posts from Stack Overflow or by Norm
Published on 2010-05-20T18:57:26Z Indexed on 2010/05/20 19:00 UTC
Read the original article Hit count: 277

Filed under:
|

I have followed along with the Tutorial and the examples. Yet I always get this error when I copy and paste the code:

Exception in thread "main" java.lang.NullPointerException
at net.test.FileServerXml.main(FileServerXml.java:13) 

In Eclipse I have the directory structured as such:

package net.test
-FileServerXml.java
-fileserver.xml
-index.html

FileServerXml.java

package net.test;


import org.mortbay.jetty.Server;
import org.mortbay.resource.Resource;
import org.mortbay.xml.XmlConfiguration;

public class FileServerXml
{
    public static void main(String[] args) throws Exception
    {
        Resource fileserver_xml = Resource.newSystemResource("fileserver.xml");
        XmlConfiguration configuration = new XmlConfiguration(fileserver_xml.getInputStream());
        Server server = (Server)configuration.configure();
        server.start();
        server.join();

    }
}
`

fileserver.xml

`<?xml version="1.0"?>

<Call name="addConnector">
  <Arg>
      <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
        <Set name="port">8080</Set>
      </New>
  </Arg>
</Call>

<Set name="handler">
  <New class="org.eclipse.jetty.server.handler.HandlerList">
    <Set name="handlers">
  <Array type="org.eclipse.jetty.server.Handler">
    <Item>
      <New class="org.eclipse.jetty.server.handler.ResourceHandler">
        <Set name="directoriesListed">true</Set>
    <Set name="welcomeFiles">
      <Array type="String"><Item>index.html</Item></Array>
    </Set>
        <Set name="resourceBase">.</Set>
      </New>
    </Item>
    <Item>
      <New class="org.eclipse.jetty.server.handler.DefaultHandler">
      </New>
    </Item>
  </Array>
    </Set>
  </New>
</Set>

`

Thanks for your input. Norm

© Stack Overflow or respective owner

Related posts about embedded-jetty

Related posts about eclipse