You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Amin Mohammed-Coleman <am...@gmail.com> on 2009/01/24 16:51:54 UTC

Maven 2.0.9 NullpointerException when running tests

Hi

I have the following pom.xm file:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance 
"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd 
">
	<developers>
		<developer>
			<email>aminmc@gmail.com</email>
			<name>Amin Mohammed-Coleman</name>
			<roles>
				<role>Software Engineer </role>
			</roles>
		</developer>
	</developers>
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.amin</groupId>
	<artifactId>app.lucene</artifactId>
	<packaging>jar</packaging>
	<version>1.0-SNAPSHOT</version>
	<name>app.lucene</name>
	<url>http://maven.apache.org</url>
	<dependencies>

	....
	</dependencies>
	<build>
		<finalName>app.lucene</finalName>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>	
		</plugins>
	</build>
</project>


I have junit 4 tests which all run correctly in eclipse.  However when  
I try to run the tests in maven (mvn test) I get nullpointerexceptions  
(due to classes not being instantiated properly.

Any help would be appreciated.


Cheers
Amin

Re: Maven 2.0.9 NullpointerException when running tests

Posted by aminm <am...@gmail.com>.
Hi

Thanks again for your replies.  It seems as though the text mininng
dependency was the culprit.  I removed the dependency and it started
working.  This is still strange as I explicitly set an exclusion of poi in
text mining.

Anyway it's working correctly so thanks again!


Cheers

Amin

Brett Randall wrote:
> 
> I Googled that stack trace for you and it pointed me straight to the POI
> FAQ
> here: http://poi.apache.org/faq.html#faq-N10006 .  Classpath debugging
> advice there - you might need to check if you have an overlapping
> dependency, so dependency:analyze and dependency:tree are probably good
> starts.
> 
> Best
> Brett
> 
> On Tue, Jan 27, 2009 at 6:24 AM, aminm <am...@gmail.com> wrote:
> 
>>
>>
>>
>> Dave Newton wrote:
>> >
>> > Geoffrey Wiseman wrote:
>> >> On Sun, Jan 25, 2009 at 7:21 PM, Dave Newton <ne...@yahoo.com>
>> >> wrote:
>> >>> Does 4.5 not work?
>> >> I was just responding to Amin's comment about JUnit 4.4 [...]
>> >
>> > Ah, missed that--never mind :)
>> >
>> > Dave
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> > For additional commands, e-mail: users-help@maven.apache.org
>> >
>> >
>> >
>>
>> Hi
>>
>> Thanks for the replies!  I managed to get the surefire plugin to use
>> junit
>> 4.  However I am getting some strange behaviour, in that some of my tests
>> fail, while they all run fine in eclipse.  I am using text mining as a
>> dependency and exclude the version of poi that comes with it.   The
>> exception that I get is
>>
>>
>> testCanCreateLuceneDocumentForMSWordDocument(com.amin.app.lucene.index.handler.ms.MSWordHandlerTest)
>> Time elapsed: 0.038 sec  <<< ERROR!
>> java.lang.NoSuchMethodError:
>>
>> org.apache.poi.poifs.filesystem.POIFSFileSystem.getRoot()Lorg/apache/poi/poifs/filesystem/DirectoryNode;
>>        at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:158)
>>        at
>> org.apache.poi.hwpf.extractor.WordExtractor.<init>(WordExtractor.java:59)
>>        at
>>
>> com.amin.app.lucene.index.handler.ms.MSWordHandler.extractText(MSWordHandler.java:16)
>>
>>
>> I know that this exception occurs if I am using an old version of poi
>> (2.5),
>> even though I have excluded the version that comes with text mining.  I
>> have
>> added
>>
>>        <dependency>
>>                        <groupId>org.apache.poi</groupId>
>>                        <artifactId>poi</artifactId>
>>                        <version>3.5-beta4</version>
>>                        <scope>compile</scope>
>>                </dependency>
>>
>> This is very strange and I can't understand why the tests won't run.
>>
>> Any help again would be appreciated.
>>
>>
>>
>> --
>> View this message in context:
>> http://n2.nabble.com/Maven-2.0.9-NullpointerException-when-running-tests-tp2209372p2220012.html
>> Sent from the maven users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://n2.nabble.com/Maven-2.0.9-NullpointerException-when-running-tests-tp2209372p2222945.html
Sent from the maven users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven 2.0.9 NullpointerException when running tests

Posted by Brett Randall <ja...@gmail.com>.
I Googled that stack trace for you and it pointed me straight to the POI FAQ
here: http://poi.apache.org/faq.html#faq-N10006 .  Classpath debugging
advice there - you might need to check if you have an overlapping
dependency, so dependency:analyze and dependency:tree are probably good
starts.

Best
Brett

On Tue, Jan 27, 2009 at 6:24 AM, aminm <am...@gmail.com> wrote:

>
>
>
> Dave Newton wrote:
> >
> > Geoffrey Wiseman wrote:
> >> On Sun, Jan 25, 2009 at 7:21 PM, Dave Newton <ne...@yahoo.com>
> >> wrote:
> >>> Does 4.5 not work?
> >> I was just responding to Amin's comment about JUnit 4.4 [...]
> >
> > Ah, missed that--never mind :)
> >
> > Dave
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
> >
>
> Hi
>
> Thanks for the replies!  I managed to get the surefire plugin to use junit
> 4.  However I am getting some strange behaviour, in that some of my tests
> fail, while they all run fine in eclipse.  I am using text mining as a
> dependency and exclude the version of poi that comes with it.   The
> exception that I get is
>
>
> testCanCreateLuceneDocumentForMSWordDocument(com.amin.app.lucene.index.handler.ms.MSWordHandlerTest)
> Time elapsed: 0.038 sec  <<< ERROR!
> java.lang.NoSuchMethodError:
>
> org.apache.poi.poifs.filesystem.POIFSFileSystem.getRoot()Lorg/apache/poi/poifs/filesystem/DirectoryNode;
>        at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:158)
>        at
> org.apache.poi.hwpf.extractor.WordExtractor.<init>(WordExtractor.java:59)
>        at
>
> com.amin.app.lucene.index.handler.ms.MSWordHandler.extractText(MSWordHandler.java:16)
>
>
> I know that this exception occurs if I am using an old version of poi
> (2.5),
> even though I have excluded the version that comes with text mining.  I
> have
> added
>
>        <dependency>
>                        <groupId>org.apache.poi</groupId>
>                        <artifactId>poi</artifactId>
>                        <version>3.5-beta4</version>
>                        <scope>compile</scope>
>                </dependency>
>
> This is very strange and I can't understand why the tests won't run.
>
> Any help again would be appreciated.
>
>
>
> --
> View this message in context:
> http://n2.nabble.com/Maven-2.0.9-NullpointerException-when-running-tests-tp2209372p2220012.html
> Sent from the maven users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Maven 2.0.9 NullpointerException when running tests

Posted by Geoffrey Wiseman <ge...@gmail.com>.
On Mon, Jan 26, 2009 at 2:24 PM, aminm <am...@gmail.com> wrote:

> I know that this exception occurs if I am using an old version of poi
> (2.5),
> even though I have excluded the version that comes with text mining.  I
> have
> added
>
>        <dependency>
>                        <groupId>org.apache.poi</groupId>
>                        <artifactId>poi</artifactId>
>                        <version>3.5-beta4</version>
>                        <scope>compile</scope>
>                </dependency>
>
> This is very strange and I can't understand why the tests won't run.
>
> Any help again would be appreciated.
>

Nothing leaps to mind right away -- try "mvn dependency:tree" and "mvn
help:effective-pom" to see if you're getting the dependencies that you
expect to get, and no additional dependencies?

  - Geoffrey
-- 
Geoffrey Wiseman
http://www.geoffreywiseman.ca/

Re: Maven 2.0.9 NullpointerException when running tests

Posted by aminm <am...@gmail.com>.


Dave Newton wrote:
> 
> Geoffrey Wiseman wrote:
>> On Sun, Jan 25, 2009 at 7:21 PM, Dave Newton <ne...@yahoo.com>
>> wrote:
>>> Does 4.5 not work?
>> I was just responding to Amin's comment about JUnit 4.4 [...]
> 
> Ah, missed that--never mind :)
> 
> Dave
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

Hi

Thanks for the replies!  I managed to get the surefire plugin to use junit
4.  However I am getting some strange behaviour, in that some of my tests
fail, while they all run fine in eclipse.  I am using text mining as a
dependency and exclude the version of poi that comes with it.   The
exception that I get is

testCanCreateLuceneDocumentForMSWordDocument(com.amin.app.lucene.index.handler.ms.MSWordHandlerTest) 
Time elapsed: 0.038 sec  <<< ERROR!
java.lang.NoSuchMethodError:
org.apache.poi.poifs.filesystem.POIFSFileSystem.getRoot()Lorg/apache/poi/poifs/filesystem/DirectoryNode;
	at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:158)
	at
org.apache.poi.hwpf.extractor.WordExtractor.<init>(WordExtractor.java:59)
	at
com.amin.app.lucene.index.handler.ms.MSWordHandler.extractText(MSWordHandler.java:16)


I know that this exception occurs if I am using an old version of poi (2.5),
even though I have excluded the version that comes with text mining.  I have
added 

	<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi</artifactId>
			<version>3.5-beta4</version>
			<scope>compile</scope>
		</dependency>

This is very strange and I can't understand why the tests won't run.

Any help again would be appreciated. 



-- 
View this message in context: http://n2.nabble.com/Maven-2.0.9-NullpointerException-when-running-tests-tp2209372p2220012.html
Sent from the maven users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven 2.0.9 NullpointerException when running tests

Posted by Dave Newton <ne...@yahoo.com>.
Geoffrey Wiseman wrote:
> On Sun, Jan 25, 2009 at 7:21 PM, Dave Newton <ne...@yahoo.com> wrote:
>> Does 4.5 not work?
> I was just responding to Amin's comment about JUnit 4.4 [...]

Ah, missed that--never mind :)

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven 2.0.9 NullpointerException when running tests

Posted by Geoffrey Wiseman <ge...@gmail.com>.
On Sun, Jan 25, 2009 at 7:21 PM, Dave Newton <ne...@yahoo.com> wrote:

> Geoffrey Wiseman wrote:
>
>> Or <version>4.4</version>.
>>
>
> Does 4.5 not work?


I was just responding to Amin's comment about JUnit 4.4, more than anything
else.

  - Geoffrey
-- 
Geoffrey Wiseman
http://www.geoffreywiseman.ca/

Re: Maven 2.0.9 NullpointerException when running tests

Posted by Wayne Fay <wa...@gmail.com>.
> Does 4.5 not work?

It looks like JUnit 4.5 *is* deployed to Central, so it *should* work:
http://www.mvnrepository.com/artifact/junit/junit

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven 2.0.9 NullpointerException when running tests

Posted by Dave Newton <ne...@yahoo.com>.
Geoffrey Wiseman wrote:
> Or <version>4.4</version>.

Does 4.5 not work?

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven 2.0.9 NullpointerException when running tests

Posted by Geoffrey Wiseman <ge...@gmail.com>.
On Sun, Jan 25, 2009 at 8:13 AM, Hubert Iwaniuk <ne...@kungfoo.pl> wrote:

> Try:
> <dependency>
>  <groupId>junit</groupId>
>  <artifactId>junit</artifactId>
>  <version>4.1</version>
>  <scope>test</scope>
> </dependency>
>

Or <version>4.4</version>.

  - Geoffrey

-- 
Geoffrey Wiseman
http://www.geoffreywiseman.ca/

Re: Maven 2.0.9 NullpointerException when running tests

Posted by Hubert Iwaniuk <ne...@kungfoo.pl>.
Try:
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.1</version>
  <scope>test</scope>
</dependency>

HTH.

On Sat, Jan 24, 2009 at 8:54 PM, Amin Mohammed-Coleman <am...@gmail.com>wrote:

> Hi (To Geoffrey Wiseman)
>
> You are correct it is using junit 3.8.1 jar, I'm not sure how to change
> this to 4.4. Would it be possible to get some advice on how to do this?
>
>
> Cheers
> Amin
>
>
>
> On 24 Jan 2009, at 15:51, Amin Mohammed-Coleman wrote:
>
>  Hi
>>
>> I have the following pom.xm file:
>>
>> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
>> http://www.w3.org/2001/XMLSchema-instance"
>>        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>> http://maven.apache.org/maven-v4_0_0.xsd">
>>        <developers>
>>                <developer>
>>                        <email>aminmc@gmail.com</email>
>>                        <name>Amin Mohammed-Coleman</name>
>>                        <roles>
>>                                <role>Software Engineer </role>
>>                        </roles>
>>                </developer>
>>        </developers>
>>        <modelVersion>4.0.0</modelVersion>
>>        <groupId>com.amin</groupId>
>>        <artifactId>app.lucene</artifactId>
>>        <packaging>jar</packaging>
>>        <version>1.0-SNAPSHOT</version>
>>        <name>app.lucene</name>
>>        <url>http://maven.apache.org</url>
>>        <dependencies>
>>
>>        ....
>>        </dependencies>
>>        <build>
>>                <finalName>app.lucene</finalName>
>>                <plugins>
>>                        <plugin>
>>                                <groupId>org.apache.maven.plugins</groupId>
>>
>>  <artifactId>maven-compiler-plugin</artifactId>
>>                                <configuration>
>>                                        <source>1.6</source>
>>                                        <target>1.6</target>
>>                                </configuration>
>>                        </plugin>
>>                </plugins>
>>        </build>
>> </project>
>>
>>
>> I have junit 4 tests which all run correctly in eclipse.  However when I
>> try to run the tests in maven (mvn test) I get nullpointerexceptions (due to
>> classes not being instantiated properly.
>>
>> Any help would be appreciated.
>>
>>
>> Cheers
>> Amin
>>
>
>


-- 
Hubert Iwaniuk

Re: Maven 2.0.9 NullpointerException when running tests

Posted by Amin Mohammed-Coleman <am...@gmail.com>.
Hi (To Geoffrey Wiseman)

You are correct it is using junit 3.8.1 jar, I'm not sure how to  
change this to 4.4. Would it be possible to get some advice on how to  
do this?


Cheers
Amin


On 24 Jan 2009, at 15:51, Amin Mohammed-Coleman wrote:

> Hi
>
> I have the following pom.xm file:
>
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance 
> "
> 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd 
> ">
> 	<developers>
> 		<developer>
> 			<email>aminmc@gmail.com</email>
> 			<name>Amin Mohammed-Coleman</name>
> 			<roles>
> 				<role>Software Engineer </role>
> 			</roles>
> 		</developer>
> 	</developers>
> 	<modelVersion>4.0.0</modelVersion>
> 	<groupId>com.amin</groupId>
> 	<artifactId>app.lucene</artifactId>
> 	<packaging>jar</packaging>
> 	<version>1.0-SNAPSHOT</version>
> 	<name>app.lucene</name>
> 	<url>http://maven.apache.org</url>
> 	<dependencies>
>
> 	....
> 	</dependencies>
> 	<build>
> 		<finalName>app.lucene</finalName>
> 		<plugins>
> 			<plugin>
> 				<groupId>org.apache.maven.plugins</groupId>
> 				<artifactId>maven-compiler-plugin</artifactId>
> 				<configuration>
> 					<source>1.6</source>
> 					<target>1.6</target>
> 				</configuration>
> 			</plugin>	
> 		</plugins>
> 	</build>
> </project>
>
>
> I have junit 4 tests which all run correctly in eclipse.  However  
> when I try to run the tests in maven (mvn test) I get  
> nullpointerexceptions (due to classes not being instantiated properly.
>
> Any help would be appreciated.
>
>
> Cheers
> Amin


Re: Maven 2.0.9 NullpointerException when running tests

Posted by Geoffrey Wiseman <ge...@gmail.com>.
On Sat, Jan 24, 2009 at 10:51 AM, Amin Mohammed-Coleman <am...@gmail.com>wrote:

> I have junit 4 tests which all run correctly in eclipse.  However when I
> try to run the tests in maven (mvn test) I get nullpointerexceptions (due to
> classes not being instantiated properly.
>
> Any help would be appreciated.


Probably means Maven is running them as JUnit 3.X and ignoring the @Before
annotations.  mvn -X test, pipe the output, and check which version of
Junit.jar is being used.

  - Geoffrey
-- 
Geoffrey Wiseman
http://www.geoffreywiseman.ca/