struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Srineel Mazumdar <smaz19...@gmail.com>
Subject Re: Issue with running Struts2 project
Date Tue, 06 Nov 2012 13:30:03 GMT
Hi,

Changed as per your suggestion. Also changed package name in struts.xml to
shop since my package structure is like

Also , the home page is coming only in Glassfish but not in Tomcat. (gives
404 error.)

[image: Inline image 1]

*applicationContext.xml :*
*
*
<?xml version="1.0" encoding="UTF-8"?>

<!-- - Application context definition for JPetStore's business layer. -
Contains
bean references to the transaction manager and to the DAOs in -
dataAccessContext-local/jta.xml
(see web.xml's "contextConfigLocation"). -->
<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.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">


<bean id="addItemToCartAction"
class="com.home.practice.shop.AddItemToCartAction" scope = "prototype">
<property name="workingItemId" value="" />
<property name="cart" ref="domain.cart" />
</bean>

<!-- <bean id="baseAction" class="com.home.practice.shop.BaseAction" /> -->

<bean id="doNothingAction" class="com.home.practice.shop.DoNothingAction"
scope = "prototype"/>

<bean id="editAccountAction"
class="com.home.practice.shop.EditAccountAction" scope = "prototype">
<property name="username" value="" />
<property name="password" value="" />
<property name="repeatedPassword" value="" />
<property name="languages">
<list>
<value>enlish</value>
<value>japanese</value>
</list>
</property>
<property name="categories">
<list></list>
</property>
<property name="validate" value="" />
<property name="forwardAction" value="" />
<property name="account" ref="domain.account" />
<property name="myList" ref = "myPageList" />
</bean>

<bean id="editAccountFormAction"
class="com.home.practice.shop.EditAccountFormAction" scope = "prototype"/>
 <bean id="listOrdersAction"
class="com.home.practice.shop.ListOrdersAction" scope = "prototype"/>
 <bean id="newAccountAction"
class="com.home.practice.shop.NewAccountAction" scope = "prototype"/>

 <bean id="newOrderAction" class="com.home.practice.shop.NewOrderAction"
scope = "prototype">
<property name="order" ref="domain.order" />
<property name="shippingAddressRequired" value="false" />
<property name="confirmed" value="false" />
<property name="cardTypeList">
<list>
<value>Visa</value>
<value>MasterCard</value>
<value>American Express</value>
</list>
</property>
</bean>


<bean id="newOrderFormAction"
class="com.home.practice.shop.NewOrderFormAction" scope = "prototype">
<property name="order" ref="domain.order" />
<property name="shippingAddressRequired" value="false" />
<property name="confirmed" value="false" />
<property name="cardTypeList">
<list>
<value>Visa</value>
<value>MasterCard</value>
<value>American Express</value>
</list>
</property>
</bean>
 <bean id="removeItemFromCartAction"
class="com.home.practice.shop.RemoveItemFromCartAction" scope = "prototype">
<property name="workingItemId" value="" />
<property name="cart" ref="domain.cart" />
</bean>

<bean id="searchProductsAction"
class="com.home.practice.shop.SearchProductsAction" scope = "prototype"/>


<bean id="signonAction" class="com.home.practice.shop.SignonAction" scope =
"prototype">
<property name="username" value="" />
<property name="password" value="" />
<property name="repeatedPassword" value="" />
<property name="languages">
<list>
<value>enlish</value>
<value>japanese</value>
</list>
</property>
<property name="categories">
<list></list>
</property>
<property name="validate" value="" />
<property name="forwardAction" value="" />
<property name="account" ref="domain.account" />
<property name="myList" ref = "myPageList" />
</bean>

 <bean id="updateCartQuantitiesAction"
class="com.home.practice.shop.UpdateCartQuantitiesAction" scope =
"prototype">
<property name="workingItemId" value="" />
<property name="cart" ref="domain.cart" />
</bean>


<bean id="viewCartAction" class="com.home.practice.shop.ViewCartAction"
scope = "prototype">
<property name="workingItemId" value="" />
<property name="cart" ref="domain.cart" />
</bean>


<bean id="viewCategoryAction"
class="com.home.practice.shop.ViewCategoryAction" scope = "prototype"/>

<bean id="viewItemAction" class="com.home.practice.shop.ViewItemAction"
scope = "prototype" />

<bean id="viewOrderAction" class="com.home.practice.shop.ViewOrderAction"
scope = "prototype">
<property name="username" value="" />
<property name="password" value="" />

<property name="repeatedPassword" value="" />

<property name="languages">
<list>
<value>enlish</value>
<value>japanese</value>
</list>
</property>
<property name="categories">
<list></list>
</property>
<property name="validate" value="" />

<property name="forwardAction" value="" />

<property name="account" ref="domain.account" />

<property name="myList"
ref = "myPageList" />
</bean>


<bean id="viewProductAction"
class="com.home.practice.shop.ViewProductAction" scope = "prototype"/>
 <bean id="domain.account" class="com.home.practice.shop.domain.Account"
scope = "prototype"/>
<bean id="domain.cart" class="com.home.practice.shop.domain.Cart" scope =
"prototype"/>
<bean id="domain.cartItem" class="com.home.practice.shop.domain.CartItem"
scope = "prototype"/>
<bean id="domain.category" class="com.home.practice.shop.domain.Category"
scope = "prototype"/>
<bean id="domain.item" class="com.home.practice.shop.domain.Item" scope =
"prototype"/>
<bean id="domain.lineItem" class="com.home.practice.shop.domain.LineItem"
scope = "prototype"/>
<bean id="domain.order" class="com.home.practice.shop.domain.Order" scope =
"prototype"/>
<bean id="domain.product" class="com.home.practice.shop.domain.Product"
scope = "prototype"/>
<bean id="myPageList" class =
"org.springframework.beans.support.PagedListHolder" scope = "prototype"/>


</beans>

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

<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

<constant name="struts.action.extension" value="action" />
<constant name="struts.devMode" value="true" />
<package name="shop" extends="struts-default" namespace="/shop">


<global-results>
<result name="failure">/WEB-INF/jsp/struts/Error.jsp</result>
<result name="unknown-error">/WEB-INF/jsp/struts/Error.jsp</result>
<result name="global-signon">/WEB-INF/jsp/struts/SignonForm.jsp</result>
</global-results>


<action name="addItemToCart" class="addItemToCartAction">
<result name="success">/WEB-INF/jsp/struts/Cart.jsp<result />
</action>

<action name="checkout" name="viewCartAction">
<result name="success">/WEB-INF/jsp/struts/Checkout.jsp<result />
</action>


<action name="editAccount" class="editAccountAction">
<result type="redirectAction>
    <param name= "actionName">index</param>
</result>
<result name="input">/WEB-INF/jsp/struts/EditAccountForm.jsp</result>
</action>


<action name="editAccountForm" class="editAccountFormAction">
<result name="success">/WEB-INF/jsp/struts/EditAccountForm.jsp<result />
</action>

<action name="index" class="doNothingAction">
<result name="success">/WEB-INF/jsp/struts/index.jsp<result />
</action>

<action name="listOrders" class="listOrdersAction">
<result name="success">/WEB-INF/jsp/struts/ListOrders.jsp<result />
</action>

<action name="newAccount" class="editAccountAction">
<result type="redirectAction>
                <param name="actionName ">index</param>
<param name="namespace">/shop</param>
</result>
<result name="input">/WEB-INF/jsp/struts/NewAccountForm.jsp</result>
</action>


<action name="newAccountForm" class="newAccountFormAction">
<result name="success">/WEB-INF/jsp/struts/NewAccountForm.jsp<result />
</action>

<action name="newOrder" class="newOrderAction">
<result name="confirm">/WEB-INF/jsp/struts/ConfirmOrder.jsp<result />
<result name="shipping">/WEB-INF/jsp/struts/ShippingForm.jsp</result>
<result name="success">/WEB-INF/jsp/struts/ViewOrder.jsp</result>
</action>

<action name="newOrderForm" class="newOrderFormAction">
<result name="success">/WEB-INF/jsp/struts/NewOrderForm.jsp</result>
</action>

<action name="removeItemFromCart" class="removeItemFromCartAction">
<result name="success">/WEB-INF/jsp/struts/Cart.jsp</result>
</action>

<action name="searchProducts" class="searchProductsAction">
<result name="success">/WEB-INF/jsp/struts/SearchProducts.jsp</result>
</action>

<action name="signon" class="signonAction">
<result name="success">index.action</result>
</action>

<action name="signonForm" class="doNothingAction">
<result name="success">/WEB-INF/jsp/struts/SignonForm.jsp</result>
</action>

<action name="updateCartQuantities" class="updateCartQuantitiesAction">
<result name="success">/WEB-INF/jsp/struts/Cart.jsp</result>
</action>

<action name="viewCart" class="viewCartAction">
<result name="success">/WEB-INF/jsp/struts/Cart.jsp</result>
</action>

 <action name="newAccount" class="editAccountAction">
<result type="redirectAction>
    <param name="actionName ">index</param>
<param name="namespace">/shop</param>
</result>
<result name="input">/WEB-INF/jsp/struts/index.jsp</result>
</action>

<action name="viewItem" class="viewItemAction">
<result name="success">/WEB-INF/jsp/struts/Item.jsp</result>
</action>

<action name="viewOrder" class="viewOrderAction">
<result name="success">/WEB-INF/jsp/struts/ViewOrder.jsp"</result>
</action>

<action name="viewProduct" class="viewProductAction"
 <result name="success">/WEB-INF/jsp/struts/Product.jsp</result>
</action>

</struts>

*web.xml*
*
*
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="
http://java.sun.com/xml/ns/javaee" xmlns:web="
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID"
version="2.5">
  <display-name>NewPetstore</display-name>
  <!--
- Key of the system property that should specify the root directory of this
- web app. Applied by WebAppRootListener or Log4jConfigListener.
-->
<context-param>
        <param-name>org.apache.tiles.CONTAINER_FACTORY</param-name>

<param-value>org.apache.struts2.tiles.StrutsTilesContainerFactory</param-value>
    </context-param>
    <filter>
        <filter-name>struts-cleanup</filter-name>

<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
    </filter>

    <filter>
        <filter-name>struts</filter-name>

<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>


    <filter-mapping>
        <filter-name>struts-cleanup</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>



    <filter-mapping>
        <filter-name>struts</filter-name>
        <url-pattern>*.action</url-pattern>
    </filter-mapping>

<!--
- Key of the system property that should specify the root directory of this
- web app. Applied by WebAppRootListener or Log4jConfigListener.
-->
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>petstore.root</param-value>
</context-param>

<!--
- Location of the Log4J config file, for initialization and refresh checks.
- Applied by Log4jConfigListener.
-->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>

   <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

  <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>
</web-app>
*
*


On Tue, Nov 6, 2012 at 12:57 AM, Lukasz Lenart <lukaszlenart@apache.org>wrote:

> 2012/11/5 Srineel Mazumdar <smaz19584@gmail.com>
>
> > Hi,
> >
> > Also I would like to add :
> >
> > The url now I am using is
> >
> > http://localhost:8081/NewPetstore/shop/index.action.
> >
> > Now the error is coming as : *There is no Action mapped for namespace
> /shop
> > and action name index*
> > *
> > *
> > *In struts.xml : *
> > *
> > *
> > <package name="newpetstore" extends="struts-default" namespace="/shop">
> > *
> > *
> > <action name ="index" class ="com.home.practice.shop.DoNothingAction">
> > <result name="success">/WEB-INF/jsp/struts/index.jsp<result/>
> > </action>
> >
> > Seems I am making a silly mistake somewhere but I am unable to figure in
> > out. Please help.
> >
>
> Take a look on that [1] as you can see class should be named as spring id
> which is doNothingAction
>
> [1] http://struts.apache.org/2.x/docs/spring-and-struts-2.html
>
>
> Regards
> --
> Ɓukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>

Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message