Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: Spring + hibernate

  1. #11
    Join Date
    Aug 2011
    Location
    Sydney
    Posts
    37

    Default

    Hi BlackBeard

    in Groupe class

    1. constructor method has to be public.

    remove the black constructor method from your Group class.
    give try.

    ===========================
    remove this ->
    private Groupe(){

    }
    ===========================

    Placidus.

  2. #12
    Join Date
    Aug 2011
    Posts
    20

    Arrow

    Hello

    I change all of the Groupe class code with this code, and i still have the same problem

    Code:
    package m;
    // default package
    // Generated 28 août 2011 02:18:20 by Hibernate Tools 3.4.0.CR1
    
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    import javax.persistence.Table;
    
    /**
     * Groupe generated by hbm2java
     */
    @Entity
    @Table(name = "groupe", catalog = "pfedb")
    public class Groupe implements java.io.Serializable {
    
    	private String groupeId;
    	
    	public Groupe(){
    		
    	}
    	
    	public Groupe(String groupeId) {
    		this.groupeId = groupeId;
    	}
    
    	@Id
    	@Column(name = "groupeID", unique = true, nullable = false)
    	public String getGroupeId() {
    		return this.groupeId;
    	}
    
    	public void setGroupeId(String groupeId) {
    		this.groupeId = groupeId;
    	}
    
    }
    Code:
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [appco.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'annotatedClasses' of bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Bean property 'annotatedClasses' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
    org.springframework.beans.NotWritablePropertyException: Invalid property 'annotatedClasses' of bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Bean property 'annotatedClasses' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:670)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:572)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:737)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:764)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:753)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1061)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:857)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:378)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
    	at m.Main.main(Main.java:17)
    plz help me i'm using th Spring 3.1 version
    and this is the list of all the jars that i use for this project, there are all in the class path of this project

    Code:
    commons-codec-1.4.jar
    commons-io-1.4.jar
    commons-lang-2.4.jar
    hibernate-jpa-2.0-api-1.0.0.Final.jar
    hibernate-search-analyzers-3.4.0.Final.jar
    i18nlog-1.0.10.jar
    infinispan-core-4.2.1.FINAL.jar
    infinispan-lucene-directory-4.2.1.FINAL.jar
    jboss-transaction-api-1.0.1.GA.jar
    jgroups-2.12.0.Final.jar
    jgroups-2.8.0.GA.jar
    log4j-1.2.16.jar
    lucene-analyzers-3.1.0.jar
    marshalling-api-1.2.3.GA.jar
    rhq-pluginAnnotations-3.0.1.jar
    river-1.2.3.GA.jar
    slf4j-log4j12-1.6.1.jar
    solr-analysis-extras-3.1.0.jar
    solr-commons-csv-3.1.0.jar
    solr-core-3.1.0.jar
    solr-solrj-3.1.0.jar
    jms-1.1.jar
    jsr250-api-1.0.jar
    jta-1.1.jar
    antlr-2.7.6.jar
    commons-collections-3.1.jar
    commons-lang-2.4.jar
    dom4j-1.6.1.jar
    hibernate-commons-annotations-3.2.0.Final.jar
    hibernate-core-3.6.3.Final.jar
    lucene-core-3.1.0.jar
    slf4j-api-1.6.1.jar
    hibernate-search-3.4.0.Final.jar
    hibernate-search-infinispan-3.4.0.Final.jar
    javassist.jar
    mysql-connector-java-5.1.17-bin.jar
    org.springframework.aop-3.1.0.M2.jar
    org.springframework.asm-3.1.0.M2.jar
    org.springframework.aspects-3.1.0.M2.jar
    org.springframework.beans-3.1.0.M2.jar
    org.springframework.context-3.1.0.M2.jar
    org.springframework.context.support-3.1.0.M2.jar
    org.springframework.core-3.1.0.M2.jar
    org.springframework.expression-3.1.0.M2.jar
    org.springframework.instrument-3.1.0.M2.jar
    org.springframework.instrument.tomcat-3.1.0.M2.jar
    org.springframework.jdbc-3.1.0.M2.jar
    org.springframework.jms-3.1.0.M2.jar
    org.springframework.orm-3.1.0.M2.jar
    org.springframework.oxm-3.1.0.M2.jar
    org.springframework.test-3.1.0.M2.jar
    org.springframework.transaction-3.1.0.M2.jar
    org.springframework.web-3.1.0.M2.jar
    org.springframework.web.portlet-3.1.0.M2.jar
    org.springframework.web.servlet-3.1.0.M2.jar
    org.springframework.web.struts-3.1.0.M2.jar
    Thank you

    i'm waiting for the response
    ---------------
    Blacky

  3. #13
    Join Date
    Aug 2011
    Location
    Sydney
    Posts
    37

    Default

    1. remove the Groupe -> constructor method.
    2. remane the class to some thing else , this will make sure it's accessing new class -> like Groupe2

    give try.

  4. #14
    Join Date
    Jul 2010
    Location
    Venice, Italy
    Posts
    709

    Default

    I'd start by using the correct headers on your xml. You say you're using the latest Spring version (I suppose 3.0.5 or 3.1) but you use the dtd on the header which is deprecated since Spring 2. This is the proper way to start your applicationContext.xml:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" 
    	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xsi:schemaLocation="http://www.springframework.org/schema/beans 
           					   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                			   http://www.springframework.org/schema/context 
                			   http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    Also, check that the Spring version and Hibernate version used are in fact compatible (and I suggest using Maven to resolve both framework dependencies).

  5. #15
    Join Date
    Aug 2011
    Posts
    20

    Red face

    Hello
    thanks for the reply

    I use the Eclipse INDIGO, the hibernate-search-3.4.0.Final-dist.zip and spring-framework-3.1.0.M2.zip

    I resolve the problem, i'm soory because i had put another old version of the Spring in the C:\Program Files\Java\jre6\lib\ext folder i forgot that
    so i remove all of their old jars

    I still have this problem

    Code:
    Exception in thread "main" java.lang.ClassCastException: org.hibernate.impl.SessionFactoryImpl cannot be cast to org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
    	at m.Main.main(Main.java:18)
    and thank you very much
    Last edited by BlackBeard; Aug 31st, 2011 at 01:28 AM.

  6. #16
    Join Date
    Aug 2011
    Posts
    20

    Default

    can any one help me ?!!!!!!!!!!!!!!!!!!!!!!!!

  7. #17
    Join Date
    Aug 2011
    Posts
    20

    Unhappy

    Hello
    I still waiting for the response

    ------------
    Blacky

  8. #18
    Join Date
    Dec 2010
    Location
    Singapore
    Posts
    286

    Default

    Hello, tried the same configuration and it worked.

    Only changes i did was using hsql db and following,

    Code:
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		BasicDataSource mds=(BasicDataSource) (new XmlBeanFactory(new ClassPathResource("appco.xml")).getBean("myDataSource"));
    		SessionFactory lse= (SessionFactory) (new XmlBeanFactory(new ClassPathResource("appco.xml")).getBean("sessionFactory"));
    
    		System.out.println("Hello");
    	}
    Please post your applicationContext.xml too
    Amila Domingo

  9. #19
    Join Date
    Aug 2011
    Posts
    20

    Exclamation

    Hello
    you can see the configuration context file
    at the begining of this therad
    http://forum.springsource.org/showth...ring-hibernate

    i want to use the AnnotaionSessionFactoryBean class
    is there any other solution ?

    thank you
    ----------------
    Blacky

  10. #20
    Join Date
    Dec 2010
    Location
    Singapore
    Posts
    286

    Default

    I used AnnotationSessionFactoryBean and it works.

    Exception in thread "main" java.lang.ClassCastException: org.hibernate.impl.SessionFactoryImpl cannot be cast to org.springframework.orm.hibernate3.annotation.Anno tationSessionFactoryBean
    at m.Main.main(Main.java:18)
    Above exception comes because of invalid casting.

    What is the reason you want to get AnnotationSessionFactoryBean from context?
    Amila Domingo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •