问题描述
项目名称:CarpoolDB,我已经在另一个应用程序名称Carpool中为此项目添加了jar。在运行Carpool应用程序时,出现以下异常。
项目:Carpool。
在这里,我收到了异常,因为carpoolService在作为Google Web应用程序运行时没有自动装入,但是同样在Tomcat下运行,并且bean正确地被注入。
@Controller
public class PlacesSearchController {
$ b $ @Autowired
CarpoolService carpoolService = null;
公共CarpoolService getCarpoolService(){
返回carpoolService;
}
public void setCarpoolService(CarpoolService carpoolService){
this.carpoolService = carpoolService;
}
}
carpool-application-context1.xml
另外我还有applicationContext-security.xml,用于弹簧安全。
项目:CarpoolDB
所有课程都在包中,com.company.carpooldb.db
public interface CarpoolService {
public boolean validateUser(User user);
$ b @Service(carpoolService)
public class CarpoolServiceImpl implements CarpoolService {
$ b $ @Autowired
private CarpoolDao carpoolDao = null;
public CarpoolDao getCarpoolDao(){
return carpoolDao;
}
public void setCarpoolDao(CarpoolDao carpoolDao){
this.carpoolDao = carpoolDao;
$ b @Override
public boolean validateUser(User user){
return carpoolDao.validateUser(user);;
}
}
public interface CarpoolDao {
public boolean validateUser(User user);
$ b $ public class CarpoolDaoImpl extends HibernateDaoSupport implements CarpoolDao {
@Override
public boolean validateUser(User user){
// TODO自动生成的方法存根
返回false;
carpool-application-context.xml
< context:annotation-config />
< context:component-scan base-package =com.onmobile/>
< context:property-placeholder location =classpath:server.properties/>
< bean id =sessionFactory
class =org.springframework.orm.hibernate3.LocalSessionFactoryBean>
< property name =mappingResources>
< list>
<值> com\company\carpooldb\hbm\User.hbm.xml< /值>
< / list>
< / property>
< property name =hibernateProperties>
<道具>
< prop key =hibernate.dialect><! - 根据底层数据库的类型使用hibernate的方言 - >
org.hibernate.dialect.MySQLDialect
< / prop>
< prop key =hibernate.show_sql> false< / prop>
< /道具>
< / property>
< property name =dataSource>< ref bean =dataSource/>< / property>
< / bean>
< bean:bean id =dataSourceclass =org.apache.commons.dbcp.BasicDataSourcedestroy-method =close>
< beans:property name =driverClassName>< beans:value> $ {cm.db.driverClassName}< /bean:value>< / beans:property>
< beans:property name =url>< beans:value> $ {cm.db.url}< / beans:value>< / beans:property>
< beans:property name =username>< beans:value> $ {cm.db.username}< / beans:value>< / beans:property>
< beans:property name =password>< beans:value> $ {cm.db.password}< / beans:value>< / beans:property>
< beans:property name =testOnBorrow>< beans:value> true< / beans:value>< / beans:property>
< beans:property name =testOnReturn>< beans:value> true< / beans:value>< / beans:property>
< beans:property name =validationQuery>< beans:value> select 1< /bean:value>< / beans:property>
< / beans:bean>
< bean id =transactionManager
class =org.springframework.orm.hibernate3.HibernateTransactionManager>
< property name =sessionFactory>
< ref bean =sessionFactory/>
< / property>
< / bean>
< bean id =carpoolDaoImplclass =com.company.carpooldb.db.CarpoolDaoImpl>
< property name =sessionFactory>
< ref bean =sessionFactory/>
< / property>
< / bean>
在运行应用程序时,我收到了异常,
log4j:WARN默认初始化期间出错
java.lang.NoClassDefFoundError:java.io.FileOutputStream是一个受限制的类。有关更多详细信息,请参阅Google App Engine开发人员指南。
at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:290)
.........
在com.google.appengine.tools.development.DevAppServerMain $ StartAction.apply(DevAppServerMain.java:162)
at com .google.appengine.tools.util.Parser $ ParseResult.applyArgs(Parser.java:48)
,位于com.google.appengine.tools.development.DevAppServerMain。< init>(DevAppServerMain.java:113)
,位于com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:89)
log4j:WARN无法为记录器(org.springframework.web.context.ContextLoader)找到appender。
log4j:WARN请正确初始化log4j系统。
2012年11月11日下午5点14分18秒com.google.apphosting.utils.jetty.JettyLogger警告
警告:上下文启动失败com.google.apphosting.utils.jetty.DevAppEngineWebAppContext@5e55ab { /,D:\EclipseEuropa\CarpoolingGAE\war}
org.springframework.beans.factory.BeanCreationException:创建名为'placesSearchController'的bean时出错:自动布线依赖关系注入失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:无法自动装入字段:com.onmobile.carpooldb.db.CarpoolService com.onmobile.carpool.controller.PlacesSearchController.carpoolService;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名为'carpoolService'的bean时出错:注入自动装配依赖失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:无法自动装入字段:private com.onmobile.carpooldb.db.CarpoolDao com.onmobile.carpooldb.db.CarpoolServiceImpl.carpoolDao;嵌套的异常是org.springframework.beans.factory.BeanCreationException:在类路径资源[carpool-application-context.xml]中定义名称为'carpoolDaoImpl'的bean时出错:无法在设置bean属性'sessionFactory时解析对bean'sessionFactory'的引用;嵌套的异常是org.springframework.beans.factory.BeanCreationException:在类路径资源[carpool-application-context.xml]中定义名称为'sessionFactory'的bean时出错:init方法的调用失败;嵌套异常是java.lang.NoClassDefFoundError:java.net.InetAddress是一个受限制的类。有关更多详细信息,请参阅Google App Engine开发人员指南。
在org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1064)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
.........
com.google.appengine.tools .development.DevAppServerMain。< init>(DevAppServerMain.java:113)
com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:89)
引起:org。 springframework.beans.factory.BeanCreationException:无法自动装入字段:com.onmobile.carpooldb.db.CarpoolService com.onmobile.carpool.controller.PlacesSearchController.carpoolService;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名为'carpoolService'的bean时出错:注入自动装配依赖失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:无法自动装入字段:private com.onmobile.carpooldb.db.CarpoolDao com.onmobile.carpooldb.db.CarpoolServiceImpl.carpoolDao;嵌套的异常是org.springframework.beans.factory.BeanCreationException:在类路径资源[carpool-application-context.xml]中定义名称为'carpoolDaoImpl'的bean时出错:无法在设置bean属性'sessionFactory时解析对bean'sessionFactory'的引用;嵌套的异常是org.springframework.beans.factory.BeanCreationException:在类路径资源[carpool-application-context.xml]中定义名称为'sessionFactory'的bean时出错:init方法的调用失败;嵌套异常是java.lang.NoClassDefFoundError:java.net.InetAddress是一个受限制的类。有关更多详细信息,请参阅Google App Engine开发人员指南。
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:507)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java: 84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:283)
... 31 more
引起:org.springframework.beans.factory .BeanCreationException:创建名为'carpoolService'的bean时出错:注入自动装配依赖失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:无法自动装入字段:private com.onmobile.carpooldb.db.CarpoolDao com.onmobile.carpooldb.db.CarpoolServiceImpl.carpoolDao;嵌套的异常是org.springframework.beans.factory.BeanCreationException:在类路径资源[carpool-application-context.xml]中定义名称为'carpoolDaoImpl'的bean时出错:无法在设置bean属性'sessionFactory时解析对bean'sessionFactory'的引用;嵌套的异常是org.springframework.beans.factory.BeanCreationException:在类路径资源[carpool-application-context.xml]中定义名称为'sessionFactory'的bean时出错:init方法的调用失败;嵌套异常是java.lang.NoClassDefFoundError:java.net.InetAddress是一个受限制的类。有关更多详细信息,请参阅Google App Engine开发人员指南。
在org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1064)
....在org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:780)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
... 33 more
导致:org.springframework .beans.factory.BeanCreationException:无法自动装入字段:private com.onmobile.carpooldb.db.CarpoolDao com.onmobile.carpooldb.db.CarpoolServiceImpl.carpoolDao;嵌套的异常是org.springframework.beans.factory.BeanCreationException:在类路径资源[carpool-application-context.xml]中定义名称为'carpoolDaoImpl'的bean时出错:无法在设置bean属性'sessionFactory时解析对bean'sessionFactory'的引用;嵌套的异常是org.springframework.beans.factory.BeanCreationException:在类路径资源[carpool-application-context.xml]中定义名称为'sessionFactory'的bean时出错:init方法的调用失败;嵌套异常是java.lang.NoClassDefFoundError:java.net.InetAddress是一个受限制的类。有关更多详细信息,请参阅Google App Engine开发人员指南。
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:507)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java: 84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:283)
... 44 more
引起:org.springframework.beans.factory .BeanCreationException:创建在类路径资源[carpool-application-context.xml]中定义名为'carpoolDaoImpl'的bean时出错:设置bean属性'sessionFactory'时无法解析对bean'sessionFactory'的引用。嵌套的异常是org.springframework.beans.factory.BeanCreationException:在类路径资源[carpool-application-context.xml]中定义名称为'sessionFactory'的bean时出错:init方法的调用失败;嵌套异常是java.lang.NoClassDefFoundError:java.net.InetAddress是一个受限制的类。有关更多详细信息,请参阅Google App Engine开发人员指南。
在org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)中的
。
.... at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:697)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject( AutowiredAnnotationBeanPostProcessor.java:478)
... 46 more
导致:org.springframework.beans.factory.BeanCreationException:在类路径资源中定义的名为'sessionFactory'的bean创建时出错[carpool-application- context.xml]:调用init方法失败;嵌套异常是java.lang.NoClassDefFoundError:java.net.InetAddress是一个受限制的类。有关更多详细信息,请参阅Google App Engine开发人员指南。
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1412)
.... at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver。 java:322)
... 59 more
导致:java.lang.NoClassDefFoundError:java.net.InetAddress是一个受限制的类。有关更多详细信息,请参阅Google App Engine开发人员指南。
at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
.... at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory。 invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1457)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
... 66 more
2012年11月11日5:14:18 PM com.google.apphosting.utils.jetty.JettyLogger警告
警告:嵌套在org.springframework.beans.factory.BeanCreationException中:创建名为'placesSearchController'的bean时出错:注入自动装配依赖项失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:无法自动装入字段:com.onmobile.carpooldb.db.CarpoolService com.onmobile.carpool.controller.PlacesSearchController.carpoolService;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名为'carpoolService'的bean时出错:注入自动装配依赖失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:无法自动装入字段:private com.onmobile.carpooldb.db.CarpoolDao com.onmobile.carpooldb.db.CarpoolServiceImpl.carpoolDao;嵌套的异常是org.springframework.beans.factory.BeanCreationException:在类路径资源[carpool-application-context.xml]中定义名称为'carpoolDaoImpl'的bean时出错:无法在设置bean属性'sessionFactory时解析对bean'sessionFactory'的引用;嵌套的异常是org.springframework.beans.factory.BeanCreationException:在类路径资源[carpool-application-context.xml]中定义名称为'sessionFactory'的bean时出错:init方法的调用失败;嵌套异常是java.lang.NoClassDefFoundError:java.net.InetAddress是一个受限制的类。有关更多详细信息,请参阅Google App Engine开发人员指南。:
java.lang.NoClassDefFoundError:java.net.InetAddress是一个受限制的类。有关更多详细信息,请参阅Google App Engine开发人员指南。
at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
at org.hibernate.id.AbstractUUIDGenerator。< clinit>(AbstractUUIDGenerator.java :22)
...... at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:697)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation .AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:283)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1064)
.....
at org.springframework.beans.factory.support.Defau ltListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:697)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
at org.springframework.beans.factory。在org.springframework.beans.factory中,
在org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:283)上
。 support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1064)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
..... at com.google .appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:89)
服务器运行在http:// localhost:8888 /
为什么我得到
1. java.lang.NoClassDefFoundError:java.io.FileOutputStream是一个受限制的类。
我不写任何文件
- GAE不支持少数API,我知道,但我的应用程序已经为MySQL工作,我想支持两者。我的意思是基于属性文件中设置的属性,我想在某些时候使用MySQL,有时想用GAE数据存储。 使用spring 3.
- GAE doesn't support few API that I am aware of but my application already working for MySQL and I want to support both. I mean based on property set in my property file I want to use sometime MySQL and sometime want to work with GAE datastore.
在这种情况下我应该做什么?
< property name =hibernateProperties >
<道具>
< prop key =hibernate.dialect><! - 根据底层数据库的类型使用hibernate的方言 - >
org.hibernate.dialect.MySQLDialect
< / prop>
< prop key =hibernate.show_sql> false< / prop>
< /道具>
< / property>
如果您正在使用依赖于Hibernate的现有代码库,则可以尝试配置Hibernate来运行由Cloud SQL支持:
Project Name: CarpoolDB, I have added the jar for this project in another application name Carpool.While running the Carpool app I am getting following exception.
Project: Carpool.Here i am getting exception as "carpoolService" not getting autowired while running as "Google Web application" but same runs under Tomcat and beans properly get injected.
@Controller
public class PlacesSearchController {
@Autowired
CarpoolService carpoolService=null;
public CarpoolService getCarpoolService() {
return carpoolService;
}
public void setCarpoolService(CarpoolService carpoolService) {
this.carpoolService = carpoolService;
}
}
carpool-application-context1.xml
Also I have applicationContext-security.xml, for spring security.
Project: CarpoolDBAll class are in package, com.company.carpooldb.db
public interface CarpoolService {
public boolean validateUser(User user);
}
@Service("carpoolService")
public class CarpoolServiceImpl implements CarpoolService{
@Autowired
private CarpoolDao carpoolDao=null;
public CarpoolDao getCarpoolDao() {
return carpoolDao;
}
public void setCarpoolDao(CarpoolDao carpoolDao) {
this.carpoolDao = carpoolDao;
}
@Override
public boolean validateUser(User user) {
return carpoolDao.validateUser(user);;
}
}
public interface CarpoolDao {
public boolean validateUser(User user);
}
public class CarpoolDaoImpl extends HibernateDaoSupport implements CarpoolDao{
@Override
public boolean validateUser(User user) {
// TODO Auto-generated method stub
return false;
}
}
carpool-application-context.xml
<context:annotation-config />
<context:component-scan base-package="com.onmobile" />
<context:property-placeholder location="classpath:server.properties" />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>com\company\carpooldb\hbm\User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect"><!--Which dialect is used of hibernate according to type of underlying database-->
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
<property name="dataSource"><ref bean="dataSource"/></property>
</bean>
<beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<beans:property name="driverClassName"><beans:value>${cm.db.driverClassName}</beans:value></beans:property>
<beans:property name="url"><beans:value>${cm.db.url}</beans:value></beans:property>
<beans:property name="username"><beans:value>${cm.db.username}</beans:value></beans:property>
<beans:property name="password"><beans:value>${cm.db.password}</beans:value></beans:property>
<beans:property name="testOnBorrow"><beans:value>true</beans:value></beans:property>
<beans:property name="testOnReturn"><beans:value>true</beans:value></beans:property>
<beans:property name="validationQuery"><beans:value>select 1</beans:value></beans:property>
</beans:bean>
<!--Hibernate's transaction manager used for handling database transactions/manipulating data happening-->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager" >
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="carpoolDaoImpl" class="com.company.carpooldb.db.CarpoolDaoImpl">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
While running the application, I am getting exception as,
log4j:WARN Error during default initialization
java.lang.NoClassDefFoundError: java.io.FileOutputStream is a restricted class. Please see the Google App Engine developer's guide for more details.
at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:290)
.........
at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:162)
at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48)
at com.google.appengine.tools.development.DevAppServerMain.<init>(DevAppServerMain.java:113)
at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:89)
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
11 Nov, 2012 5:14:18 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: Failed startup of context com.google.apphosting.utils.jetty.DevAppEngineWebAppContext@5e55ab{/,D:\EclipseEuropa\CarpoolingGAE\war}
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'placesSearchController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.onmobile.carpooldb.db.CarpoolService com.onmobile.carpool.controller.PlacesSearchController.carpoolService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'carpoolService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.onmobile.carpooldb.db.CarpoolDao com.onmobile.carpooldb.db.CarpoolServiceImpl.carpoolDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'carpoolDaoImpl' defined in class path resource [carpool-application-context.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [carpool-application-context.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: java.net.InetAddress is a restricted class. Please see the Google App Engine developer's guide for more details.
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1064)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
.........
at com.google.appengine.tools.development.DevAppServerMain.<init>(DevAppServerMain.java:113)
at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:89)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.onmobile.carpooldb.db.CarpoolService com.onmobile.carpool.controller.PlacesSearchController.carpoolService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'carpoolService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.onmobile.carpooldb.db.CarpoolDao com.onmobile.carpooldb.db.CarpoolServiceImpl.carpoolDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'carpoolDaoImpl' defined in class path resource [carpool-application-context.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [carpool-application-context.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: java.net.InetAddress is a restricted class. Please see the Google App Engine developer's guide for more details.
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:507)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:283)
... 31 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'carpoolService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.onmobile.carpooldb.db.CarpoolDao com.onmobile.carpooldb.db.CarpoolServiceImpl.carpoolDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'carpoolDaoImpl' defined in class path resource [carpool-application-context.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [carpool-application-context.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: java.net.InetAddress is a restricted class. Please see the Google App Engine developer's guide for more details.
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1064)
.... at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:780)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:697)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
... 33 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.onmobile.carpooldb.db.CarpoolDao com.onmobile.carpooldb.db.CarpoolServiceImpl.carpoolDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'carpoolDaoImpl' defined in class path resource [carpool-application-context.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [carpool-application-context.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: java.net.InetAddress is a restricted class. Please see the Google App Engine developer's guide for more details.
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:507)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:283)
... 44 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'carpoolDaoImpl' defined in class path resource [carpool-application-context.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [carpool-application-context.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: java.net.InetAddress is a restricted class. Please see the Google App Engine developer's guide for more details.
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
.... at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:697)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
... 46 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [carpool-application-context.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: java.net.InetAddress is a restricted class. Please see the Google App Engine developer's guide for more details.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1412)
.... at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 59 more
Caused by: java.lang.NoClassDefFoundError: java.net.InetAddress is a restricted class. Please see the Google App Engine developer's guide for more details.
at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
.... at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1457)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
... 66 more
11 Nov, 2012 5:14:18 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'placesSearchController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.onmobile.carpooldb.db.CarpoolService com.onmobile.carpool.controller.PlacesSearchController.carpoolService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'carpoolService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.onmobile.carpooldb.db.CarpoolDao com.onmobile.carpooldb.db.CarpoolServiceImpl.carpoolDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'carpoolDaoImpl' defined in class path resource [carpool-application-context.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [carpool-application-context.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: java.net.InetAddress is a restricted class. Please see the Google App Engine developer's guide for more details.:
java.lang.NoClassDefFoundError: java.net.InetAddress is a restricted class. Please see the Google App Engine developer's guide for more details.
at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
at org.hibernate.id.AbstractUUIDGenerator.<clinit>(AbstractUUIDGenerator.java:22)
......at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:697)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:283)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1064)
.....
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:697)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:283)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1064)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
..... at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:89)
The server is running at http://localhost:8888/
Why I am getting as1. java.lang.NoClassDefFoundError: java.io.FileOutputStream is a restricted class.
I am not writing anything on file
I am using spring 3.
What I should do in this case?
As Boris notes, the issue appears to be with your session factory. GAE doesn't support jdbc, and it looks like your sessionFactory is configured for mysql:
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect"><!--Which dialect is used of hibernate according to type of underlying database-->
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
If you're working with an existing codebase that depends on Hibernate, you could try configuring Hibernate to run backed by Cloud SQL: https://developers.google.com/appengine/articles/using_hibernate
As for the FileOutputStream issue, I believe one of the default appenders for log4j is a FileAppender, so simply not configuring log4j won't fix it - you'll need to explicitly configure it. See if this page helps: http://blog.xam.de/2010/03/logging-in-google-appengine-for-java.html
这篇关于Spring,Hibernate与谷歌应用程序引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!