SSH 项目图标上有红叉 文件没错 一开始能运行 突然就就不行了
Struts2+Spring3+Hibernate3 整合数据库:SQL Server2005 服务器:apache-tomcat-8.0.0-RC1 开发环境:Myeclipse8.5
一开始项目是能运行的 然后也没改过什么东西 项目图标上就有个红叉 不能启动 。
以下是控制台的出错信息:
十月 23, 2013 7:26:13 下午 org.apache.catalina.core.AprLifecycleListener init
信息: Loaded APR based Apache Tomcat Native library 1.1.27 using APR version 1.4.6.
十月 23, 2013 7:26:14 下午 org.apache.catalina.core.AprLifecycleListener init
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
十月 23, 2013 7:26:14 下午 org.apache.catalina.core.AprLifecycleListener initializeSSL
信息: OpenSSL successfully initialized (OpenSSL 1.0.1d 5 Feb 2013)
十月 23, 2013 7:26:15 下午 org.apache.coyote.http11.Http11AprProtocol init
信息: Initializing ProtocolHandler ["http-apr-8080"]
十月 23, 2013 7:26:15 下午 org.apache.coyote.ajp.AjpAprProtocol init
信息: Initializing ProtocolHandler ["ajp-apr-8009"]
十月 23, 2013 7:26:15 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 2896 ms
十月 23, 2013 7:26:15 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
十月 23, 2013 7:26:15 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/8.0.0-RC1
十月 23, 2013 7:26:15 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\JAVATOOlS\apache-tomcat-8.0.0-RC1\webapps\107gxwz
十月 23, 2013 7:26:20 下午 org.apache.tomcat.util.digester.Digester body
信息: TLD skipped. URI: http://www.springframework.org/tags/form is already defined
十月 23, 2013 7:26:20 下午 org.apache.tomcat.util.digester.Digester body
信息: TLD skipped. URI: http://www.springframework.org/tags is already defined
十月 23, 2013 7:26:20 下午 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/107gxwz] log
信息: Initializing Spring root WebApplicationContext
2013-10-23 19:26:21,250 | [DigtalTravel] DEBUG [localhost-startStop-1] org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(322) | Ignoring bean class loading failure for bean 'userAction'
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.gxwz.action.UserAction] for bean with name 'userAction' defined in class path resource [spring_struts.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/apache/struts2/interceptor/RequestAware
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:570)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1277)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:382)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:582)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:405)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5288)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:698)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1119)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1760)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.NoClassDefFoundError: org/apache/struts2/interceptor/RequestAware
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2627)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:989)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1432)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1310)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:408)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1229)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1200)
... 22 more
Caused by: java.lang.ClassNotFoundException: org.apache.struts2.interceptor.RequestAware
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1465)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1310)
... 33 more
2013-10-23 19:26:21,250 | [DigtalTravel] DEBUG [localhost-startStop-1] org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(322) | Ignoring bean class loading failure for bean 'userAction'
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.gxwz.action.UserAction] for bean with name 'userAction' defined in class path resource [spring_struts.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/apache/struts2/interceptor/RequestAware
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:570)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1277)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:303)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:594)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:405)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5288)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:698)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1119)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1760)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.NoClassDefFoundError: org/apache/struts2/interceptor/RequestAware
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2627)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:989)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1432)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1310)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:408)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1229)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1200)
... 21 more
Caused by: java.lang.ClassNotFoundException: org.apache.struts2.interceptor.RequestAware
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1465)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1310)
... 32 more ssh 控制台 myeclipse 服务器 hibernate --------------------编程问答-------------------- --------------------------------------------------------------------------------
相关配置文件如下:
我用了Myeclipse hibernate逆向工程生成映射文件
GxUser.hbm.xml
<hibernate-mapping>
<class name="com.gxwz.entity.GxUser" table="gx_user" schema="dbo" catalog="107gxwz">
<id name="uid" type="java.lang.Integer">
<column name="UId" />
<generator class="native"></generator>
</id>
<property name="uname" type="java.lang.String">
<column name="UName" length="20" not-null="true" />
</property>
<property name="upwd" type="java.lang.String">
<column name="UPwd" length="20" not-null="true" />
</property>
<property name="ugender" type="java.lang.String">
<column name="UGender" length="4" not-null="true" />
</property>
<property name="uemal" type="java.lang.String">
<column name="UEmal" length="50" not-null="true" />
</property>
<property name="urole" type="java.lang.Integer">
<column name="URole" not-null="true" />
</property>
<property name="uhead" type="java.lang.String">
<column name="UHead" length="50" />
</property>
<property name="uregDate" type="java.sql.Timestamp">
<column name="URegDate" length="23" />
</property>
<property name="ulastLogin" type="java.sql.Timestamp">
<column name="ULastLogin" length="23" />
</property>
<property name="ulastEmit" type="java.sql.Timestamp">
<column name="ULastEmit" length="23" />
</property>
<property name="upermit" type="java.lang.Integer">
<column name="UPermit" />
</property>
<property name="umobile" type="java.lang.String">
<column name="UMobile" length="20" />
</property>
<property name="uuploadFilesIds" type="java.lang.String">
<column name="UUploadFilesIDs" length="200" />
</property>
<property name="udownLoadFileIds" type="java.lang.String">
<column name="UDownLoadFileIDs" length="200" />
</property>
<property name="uurl" type="java.lang.String">
<column name="UUrl" length="50" />
</property>
<property name="utopicIds" type="java.lang.String">
<column name="UTopicIDs" length="500" />
</property>
<property name="urevertIds" type="java.lang.String">
<column name="URevertIDs" length="500" />
</property>
</class>
</hibernate-mapping>
--------------------------------------------------------------------------------
Hibernate 配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<!-- hibernate配置开始 -->
<beans>
<!-- 数据源注入session工厂 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/gxwz/entity/GxUser.hbm.xml</value>
</list>
</property>
</bean>
<!-- 配置数据库连接池开始-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver">
</property>
<property name="url"
value="jdbc:sqlserver://localhost:1433;DatabaseName=107gxwz">
</property>
<property name="username" value="sa"></property>
<property name="password" value="root"></property>
</bean>
<!-- 配置数据库连接池结束-->
<!-- 声明事物管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="jdbcExceptionTranslator"
class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
<property name="jdbcExceptionTranslator" ref="jdbcExceptionTranslator" />
</bean>
</beans>
跪求指点一二。。。。。
备注:exception is java.lang.NoClassDefFoundError: org/apache/struts2/interceptor/RequestAware是可以在jar包中找到的 --------------------编程问答-------------------- 只要能运行,那么就clean一下工程,然后重新跑。。。
NoClassDefFoundError问题的出现并不一定是没有导包,还有可能是包冲突。。 --------------------编程问答-------------------- 你的冲突包删掉没有? --------------------编程问答-------------------- 把spring的配置文件贴下。。 --------------------编程问答-------------------- 重新发布运行一下。。 --------------------编程问答-------------------- 把所有jar包移除, 从新构建一下项目,然后重新发布运行看看。 --------------------编程问答-------------------- 肯定有不需要的包在里面构成冲突。如图
找出不需要的或者带有警告标志的 --------------------编程问答-------------------- 是的 项目红叉是因为里面多了一个mysql-connector的jar包! 删除后就没有!
再次运行出现了这个问题
Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;)V
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:265)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5288)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.c
ore.ContainerBase.addChildInternal(ContainerBase.java:726)
这个问题在网上查后说是因为读取了spring2.0而不是我项目中的3.0.1 也就是有重复的包。但是我找不到哪些才算是呢! 我把我的包截图如下,希望大家帮我看一下那些是不需要的! --------------------编程问答-------------------- 谢谢各位的回答 已经解决 原因是引进struts2里的spring包出现了问题。删除后即可!
如下图:
也即是多了这些包:
--------------------编程问答-------------------- 已经有maven了
你的包管理得还这么乱 --------------------编程问答-------------------- 1] org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(322) | Ignoring bean class loading failure for bean 'userAction'
这个'userAction' 类没有加载成功 是不是没有编译成功? --------------------编程问答-------------------- 你的Jar包antlr-2.7.2.jar与antlr2.7.6.jar冲突了,删掉antlr2.7.2.jar就可以了,在lib下配置个antlr2.7.6.rar的rar包。 --------------------编程问答--------------------
新手 maven 还没熟悉过! 以后慢慢改进! --------------------编程问答--------------------
感谢 这个问题暂时没出现那问题,不过有肯那个是一个潜伏的炸弹! 去修正一下! --------------------编程问答--------------------
真是因为有多余的包 删除后就OK了 --------------------编程问答-------------------- 切换一下你的jre版本就行了. 可以切一个版本. 确定后再切回来.
补充:Java , Java EE