views:

247

answers:

1

I am just getting started with Jetty (Jetty 6 w/ Java 6). Using the example files with Jetty 6, I place my xml configuration file. in the same directory as my java file. But when I run the project I get this error.

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

Here is the example code:

`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();

    }
 }

What is the proper way to structure the file system so that my xml file is found?

A: 

After doing some experimentation and heavy soul searching in the API for I changed:

Resource fileserver_xml = Resource.newSystemResource("fileserver.xml");  

To this

Resource fileserver_xml = Resource.newResource("fileserver.xml");  

Then placed the fileserver.xml outside of the "src" directory, which is the project root. Then it worked.

Norm