aspose file tools*
The moose likes Other Application Frameworks and the fly likes struts-spring-hibernate integration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "struts-spring-hibernate integration" Watch "struts-spring-hibernate integration" New topic
Author

struts-spring-hibernate integration

subha nair
Greenhorn

Joined: Jun 19, 2008
Posts: 23
I am doing struts in the web tier, springs and hibernate.

applicationContext.xml
========================

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/shop</value>
</property>
<property name="username">
<value>palnar</value>
</property>
<property name="password">
<value>palnar</value>
</property>
</bean>

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>

<property name="annotatedClasses">
<list>
<value>com.palnar.shop.form.Login</value>

</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
<prop key="connection.pool_size">1</prop>
<prop key="current_session_context_class">thread</prop>
<prop key="cache.provider_class">
org.hibernate.cache.NoCacheProvider
</prop>
<prop key="show_sql">true</prop>
</props>
</property>
</bean>

<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>

<bean id="LoginDAO"
class="com.palnar.shop.dao.LoginDAOImpl">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>

<aop:config></aop:config>
</beans>


web.xml
==========
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Shop</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>


<servlet>
<servlet-name>context</servlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!--<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/shop-servlet.xml</param-value>
</context-param>
-->

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<!-- <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/shop-servlet.xml</param-value>
</context-param>
-->

<servlet>
<!-- Standard Action Servlet Configuration (with debugging) -->
<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>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<!-- Standard Action Servlet Mapping -->
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<jsp-config>
<taglib>
<taglib-uri>/tags/struts-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/tags/struts-logic</taglib-uri>
<taglib-location>
/WEB-INF/tld/struts-logic.tld
</taglib-location>
</taglib>
</jsp-config>
</web-app>

struts-cnfig.xml
===================
<?xml version="1.0" encoding="UTF-8"?>
<struts-config>



<form-beans>
<form-bean name="login" type="com.palnar.shop.form.Login" />
</form-beans>

<action-mappings>
<action path="/Login"
type="org.springframework.web.struts.DelegatingActionProxy"
name="login">
<forward name="success" path="/success.jsp" />
<forward name="failure" path="/index.jsp" />
</action>
</action-mappings>

<!-- <controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"/> -->

<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/applicationContext.xml,/WEB-INF/shop-servlet.xml" />
</plug-in>


</struts-config>


===============================================================
when I run this application, I am getting the error..
servlet action not available..

please tell me a solution
thanks......
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Not a solution, sorry, but there is a CODE button below the Add Reply button that will add CODE tags to you post, which you can post your xml within those tags and it will keep its indentation and make it so much easier to read.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts-spring-hibernate integration