not like condition in hibernate criteria query

I have a list of tickets. I want all tickets whose status are not like %CLOSED%. Here is an example using Criteria.


Criteria c = super.getSession().createCriteria(Ticket.class);

c.add(Restrictions.not(Restrictions.like("status", "%CLOSED%")));

Advertisements

javax.validation.ValidationException: HV000183: Unable to load ‘javax.el.ExpressionFactory’. Check that you have the EL dependencies on the classpath, or use ParameterMessageInterpolator instead

I got this exception when I executed my newly written junit test for a Spring DAO with Hibernate Validations.

After adding javax.el to pom, this is resolved.


<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId>
<version>2.2.4</version>
</dependency>

 

Live internet radio stream extractor

radio.jpg

Friends,

This is to give you a code pack I wrote today. I was listening to one of the internet radios in Tamil. I want to store it on my hdd, the tools I searched dint helped me much. I want a simple tool, that saves my time. And It should be able to work in my absence. I wrote couple of classes, which I am going to test it now.

Why dont you test it youself 🙂
It doesnt require any installation. you need only three files.

mp3_stream_extractor.jar, The execution binary,
RUN.CMD, the invoking script
radio.properties, where you configure the radios

run the run.cmd, The audio is extracted to your home folder automatically.

Enjoy.

Download MP3 stream extractor

radio properties

java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence

Hi,

I have taken a short break! There are many more error messages, which are keep on accumulating behind the screens. But I am so lazy to put them in grassfield.

Anyway, today I got interrupted with an interesting exception

java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence

The scenario was, I am trying to parse an xml string. I am taking the byte array from the xml string, and give that array as input to xml reader stream. I have used java.lang.String.getBytes() for this.

Unfortunately, I got a chinese (or any other funny) characters as a value of one node in the xml. Ooof. I got up with the above error. Later, I found that getBytes() method supports only the western encoding, not UTF-8. So by using java.lang.String.getBytes("UTF-8") method, we solved the issue! nice na!

Java Runtime exec can hang

Today I was trying to extract the windows eventlog entries in my win-xp box. I have used Eldump to do this. please see my earlier post about this tool http://blog.grassfield.org/2007/06/24/fetch-your-eventlog-entries-with-eldump/ . I have used runtime.exec() to execute this command and extracted the information from the process streams.

The program was extracting the log entries, but hang in between, and went for endless sleep; i.e, the process never ended. Later with some googling, I was adviced to read error stream first, and then process output stream. Also both the streams need to be read concurrently with two threads. This could solve my issue. Try then!

java.util.zip.ZipException: invalid CEN header (encrypted entry)

friends,This week started with some more problems :). Nothing to worry, problems only feed us! Otherwise, who will give us job!!! Today I was trying to unzip a zip file and read the contents inside the file, using java.util.zip.ZipFile. It was working fine till I increased the file size. The zip file is around 160MB, and the single file inside that zip file is 4.5GB contains raw text. I hit with the exception

java.util.zip.ZipException: invalid CEN header (encrypted entry)

Pathetic, I was totally helpless! Later I came to know that It is a open bug in java, which will not support above 3.2G!  I am in darkness. Latermy lead had pointed out that is due to java’s non-compliance to zip64, which is fixed in jdk1.6, 24th build. I need to get it installed and get rid of this issue!

Make fun with Text : java.util.Scanner


One of my friend came with the sun’s newsletter today morning. I was wondering about their demo on a new class, java.util.Scanner
See, parsing the string becomes very simple, like iterating a list.

Scanner accepts streams, file and other string input mechanisms and parses the string and give is the tokens. (It also allows the user to specify using which encoding the text has been built. goo news for localisation guyz like me). By default, whatever you have given, it is tokenized by having the default delimiter, space, See the following example,

import java.util.*;
import java.io.*;
public class test
{
public static void main(String [] args) throws FileNotFoundException
{
File f = new File(“test.java”);
Scanner scanner = new Scanner(f);
while (scanner.hasNext())
{
System.out.println(scanner.next());
}
scanner.close();
}
}

The output is

C:>java test
import
java.util.*;
import
java.io.*;
public
class
test
{
public
static
void
main(String
[]
args)
throws
FileNotFoundException
{
File
f
=
new
File(“test.java”);
Scanner
scanner
=
new
Scanner(f);
while
(scanner.hasNext())
{
System.out.println(scanner.next());
}
scanner.close();
}
}

funny, isnt it!!!

We can also change the delimiter, see the following example

import java.util.*;
import java.io.*;
public class test
{
public static void main(String [] args) throws FileNotFoundException
{
File f = new File(“test.java”);
Scanner scanner = new Scanner(f);
scanner.useDelimiter(“n”);
while (scanner.hasNext())
{
System.out.println(scanner.next());
}
scanner.close();
}
}

The output is same as that of above code, want to see that one also?

C:>java test
import java.util.*;
import java.io.*;
public class test
{
public static void main(String [] args) throws FileNotFoundException
{
File f = new File(“test.java”);
Scanner scanner = new Scanner(f);
scanner.useDelimiter(“n”);
while (scanner.hasNext())
{
System.out.println(scanner.next());
}
scanner.close();
}
}

Really good one! But I really miss the fun of using the streams 😦