开发者

Where do I put my jetty.xml file with Jetty embedded?

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜