Hibernate Proxy InstantiationException

Changing entities to be lazy loaded led me to the following problem:

@OneToMany(fetch = FetchType.LAZY)
Caused by: org.hibernate.HibernateException: Javassist Enhancement failed: Thing
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:142)
	at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:72)
	at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:402)
	at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3483)
….
Caused by: java.lang.InstantiationException: Thing_$$_javassist_38
	at java.lang.Class.newInstance0(Class.java:340)
	at java.lang.Class.newInstance(Class.java:308)
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:139)

Thanks to Kristian I jumped straight to the problem. From the Hibernate docs:

Cat has a no-argument constructor. All persistent classes must have a default constructor (which can be non-public) so that Hibernate can instantiate them using Constructor.newInstance(). It is recommended that you have a default constructor with at least package visibility for runtime proxy generation in Hibernate.

This should probably read “It is essential….”

Anyway now everything is real lazy so happy days.

  • Share/Bookmark

@ 13:07

hibernate

Permalink

Add a proxy to subversion configuration

If you need to access subversion from outside a proxy, you need to edit ~/.subversion/servers and add this:

[groups]
mySubversionGroup = *.some.domain
[mySubversionGroup]
http-proxy-host = my.proxy.server
http-proxy-port = 8080

Since Intellij 9.0.3 you now also need to set this information in the svn settings.

  • Share/Bookmark

@ 12:07

svn

Permalink

Log4J settings for working with Hibernate


	
	
  		
	
	
  		
	
	
  		
	
	

	

  • Share/Bookmark

@ 12:07

hibernate

Permalink

Installing JRuby with Intellij (OS X)

GET it from http://jruby.org/

There is a download page, download and exract the tar file somehwere.

I put it in /System/Library/Frameworks/JRuby.framework/jruby-1.5.1

I then created a symbolic link to jruby_current

ln -s jruby-1.5.1/ jruby_current

And then simply add it to my ~/.bash_profile

$vi ~/.bash_profile
export PATH=/System/Library/Frameworks/JRuby.framework/jruby_current/bin:$PATH
#Reload the profile…
$. ~/.bash_profile
#Try out jruby…
$jruby -v
jruby 1.5.1 (ruby 1.8.7 patchlevel 249) (2010-06-06 f3a3480) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_17) [x86_64-java]

Now you can add the JRuby SDK to your Java Module in Intellij:

Now you can have ruby and Java in the same project. Awesome.

  • Share/Bookmark

@ 09:07

build
intellij
java
jruby
ruby
thoughtblog

Permalink

Resources not available on classpath in Intellij

Today I spent a while puzzling over why my StringTemplates weren’t available on the classpath in Intellij.

I forgot that you have to specifically identify file types to copy into the classes folder, you do it in the project settings. Search for “resource” and look in the compiler settings.

  • Share/Bookmark

@ 15:07

intellij

Permalink