一尘不染

Spring Autowiring停止在GAE上工作

hibernate

我确定我的应用程序一直运行到昨天,直到出现此错误:

Failed startup of context com.google.apphosting.utils.jetty.RuntimeAppEngineWebAppContext@1079ff{/,/ base/data/home/apps/s~trewnewmedia/1.357617962256387950} org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘scadenziarioController’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void it.trew.prove.web.controllers.ScadenziarioController.setScadenzaService(it. trew.prove.services.ScadenzaService); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘scadenzaService’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void it.trew.prove.services.ScadenzaService.setSocietaService(it.trew.prove.serv ices.SocietaService); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘societaService’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void it.trew.prove.services.SocietaService.setSocietaDao(it.trew.prove.model.dao .Dao); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dao’: Injection of resource dependencies failed; nested exception is 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

我将Hibernate与Google Cloud SQL一起使用,并且始终可以正常工作。

在我的本地计算机上,使用本地MySQL仍然可以使用!

我不认为这是Cloud SQL的问题,因为删除一些仍自动连接的自动装配(测试),依此类推。这是我的xml:

<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>

我的DAO的一部分:

@Component
public class Dao {

    @Resource(name = "mySessionFactory")
    private SessionFactory sessionFactory;
...

而我的服务:

@Service
@Transactional
public class SocietaService {

    private Dao societaDao;

    @Autowired
    public void setSocietaDao(Dao societaDao) {
        this.societaDao = societaDao;
    }
...

我找不到GAE和本地(mvn gae:run)之间的区别。以及为什么上周效果理想。

请GAE团队支持我! 我在这个问题上疯了

(我可能会开始赏金,太紧急了)

编辑 我的pom.xmlhibernate部分:

<!-- Hibernate framework -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.3.2.GA</version>
        <type>pom</type>
        <!--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>

阅读 244

收藏
2020-06-20

共1个答案

一尘不染

问题是@Service类上的@Transactional批注。它在某些我不知道的地方使用了javax.naming.NamingException,这不是一个列入白名单的类。

2020-06-20