`
nicholas_csj
  • 浏览: 3715 次
  • 性别: Icon_minigender_1
  • 来自: 福州
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

Struts+Hibernate+Spring出现Servlet action is not available错误

阅读更多
我用的是MyEclipse5.1+Tomcat5.0.28+JDK5.0

然后在Tomcat的logs中提示以下这些信息:
2007-09-18 17:00:27 StandardContext[/ssh]Initializing WebApplicationContext for Struts ActionServlet 'action', module ''
2007-09-18 17:00:28 StandardContext[/ssh]action: null
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass
java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)......


在http://localhost:8080/ssh/person.do页面下提示以下信息:
HTTP Status 404 - Servlet action is not available
--------------------------------------------------------------------------------
[b]type[/b] Status report

[b]message[/b] Servlet action is not available

[b]description[/b] The requested resource (Servlet action is not available) is not available.


这是web.xml的配置:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>3</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>3</param-value>
    </init-param>
    <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
</web-app>


这是applicationContext.xml的配置:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>


	<bean id="dataSource"
		class="org.apache.commons.dbcp.BasicDataSource">
		<property name="driverClassName">
			<value>com.mysql.jdbc.Driver</value>
		</property>
		<property name="url">
			<value>jdbc:mysql://localhost:3306/ssh</value>
		</property>
		<property name="username">
			<value>root</value>
		</property>
		<property name="password">
			<value>123456</value>
		</property>
	</bean>
	<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.MySQLDialect
				</prop>
			</props>
		</property>
		<property name="mappingResources">
			<list>
				<value>org/csj/vo/Person.hbm.xml</value></list>
		</property></bean>
	<bean id="personDAO" class="org.csj.dao.PersonDAO">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean id="personService" class="org.csj.service.PersonService"
		abstract="false" singleton="true" lazy-init="default"
		autowire="default" dependency-check="default">
		<property name="personDAO">
			<ref local="personDAO" />
		</property>
	</bean>
	<bean name="/person" class="org.csj.struts.action.PersonAction"
		abstract="false" singleton="false" lazy-init="default"
		autowire="default" dependency-check="default">
		<property name="personService">
			<ref local="personService" />
		</property>
	</bean></beans>


这是struts-cofig.xml的配置:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>
  <data-sources />
  <form-beans >
    <form-bean name="personForm" type="org.csj.struts.form.PersonForm" />

  </form-beans>

  <global-exceptions />
  <global-forwards />
  <action-mappings >
    <action
      attribute="personForm"
      input="/index.jsp"
      name="personForm"
      path="/person"
      scope="request">
	  <forward name="success" path="/success.jsp" />
	  <forward name="failure" path="/index.jsp" />
	  </action>

  </action-mappings>

  <controller>
    <set-property property="processorClass" value="org.springframework.web.struts.DelegatingRequestProcessor" />
  </controller>
  <message-resources parameter="org.csj.struts.ApplicationResources" />
  <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
    <set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml" />
  </plug-in>
</struts-config>


这是我的index.jsp页面(登录页面):

<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%> 
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
 
<html> 
	<head>
		<title>JSP for PersonForm form</title>
	</head>
	<body>
		<html:form action="/person">
			username : <html:text property="username"/><html:errors property="username"/><br/>
			password : <html:password property="password"/><html:errors property="password"/><br/>
			password2 : <html:password property="password2"/><html:errors property="password2"/><br/>
            email : <html:text property="email"/><html:errors property="email"/><br/>
			<html:submit/><html:cancel/>
		</html:form>
	</body>
</html>


----------------------------------------------------------------------------
但一登录就是提示:

HTTP Status 404 - Servlet action is not available

--------------------------------------------------------------------------------

[b]type[/b] Status report

[b]message[/b] Servlet action is not available

[b]description[/b] The requested resource (Servlet action is not available) is not available.


在baidu、google找了很多还是没能解决,请解决一下。
我是跟着视频教程做的,跟视频里的代码一样,但就是不行。

然后我把视频里附带的源代码来运行也是提示同样的错误。请下,我确实找不到错误在哪。
分享到:
评论
4 楼 nicholas_csj 2007-09-28  
那个包名叫hibernate-annotations.jar,
我也不懂是怎么回事,可能是包间的冲突吧,直接在Eclipse里删掉,
马上就不会出错了。
3 楼 jiphoenixsoft 2007-09-20  
请问楼上的老兄,是怎么删除Hibernate-*.jar的,怎样在Eclipse(MyEclipse)中删除的,jar包的名字就是Hibernate-*.jar吗,我用的是MyEclipse5.5GA,也出现与你同样的问题,可我找遍了所有的jar包,就是找不到Hibernate-*.jar这个包,能否将解决办法再说的详细一些好吗?谢谢!下面将我的程序附上,请多多指教!
2 楼 nicholas_csj 2007-09-19  
问题已解决了,是jar包中间的冲突,
我删了一个hibernate-*.jar包问题不再出现了。
1 楼 java虫 2007-09-19  
java.lang.NoClassDefFoundError

错误不是很明显吗?看看你的jar包有没有问题。

相关推荐

Global site tag (gtag.js) - Google Analytics