Hi,

I have not tried additional classpath feature in maven2. I am not sure
whether you load your xml file as following?

InputStream inputStream = YourClass.class. getResourceAsStream("The relative
PATH of your XML file");

Thanks.

Linghua

2008/12/28 Neo Anderson <[email protected]>

> I am build a project and that looks ok at the moment. However I encounter a
> problem when running test.
>
> My problem is that I have a customized xml. So I build a test located in
> the test/project/name/to/xmlTest.java, in which it will load an xml file to
> have  a small test. The xml file is located at
> reousrces/project/name/to/file.xml. Unfortunately, when executing the test
> (via mvn package), it seems the default classpath would be the place where
> pom.xml exists. Therefore, if in the xmlTest.java I specify xml path like
>
> parser.parse("project/name/to/file.xml");
>
> The maven throws "Running project.name.xmlTest
> java.io.FileNotFoundException:
> $HOME/path/to/pom.xml/project/name/to/file.xml (No such file or directory)"
>
> I read the doc -
> http://maven.apache.org/plugins/maven-surefire-plugin/examples/additional-classpath.html;
> seemingly I can add additional classpath whilst running test. But no luck,
> it still looks up the default one.
>
> I am able to specify the exactly path to solve the problem.
> For instance,
>
> parser.parse("src/parent_name/project/name/to/file.xml");
>
> where src/parent_name is the structure folder that will only be used when
> writing programme. But this is not what I want because I think that
> classpath should be configurable.
>
> Is any way I can configure to specify the classpath in pom.xml?
>
> Thanks in advice,
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to