Announcement Announcement Module
Collapse
No announcement yet.
Hibernate SessionFactory: can't instantiate bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate SessionFactory: can't instantiate bean

    Does anybody recognize this error?

    Code:
    org.springframework.beans.factory.BeanCreationException: Error 
    creating bean with name 'mySessionFactory': Post-processing of the 
    FactoryBean's object failed; nested exception is 
    java.lang.SecurityException: Unable to get members for class 
    org.hibernate.impl.SessionFactoryImpl
    Well, I have this Spring3 configuration:

    Code:
    <bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="com.google.appengine.api.rdbms.AppEngineDriver" />
            <property name="url" value="jdbc:google:rdbms://xx:xx/nomedb" />
        </bean>
    
    
        <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
            <property name="dataSource" ref="myDataSource" />
            <property name="annotatedClasses">
                <list>
                    <value>it.trew.prove.model.beans.Scadenza</value>
                    <value>it.trew.prove.model.beans.Fornitore</value>
                    <value>it.trew.prove.model.beans.Societa</value>
                </list>
            </property>
            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                    <prop key="hibernate.show_sql">true</prop>
                    <prop key="hibernate.hbm2ddl.auto">create</prop>
                    <!-- <prop key="hibernate.hbm2ddl.import_files">/setup.sql</prop> -->
                </props>
            </property>
        </bean>
    
        <tx:annotation-driven transaction-manager="transactionManager" />
    
        <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory" ref="mySessionFactory" />
        </bean>
    I can't see nothing wrong in this code, I have all dependencies, last versions.

    On Google AppEngine, it does not work.

  • #2
    Hello

    Post the complete error stack trace, perhaps some detail is there and should be most useful,

    BTW about the follow

    Code:
    <bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="com.google.appengine.api.rdbms.AppEngineDriver" />
            <property name="url" value="jdbc:google:rdbms://xx:xx/nomedb" />
        </bean>
    with

    Code:
    <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                    <prop key="hibernate.show_sql">true</prop>
                    <prop key="hibernate.hbm2ddl.auto">create</prop>
                    <!-- <prop key="hibernate.hbm2ddl.import_files">/setup.sql</prop> -->
                </props>
            </property>
    Blue and red part are not related, which DB you are using?

    Comment


    • #3
      ???

      I am using Google Cloud SQL. It is a MySQL hosted by Google, and my db configuration worked since the beginning of my project!



      Now it looks like I am missing some dependency, so I paste my maven pom.xml:

      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
      
        <!-- The Basics -->
        <groupId>it.trew.prove</groupId>
        <artifactId>ProveCloudSql</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>war</packaging>
        
        
      
        <pluginRepositories>
          <pluginRepository>
            <id>maven-gae-plugin-repo</id>
            <name>Maven Google App Engine Repository</name>
            <url>http://maven-gae-plugin.googlecode.com/svn/repository/</url>
          </pluginRepository>
        </pluginRepositories>
        
        <repositories>
        	<repository>
              <id>google-maven-repo</id>
              <name>Google Maven Repository</name>
              <url>http://google-maven-repository.googlecode.com/svn/repository/</url>
          </repository>
          <repository>
            <id>JBoss repository</id>
            <url>http://repository.jboss.org/maven2/</url>
          </repository>
        </repositories>
        
      	<dependencies>
      	
      	<!-- Hibernate framework -->
      	<dependency>
      	    <groupId>org.hibernate</groupId>
      	    <artifactId>hibernate-core</artifactId>
      	    <version>3.3.2.GA</version>
      	    <!--hibernate-dependencies is a pom, not needed for hibernate-core-->
      	  </dependency>
      	  <dependency>
      	    <groupId>org.hibernate</groupId>
      	    <artifactId>hibernate-annotations</artifactId>
      	    <version>3.4.0.GA</version>
        	</dependency>
        	<dependency>
      		<groupId>javassist</groupId>
      		<artifactId>javassist</artifactId>
      		<version>3.12.1.GA</version>
      	</dependency>
      
          <!-- Google App Engine meta-package -->
          <dependency>
            <groupId>net.kindleit</groupId>
            <artifactId>gae-runtime</artifactId>
            <version>${gae.version}</version>
            <type>pom</type>
          </dependency>
              	
      	<!-- BeanUtils -->
      	<dependency>  
      	  <groupId>commons-beanutils</groupId>  
      	  <artifactId>commons-beanutils</artifactId>  
      	  <version>1.8.3</version>  
      	</dependency> 
      	
      	        	
      	<!-- Jackson JSON Processor -->
      	<dependency>
      		<groupId>org.codehaus.jackson</groupId>
      		<artifactId>jackson-mapper-asl</artifactId>
      		<version>1.8.1</version>
      	</dependency>
              
      	<!-- Mysql (uso locale) -->
      	<dependency>
              <groupId>mysql</groupId>
              <artifactId>mysql-connector-java</artifactId>
              <version>5.1.18</version>
          </dependency>
          
              
      		<!-- Spring -->
      		<dependency>
      			<groupId>org.springframework</groupId>
      			<artifactId>spring-context</artifactId>
      			<version>${org.springframework-version}</version>
      		</dependency>
      		<dependency>
      			<groupId>org.springframework</groupId>
      			<artifactId>spring-webmvc</artifactId>
      			<version>${org.springframework-version}</version>
      		</dependency>
      		<dependency>
      		   <groupId>org.springframework</groupId>
      		   <artifactId>spring-orm</artifactId>
      		   <version>${org.springframework-version}</version>
      		</dependency>
      		
      		<!-- AspectJ -->
      		<dependency>
      			<groupId>org.aspectj</groupId>
      			<artifactId>aspectjrt</artifactId>
      			<version>${org.aspectj-version}</version>
      		</dependency>	
      		
      		<dependency>
      			<groupId>cglib</groupId>
      			<artifactId>cglib</artifactId>
      			<version>2.2.2</version>
      		</dependency>
      		            
      		
      		<!-- Logging -->
      		<dependency>
      		    <groupId>org.slf4j</groupId>
      		    <artifactId>slf4j-log4j12</artifactId>
      		    <version>1.5.2</version>
      		</dependency>
      		
      
      		<!-- @Inject -->
      		<dependency>
      			<groupId>javax.inject</groupId>
      			<artifactId>javax.inject</artifactId>
      			<version>1</version>
      		</dependency>
      				
      		<!-- Servlet -->
      		<dependency>
      			<groupId>javax.servlet</groupId>
      			<artifactId>servlet-api</artifactId>
      			<version>2.5</version>
      			<scope>provided</scope>
      		</dependency>
      		<dependency>
      			<groupId>javax.servlet.jsp</groupId>
      			<artifactId>jsp-api</artifactId>
      			<version>2.1</version>
      			<scope>provided</scope>
      		</dependency>
      		<dependency>
      			<groupId>javax.servlet</groupId>
      			<artifactId>jstl</artifactId>
      			<version>1.2</version>
      		</dependency>
      		
      		
      		<!-- Tiles -->
      		<dependency>
      	    	<groupId>org.apache.tiles</groupId>
      	    	<artifactId>tiles-extras</artifactId>
      	    	<version>2.2.2</version>
      	    </dependency>
      			
      
      		<!--
      			Make use of JSP tags. Remove, if you don't use JSPs
      		-->
      		<dependency>
      			<artifactId>standard</artifactId>
      			<groupId>taglibs</groupId>
      			<version>1.1.2</version>
      			<type>jar</type>
      			<scope>runtime</scope>
      		</dependency>
      
      		<!-- Test scope -->
      		<dependency>
      			<groupId>junit</groupId>
      			<artifactId>junit</artifactId>
      			<version>4.7</version>
      			<scope>test</scope>
      		</dependency>
      
      		<!--
      			GAE libraries for local testing as described here:
      			http://code.google.com/appengine/doc...ittesting.html
      		-->
      		<dependency>
      			<groupId>com.google.appengine</groupId>
      			<artifactId>appengine-api-labs</artifactId>
      			<version>${gae.version}</version>
      			<scope>test</scope>
      		</dependency>
      
      		<dependency>
      			<groupId>com.google.appengine</groupId>
      			<artifactId>appengine-api-stubs</artifactId>
      			<version>${gae.version}</version>
      			<scope>test</scope>
      		</dependency>
      
      		<dependency>
      			<groupId>com.google.appengine</groupId>
      			<artifactId>appengine-testing</artifactId>
      			<version>${gae.version}</version>
      			<scope>test</scope>
      		</dependency>
              
       
      	</dependencies>
      
      	<build>
      		<plugins>
      						
      			<plugin>
      				<groupId>org.apache.maven.plugins</groupId>
      				<artifactId>maven-war-plugin</artifactId>
      				<version>2.1-beta-1</version>
      				<configuration>
      					<webResources>
      						<resource>
      							<directory>src/main/webapp</directory>
      							<filtering>true</filtering>
      							<includes>
      								<include>**/appengine-web.xml</include>
      							</includes>
      						</resource>
      					</webResources>
      				</configuration>
      			</plugin>
      
      			<!--
      				The actual maven-gae-plugin. Type "mvn gae:run" to run project, "mvn
      				gae:deploy" to upload to GAE.
      			-->
      			<plugin>
      				<groupId>net.kindleit</groupId>
      				<artifactId>maven-gae-plugin</artifactId>
      				<version>0.9.2</version>
      		        <dependencies>
      		          <dependency>
      		            <groupId>net.kindleit</groupId>
      		            <artifactId>gae-runtime</artifactId>
      		            <version>${gae.version}</version>
      		            <type>pom</type>
      		          </dependency>
      		        </dependencies>
      		        <configuration>
      		        	<jvmFlags>
      		        		<jvmFlag>-Drdbms.server=local</jvmFlag>
      		        		<jvmFlag>-Drdbms.driver=com.mysql.jdbc.Driver</jvmFlag>
      		        		<jvmFlag>-Drdbms.url=jdbc:mysql://localhost:3306/prova?user=root&amp;password=pass</jvmFlag>
      		        	</jvmFlags>
                          <serverId>appengine.google.com</serverId>
      <!--                     <sdkDir>${appengine.sdk.root}</sdkDir> -->
      <!--                     <appDir>${basedir}/war</appDir> -->
                      </configuration>
      			</plugin>
      
      			<plugin>
      				<artifactId>maven-release-plugin</artifactId>
      				<configuration>
      					<goals>gae:deploy</goals>
      				</configuration>
      			</plugin>
      
      			<!-- Java compiler version -->
      			<plugin>
      				<groupId>org.apache.maven.plugins</groupId>
      				<artifactId>maven-compiler-plugin</artifactId>
      				<version>2.0</version>
      				<configuration>
      					<source>1.6</source>
      					<target>1.6</target>
      				</configuration>
      			</plugin>
      		</plugins>
      	</build>
      
      	
      	<properties>
      				
      		<downloadSources>true</downloadSources>
      		<gae.version>1.6.0</gae.version>
      		<gae.home>/opt/appengine-java-sdk-1.6.0</gae.home>
      		<gae.application.version>1</gae.application.version>
      		
      		<org.springframework-version>3.0.6.RELEASE</org.springframework-version>
      		<org.aspectj-version>1.6.9</org.aspectj-version>
      		<org.slf4j-version>1.5.10</org.slf4j-version>
      
      	</properties>
      	
      
      	<profiles>
      		
      		<profile>
      			<id>integration-build</id>
      			<properties>
      				<gae.application.version>stage</gae.application.version>
      			</properties>
      		</profile>
      
      		<profile>
      			<id>release-build</id>
      			<activation>
      				<property>
      					<name>performRelease</name>
      					<value>true</value>
      				</property>
      			</activation>
      			<properties>
      				<gae.application.version>release</gae.application.version>
      			</properties>			
      		</profile>
      	</profiles>
      
      </project>
      Other details here: http://stackoverflow.com/questions/9...stantiate-bean

      Comment

      Working...
      X