Skip to content

My Latest Issue with Groovy, Spring, and Hibernate

I started this post about a year ago; I will admit my use of groovy has been a little tumultuous, and that’s prevented me from writing much about it.

I’ve started a little webapp project – just something simple at first, to get back into doing the type of work that I enjoy doing (as opposed to what I have to do to earn a living)…

The thing is, I keep running into Groovy bugs that appear to be closed but are still in the latest release, after debugging for an hour or two. In looking through the groovy website for a release candidate or some beta or alpha version, I didn’t see one. So rather than chalk up my efforts to a wasted attempt, I thought I’d post what I have here:

Here is what I put together for a simple spring config:






	

			classpath:org/reverttoconsole/mymediamanager/resource/mmm.properties
		
	

	

			
		


				org.reverttoconsole.mymediamanager.model
			
		



					${default.schema}
				

					${hibernate.dialect}
				

					org.hibernate.cache.EhCacheProvider
				
			
		
	

	

			
		
true
	

    

            ${driver.class}
        

        	${jdbc.url}
        

            ${mmm.user}
        

            ${mmm.password}
        
    

    

    

    

    		
    	
    


This is what I had in place for a model class:

package org.reverttoconsole.mymediamanager.model;

import javax.persistence.Entity
import javax.persistence.SequenceGenerator
import javax.persistence.GeneratedValue
import javax.persistence.Id
import javax.persistence.Column
import javax.persistence.Table
import javax.persistence.Basic

@Entity
@Table(name="MEDIA")
@SequenceGenerator(
	    name="SEQ_GEN",
	    sequenceName="media_seq", allocationSize=20)
class Media {

	@Id
	@GeneratedValue(generator = "media_seq")
	@Column(name="MEDIA_ID")
	def mediaId

	@Basic(optional=false)
	@Column(nullable=false)
	def type

	@Basic(optional=false)
	@Column(nullable=false)
	def fileName

	@Basic(optional=false)
	@Column(nullable=false)
	directory
}

And a dao:

package org.reverttoconsole.mymediamanager.dao;

import org.reverttoconsole.mymediamanager.model.Media
import org.springframework.orm.hibernate3.support.HibernateDaoSupport

class MediaDao extends HibernateDaoSupport {

	void addMedia(def media){
		hibernateTemplate.save(media)
	}
}

My simple integration test looked like this:

package org.reverttoconsole.mymediamanager.integration

import org.apache.log4j.xml.DOMConfigurator
import org.springframework.context.support.ClassPathXmlApplicationContext

import org.reverttoconsole.mymediamanager.dao.MediaDao

class SimpleTest extends GroovyTestCase {

	def context
	def mediaDao

	void setUp() {
		DOMConfigurator.configure("src/org/reverttoconsole/mymediamanager/resource/log4j.xml")
		context =
			new ClassPathXmlApplicationContext("./org/reverttoconsole/mymediamanager/resource/mmmDatabaseContext.xml")
	}

	void testSomething() {
                assert context
		mediaDao = (MediaDao)context.getBean("mediaDao")
// still working on this...
	}

}

And I added an ant script:








		
			
		
	



	

	
		
	

	

		
	

	

		
	

	
		
		
	

	
		
		
	

	
		
		
	

	
		
	

	
	

The specific error I keep seeing is:

\home\Jeff\work\mymediamanager\build.xml:61: groovy.lang.MissingMethodException: No signature of method: org.reverttoconsole.mymediamanager.integration.SimpleTest.main() is applicable for argument types: ([Ljava.lang.String;) values: {[]}

Although I also see various compilation errors sporadically, which I attribute to my eclipse setup.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*