Wednesday, January 8, 2014

Viewing the maximum number of open files allowed

To check the maximum number of files allowed for a user on Linux run the following command:
$ ulimit -n

To view the maximum number of files allowed on the system as a whole:
$ cat /proc/sys/fs/file-max

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>

Tuesday, October 9, 2012

ClassNotFoundException: org.hibernate.hql.ast.HqlToken

When using Hibernate to read from a Database using Weblogic 10 and Springframework 2.5.6, I encountered the following error:

ClassNotFoundException: org.hibernate.hql.ast.HqlToken

The reason for this is that it by default will use Weblogic's default classloader to load the antlr jar file and doesn't use the version included within your .war file.

To solve this you need to wrap your .war in an ear file and within the META-INF/weblogic-application.xml file within you .ear file include the following:
 <prefer-application-packages>
    <package-name>antlr.*</package>
 </prefer-application-packages>
 

This should resolve this issue.


Sunday, August 26, 2012

SQL String functions

Some STRING functions in SQL:

select RIGHT(column, chars) from table;
select SUBSTRING_INDEX(column, char, which char (i.e, 1,2...)) from table;
select REVERSE(string);
select LTRIM(string);
select RTRIM(string);
select LENGTH(string);