Tuesday, January 26, 2010

How to deal with exceptions of org.hibernate.cfg.Configuration.xmlHelper...?

The exact exception I came across -

Exception in thread “main” java.lang.IllegalAccessError: tried to access field org.hibernate.cfg.Configuration.xmlHelper from class org.hibernate.cfg.AnnotationConfiguration
at org.hibernate.cfg.AnnotationConfiguration.addInputStream(AnnotationConfiguration.java:712)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:481)
at.......

It simply means you got to check the compatibility of the hibernate jar files present in your lib folder for the project at hand.

http://www.hibernate.org/30.html

If there are incompatibilities, this error gets thrown...

r-she-yeah

Tuesday, January 19, 2010

com.mysql.jdbc.PacketTooBigException

Packet too Big Exception originates from MySQL when the packet of data is too big for MYSQL to handle.
com.mysql.jdbc.PacketTooBigException: Packet for query is too large (4739923 > 1048576).
After a whole day of nerves wrecked for this, I figured out that i need to increase the size of "max_allowed_packet variable" in two places at the client's and server's end - as stated by MYSQL (http://dev.mysql.com/doc/refman/5.1/en/packet-too-large.html)

mysql> show variables like '%max_allowed_packet';

mysql> set global max_allowed_packet=52428800;

File: /etc/my.cnf
max_allowed_packet=50M

The maximum allowed packet size is 1GB ie 100MB.
Oh btw, 1 MB = 1048576 bytes.

And viola, then restart the server.

/etc/init.d/mysqld restart && tail -f /var/log/mysqld.log

Yeah ! problem solved...