Friday, January 11, 2013

NullPointerException with Hibernate 4

java.lang.NullPointerException at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:207) at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)

The exception above can be resolved by adding this Hibernate property:
<property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>

Thursday, January 10, 2013

"No runnable methods" when using Maven for a class that shouldn't be Tested

I recently ran into a problem doing a Maven build where I had a utility class to be used for my Test cases. Adding the @Ignore tag didn't seem to help. It turns out the solution was simply to add this plugin entry to my pom.xml file as my file had the suffix Util.java:

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-surefire-plugin</artifactId>
   <configuration>
      <excludes>
         <exclude>**/*Util.java</exclude>
      </excludes>
   </configuration>
</plugin>