Monday, May 13, 2013

Removing a file/directory that starts with a "-" in Linux/Unix

Removing a file/directory that starts with the character "-" can be tricky in Linux/Unix. On Linux/Unix you may get this error when attempting to remove a file/directory:
rm: invalid option -- '1'

Some commands may give you a hint e.g.
Try `rm ./-1' to remove the file `-1'.

This is exactly what is required i.e just append the "./" to the file/folder to resolve your problem.

Friday, May 10, 2013

Slow startup of Weblogic server on Linux

Had a strange problem on our Linux server recently after installing Weblogic 10. The server was very slow to startup. Seems the problem is this bug in Java 5: Bug 6202721

The fix is to edit the java.security file in the jre/lib/security folder of your java installation on the server. Alter the securerandom.source field to be file:/dev/./urandom as suggested in this article: How to improve Weblogic Servers Startup Time

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>