Archive for July, 2008

Could not instantiate bean class Is it an abstract class?

Ran into an interesting error this afternoon.  I have a base class which is abstract and when i deployed my app I received the above error.

The fix is simple add abstract=”true” to your bean defination:

<bean id=”baseHandler” class=”com.zeninvent.justcars.web.handler.BaseHandler” abstract=”true”>

Hey Presto!

Leave a Comment

The input type of the launch configuration does not exist

Trying to run a JUnit test case & getting this error?

Right click on the folder in which you have located the test case and under build path – select use as source folder

Hey Presto!

Leave a Comment

Required extension “ant” not found Spring 2.0

Having this problem! It’s caused me untold trouble. Anyway the problem is actually in the spring distribution. Unzip the commons-attributes-compiler.jar, open the MANIFEST.MF and remove lines with a space and text.

Example:

ant-Implementation-URL: http://www.ibiblio.org/maven/ant/jars/ant-1.5.
jar

Should be replaced with:

ant-Implementation-URL: http://www.ibiblio.org/maven/ant/jars/ant-1.5.jar

There is quite a few of these to be fixed.

Save the file.

Rezip and ensure the .jar extension

Hey Presto!

Comments (3)

Spring Hibernate hbm2ddl.auto & Annotations

Spent Yesterday and today drawing up a schema for www.justcars.ie Ireland’s newest and hottest place to source your car.

To create this schema I wanted to get hibernate generate it via the POJOs I create. I am using annotations. So here is what i did:

Step One:

Create the POJO:

@Entity
public class Manufacteur {

@Id
private Integer manufacteurlId;

…..

}

Make sure you import javax.persistence.*; & not the more intuitive sounding hibernate one .

Step Two:

I am using a hibernate.cfg.xml for neatness:

<hibernate-configuration>
<session-factory name=”justCarsSessionFactory”>
<property name=”hibernate.connection.driver_class”>org.gjt.mm.mysql.Driver</property>
<property name=”hibernate.connection.password”>yourPassword</property>
<property name=”hibernate.connection.url”>jdbc:mysql://localhost:3306/YourScehma</property>
<property name=”hibernate.connection.username”>YourUsername</property>
<property name=”hibernate.default_schema”>jYourScehma</property>
<property name=”hibernate.dialect”>org.hibernate.dialect.MySQL5Dialect</property>
<property name=”show_sql”>true</property>
<property name=”hibernate.format_sql”>true</property>
<property name=”hibernate.hbm2ddl.auto”>create-drop</property>
<mapping package=”com.zeninvent.justcars.business”/>
<mapping class=”com.zeninvent.justcars.business.Manufacteur”/>
</session-factory>
</hibernate-configuration>

Change the pieces in bold as appropriate.

Step Three servlet:

Ensure your session factory bean if you are using annotations is using the AnnotationSession otherwise you will get an “Annotation Instance required ” exception.

Point the session factory to your hibernate.cfg.xml

<bean id=”sessionFactory” class=”org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean”>

<property name=”configLocation”><value>/WEB-INF/hibernate.cfg.xml</value></property>
<property name=”schemaUpdate”><value>true</value></property>
</bean>

Step Four:

Depoly & hey Presto hibernate is creating your schema! :)

Leave a Comment