JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java Tools  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 struts,spring,hibernate报错!急救!!
zhourui_kavka





發文: 3
積分: 0
於 2005-02-26 16:00 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我的程序用了:
- Struts for the web context
- Spring for the bussiness contex
- Spring + Hiberante for the data access context

在WEB。XML中
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/applicationContext-hibernate.xml </param-value>
</context-param>
<servlet>
  <servlet-name>context</servlet-name>
  <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
</web-app>

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

<!--
- Application context definition for Petclinic on Hibernate.
  -->
<beans>

  <!-- ========================= GENERAL DEFINITIONS ========================= -->

  <!-- Configurer that replaces ${...} placeholders with values from a properties file -->
  <!-- (in this case, JDBC-related settings for the dataSource definition below) -->

  <!-- Message source for this context, loaded from localized "messages_xx" files -->
  <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basename"><value>messages</value></property>
  </bean>

  <!-- ========================= RESOURCE DEFINITIONS ========================= -->

  <!-- Local DataSource that works in any environment -->
  <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName"><value>net.sourceforge.jtds.jdbc.Driver</value></property>
    <property name="url"><value>jdbc:jtds:sqlserver://127.0.0.1:1433/tempdb;charset=gb2312</value></property>
    <property name="username"><value>sa</value></property>
    <property name="password"><value>sa</value></property>
  </bean>

  <!-- Hibernate SessionFactory -->
  <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    <property name="dataSource"><ref local="dataSource"/></property>
    <property name="mappingResources">
      <list>
      <value>teststrutsweb/po/Student.hbm.xml</value>
      </list>
    </property>
    <property name="hibernateProperties">
      <props>
        <prop key="hibernate.dialect">${hibernate.dialect}</prop>
        <prop key="hibernate.show_sql">true</prop>
        <prop key="hibernate.query.substitutions">true 't',false 'f'</prop>
      </props>
    </property>
  </bean>

  <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
  <bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
    <property name="sessionFactory"><ref local="sessionFactory"/></property>
  </bean>

  <!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) -->

  <!--
  <bean id="transactionManager_1" class="org.springframework.transaction.jta.JtaTransactionManager" />
  -->
  <bean id="DaoTest1" class="dao.DaoHTest1">
    <property name="sessionFactory"><ref bean="sessionFactory"/></property>
  </bean>

  <bean id="DomainTarget" class="domain.DomainTest1">
    <property name="daoTest1"><ref bean="DaoTest1"/></property>
</bean>

<bean id="DomainControllTest1" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref local="transactionManager"/></property>
<property name="target"><ref local="DomainTarget"/></property>
<property name="transactionAttributes">
<props>
<prop key="add*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
</beans>

运行时报错:
No WebApplicationContext found: no ContextLoaderListener registered?
  at org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:45)
  at action.ActionTest1.setServlet(ActionTest1.java:38)
  at org.apache.struts.action.RequestProcessor.processActionCreate(RequestProcessor.java:341)
  at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:268)
  at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
  at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
....

望各位高手点拨啊!

给出个大概的错误可能也好!


reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
1676 struts,spring,hibernate报错!急救!! zhourui_kavka 6254 2005-02-26 16:00
1225 Re:struts,spring,hibernate报错!急救!! zhourui_kavka 88 2005-02-26 17:30
1380 Re:struts,spring,hibernate报错!急救!! browser 432 2005-02-26 23:04
1307 Re:struts,spring,hibernate报错!急救!! try 233 2005-02-26 23:00
» JWorld@TW »  Java Tools

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8