takimafr / spring-dbunit

DBUnit support for Spring
Apache License 2.0
40 stars 19 forks source link

DataSetFormatOptions is null by default in servlet module causing NPE #13

Closed sylvainleduby closed 12 years ago

sylvainleduby commented 12 years ago

When loading DBUnit DataSets on web application startup, default DataSetFormatOptions is null and causes a NPE in DataSetFormat.java at line 77: builder.setColumnSensing(options.isColumnSensing());

Here is the stacktrace: java.lang.ExceptionInInitializerError at com.excilys.ebi.spring.dbunit.servlet.DataLoaderListener.contextInitialized(DataLoaderListener.java:56) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: java.lang.NullPointerException at com.excilys.ebi.spring.dbunit.config.DataSetFormat$2.fromResource(DataSetFormat.java:77) at com.excilys.ebi.spring.dbunit.config.DataSetFormat.loadMultiple(DataSetFormat.java:159) at com.excilys.ebi.spring.dbunit.config.DataSetConfiguration.getDataSet(DataSetConfiguration.java:54) at com.excilys.ebi.spring.dbunit.DbUnitDatabasePopulator.populate(DbUnitDatabasePopulator.java:54) at com.excilys.ebi.spring.dbunit.DefaultDataLoader.executeOperation(DefaultDataLoader.java:66) at com.excilys.ebi.spring.dbunit.DefaultDataLoader.execute(DefaultDataLoader.java:41) at com.excilys.ebi.spring.dbunit.servlet.DataLoaderListener.contextInitialized(DataLoaderListener.java:52) ... 15 more

I have just added the listener in web.xml. I don't see any configuration customization for the DataSetFormatOptions.

The test module works just fine.

slandelle commented 12 years ago

Hi,

Thanks for reporting. Until I fix this, you can declare an instance of DataSetConfiguration in your Spring ApplicationContext and it will be picked up by the Listener.

Cheers,

Stephane

slandelle commented 12 years ago

Documentation updated : https://github.com/excilys/spring-dbunit/wiki/spring-dbunit-servlet-module