eclipse中SSH加载就出错了,求大神帮忙
信息: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [138] milliseconds.2013-12-19 19:50:46 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: validateJarFile(D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\Spring\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
2013-12-19 19:50:50 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
19:50:52,083 ERROR ContextLoader:215 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'addAction': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.tit.service.iface.IUserInfoService com.tit.action.AddAction.userInfoService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userInfoService': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.tit.dao.iface.IUserInfoDao com.tit.service.impl.UserInfoService.userInfoDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userInfoDao' defined in file [D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\Spring\WEB-INF\classes\com\tit\dao\impl\UserInfoDao.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
--------------------编程问答-------------------- 'sessionFactory' 或者 'hibernateTemplate' 配了没 --------------------编程问答-------------------- 配置了。但是还是不行a --------------------编程问答-------------------- <!-- 这表示spring将会在com.tit包下查找声明了@Component的类,
并注册为spring bean,同时还会检查bean中声明了@Autowired的属性,并自动注入该属性属性值 -->
<context:component-scan base-package="com.tit"/>
<!-- 配置数据源 -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<!-- 注入驱动 -->
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<!-- 注入URL -->
<property name="url">
<value>jdbc:oracle:thin:@localhost:1521:NIIT</value>
</property>
<!-- 注入用户名 -->
<property name="username">
<value>system</value>
</property>
<!-- 注入密码 -->
<property name="password">
<value>tit</value>
</property>
</bean>
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!--使用基于注解方式配置事务 -->
<tx:annotation-driven transaction-manager="txManager"/>
<!-- 配置sessionFactory,整合hibernate-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 注入数据源-->
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<!-- 配置hibernate属性 -->
<property name="hibernateProperties">
<props>
<!-- 方言 -->
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
<!-- 配置二级缓存插件 -->
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<!-- 显示SQL语句 -->
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<!-- 配置实体映射文件 -->
<property name="mappingResources">
<list>
<value>com/tit/pojo/UserInfo.hbm.xml</value>
<value>com/tit/pojo/Email.hbm.xml</value>
</list>
</property>
</bean>
<bean id="baseDao" class="com.tit.dao.impl.BaseDao">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean> --------------------编程问答-------------------- 这是我写的applicationContext.xml --------------------编程问答-------------------- 错误提示你userInfoDao没有自动创建bean,你是用的注解还是写在配置文件里的,配置文件没看到啊 --------------------编程问答-------------------- web.xml的配置信息贴出来 --------------------编程问答-------------------- 你用到注解了没?
你的sessionFactory的类错了。
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
改为:
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
试试 --------------------编程问答-------------------- 用的注解,后来不行,现在有写成bean了 --------------------编程问答-------------------- <?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- 指定spring的配置文件,默认从web根目录寻找配置文件,我们可以通过spring提供的classpath:前缀指定从类路径下寻找 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- 对Spring容器进行实例化 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- struts2框架启动配置代码 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>struts.xml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
这是web.xml --------------------编程问答-------------------- 那个问题改回applicationContext.xml中的bean就不是这个错误了
是下面这错误
com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=com.opensymphony.xwork2.util.reflection.ReflectionProvider, name='default'] in public void com.opensymphony.xwork2.ObjectFactory.setReflectionProvider(com.opensymphony.xwork2.util.reflection.ReflectionProvider).
at com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMembers(ContainerImpl.java:144)
at com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMethods(ContainerImpl.java:113)
at com.opensymphony.xwork2.inject.ContainerImpl.addInjectors(ContainerImpl.java:90)
at com.opensymphony.xwork2.inject.ContainerImpl.addInjectors(ContainerImpl.java:86)
at com.opensymphony.xwork2.inject.ContainerImpl.addInjectors(ContainerImpl.java:86)
at com.opensymphony.xwork2.inject.ContainerImpl$1.create(ContainerImpl.java:71)
at com.opensymphony.xwork2.inject.ContainerImpl$1.create(ContainerImpl.java:67)
at com.opensymphony.xwork2.inject.util.ReferenceCache$CallableCreate.call(ReferenceCache.java:150)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at com.opensymphony.xwork2.inject.util.ReferenceCache.internalCreate(ReferenceCache.java:76)
。。。。
Caused by: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=com.opensymphony.xwork2.util.reflection.ReflectionProvider, name='default'] in public void com.opensymphony.xwork2.ObjectFactory.setReflectionProvider(com.opensymphony.xwork2.util.reflection.ReflectionProvider).
at com.opensymphony.xwork2.inject.ContainerImpl.createParameterInjector(ContainerImpl.java:235)
at com.opensymphony.xwork2.inject.ContainerImpl.getParametersInjectors(ContainerImpl.java:225)
at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.<init>(ContainerImpl.java:287)
at com.opensymphony.xwork2.inject.ContainerImpl$3.create(ContainerImpl.java:117)
at com.opensymphony.xwork2.inject.ContainerImpl$3.create(ContainerImpl.java:114)
at com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMembers(ContainerImpl.java:141)
... 46 more --------------------编程问答-------------------- 如果要用注解。。你把你的那个配置信息改为:我上面说的试试。。你的sessionFactory对应的类错了。。你试试
补充:Java , Web 开发