You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Srineel Mazumdar <sm...@gmail.com> on 2012/11/05 07:08:10 UTC

Issue with running Struts2 project

Hi,

I am new to Struts2 and for learning I am doing my own project. I am facing
the following issue and need help in fixing:

http://localhost:8081/NewPetstore : This URL is opening the index page.

However
http://localhost:8081/NewPetstore/shop/index.do shows 404 .


PFB the

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

*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>

<package name="newpetstore" 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="org.springframework.samples.jpetstore.web.struts.AddItemToCartAction">
<result name="success">/WEB-INF/jsp/struts/Cart.jsp<result/>
</action>

<action name ="checkout" name
="org.springframework.samples.jpetstore.web.struts.ViewCartAction">
<result name="success">/WEB-INF/jsp/struts/Checkout.jsp<result/>
</action>
 <!-- Check  -->
<!-- <action name="editAccount" class
="org.springframework.samples.jpetstore.web.struts.EditAccountAction"
name="workingAccountForm" scope="session" validate="true"
input="/WEB-INF/jsp/struts/EditAccountForm.jsp">
<result name="success" name="index.do"/>
</action>
 -->
<action name="editAccount"
class="org.springframework.samples.jpetstore.web.struts.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
="org.springframework.samples.jpetstore.web.struts.EditAccountFormAction">
<result name="success">/WEB-INF/jsp/struts/EditAccountForm.jsp<result/>
</action>
 <action name ="index" class
="org.springframework.samples.jpetstore.web.struts.DoNothingAction">
<result name="success">/WEB-INF/jsp/struts/index.jsp<result/>
</action>
 <action name ="listOrders" class
="org.springframework.samples.jpetstore.web.struts.ListOrdersAction">
<result name="success">/WEB-INF/jsp/struts/ListOrders.jsp<result/>
</action>
 <!--  Check -->
<!-- <action name="newAccount"
class="org.springframework.samples.jpetstore.web.struts.NewAccountAction"
name="workingAccountForm" scope="session" validate="true"
input="/WEB-INF/jsp/struts/NewAccountForm.jsp">
<result name="success">index.do<result/>
</action> -->
 <action name="newAccount"
class="org.springframework.samples.jpetstore.web.struts.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
="org.springframework.samples.jpetstore.web.struts.NewAccountFormAction">
<result name="success">/WEB-INF/jsp/struts/NewAccountForm.jsp<result/>
</action>
 <action name ="newOrder" class
="org.springframework.samples.jpetstore.web.struts.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
="org.springframework.samples.jpetstore.web.struts.NewOrderFormAction">
<result name="success">/WEB-INF/jsp/struts/NewOrderForm.jsp</result>
</action>
 <action name="removeItemFromCart"
class="org.springframework.samples.jpetstore.web.struts.RemoveItemFromCartAction">
<result name="success">/WEB-INF/jsp/struts/Cart.jsp</result>
</action>
 <action name="searchProducts"
class="org.springframework.samples.jpetstore.web.struts.SearchProductsAction">
<result name="success">/WEB-INF/jsp/struts/SearchProducts.jsp</result>
</action>
 <action name="signon"
class="org.springframework.samples.jpetstore.web.struts.SignonAction">
<result name="success">index.do</result>
</action>
 <action name="signonForm"
class="org.springframework.samples.jpetstore.web.struts.DoNothingAction">
<result name="success">/WEB-INF/jsp/struts/SignonForm.jsp</result>
</action>
 <action name="updateCartQuantities"
class="org.springframework.samples.jpetstore.web.struts.UpdateCartQuantitiesAction">
<result name="success">/WEB-INF/jsp/struts/Cart.jsp</result>
</action>
 <action name="viewCart"
class="org.springframework.samples.jpetstore.web.struts.ViewCartAction">
<result name="success">/WEB-INF/jsp/struts/Cart.jsp</result>
</action>
 <!-- Check -->
<!-- <action name="viewCategory"
class="org.springframework.samples.jpetstore.web.struts.ViewCategoryAction"
name="emptyForm" scope="session" validate="true"
input="/WEB-INF/jsp/struts/index.jsp">
<result name="success" name="/WEB-INF/jsp/struts/Category.jsp"/>
</action>
 -->
<action name="newAccount"
class="org.springframework.samples.jpetstore.web.struts.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="org.springframework.samples.jpetstore.web.struts.ViewItemAction">
<result name="success">/WEB-INF/jsp/struts/Item.jsp</result>
</action>
 <action name="viewOrder"
class="org.springframework.samples.jpetstore.web.struts.ViewOrderAction">
<result name="success">/WEB-INF/jsp/struts/ViewOrder.jsp"</result>
</action>
 <action name="viewProduct"
class="org.springframework.samples.jpetstore.web.struts.ViewProductAction"
<result name="success">/WEB-INF/jsp/struts/Product.jsp</result>
</action>
 </struts>

*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">
<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" />

<bean id="editAccountAction"
class="com.home.practice.shop.EditAccountAction">
<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" />
 <bean id="listOrdersAction"
class="com.home.practice.shop.ListOrdersAction" />
 <bean id="newAccountAction"
class="com.home.practice.shop.NewAccountAction" />

 <bean id="newOrderAction" class="com.home.practice.shop.NewOrderAction">
<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">
<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">
<property name="workingItemId" value="" />
<property name="cart" ref="domain.cart" />
</bean>

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


<bean id="signonAction" class="com.home.practice.shop.SignonAction">
<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">
<property name="workingItemId" value="" />
<property name="cart" ref="domain.cart" />
</bean>


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


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

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

<bean id="viewOrderAction" class="com.home.practice.shop.ViewOrderAction">
<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" />
 <bean id="domain.account" class="com.home.practice.shop.domain.Account" />
<bean id="domain.cart" class="com.home.practice.shop.domain.Cart" />
<bean id="domain.cartItem" class="com.home.practice.shop.domain.CartItem" />
<bean id="domain.category" class="com.home.practice.shop.domain.Category" />
<bean id="domain.item" class="com.home.practice.shop.domain.Item" />
<bean id="domain.lineItem" class="com.home.practice.shop.domain.LineItem" />
<bean id="domain.order" class="com.home.practice.shop.domain.Order" />
<bean id="domain.product" class="com.home.practice.shop.domain.Product" />
<bean id="myPageList" class =
"org.springframework.beans.support.PagedListHolder"/>


</beans>


Regards,
Srineel

Re: Issue with running Struts2 project

Posted by Srineel Mazumdar <sm...@gmail.com>.
Hi,

I could make some progress after keeping the struts.xml manually in classes
folder but the issue is again coming for other action. Currently working on
it .

Thanks a ton for your help !!

This is the screen I  am getting on hitting index.do

[image: Inline image 1]




On Tue, Nov 6, 2012 at 9:15 PM, Srineel Mazumdar <sm...@gmail.com>wrote:

> Spring Tool Suite.
>
> Right click -> Run On Server.
>
> Let me recheck all configurations and revert back to you.
>
> Thanks,
> Srineel
>
>
> On Tue, Nov 6, 2012 at 9:10 PM, Lukasz Lenart <lu...@apache.org>wrote:
>
>> 2012/11/6 Srineel Mazumdar <sm...@gmail.com>
>>
>> > Hi,
>> >
>> > http://localhost:8081/NewPetstore/shop/index.action
>> >
>> > http://localhost:8081/NewPetstore/shop/addItemToCart.action
>> >
>> > Also I noticed that struts.xml is missing in classes folder. Do you
>> think
>> > thats the issue ?
>> >
>>
>> For sure ;-) What IDE do you use ? How do you deploy the app ?
>>
>>
>> Regards
>> --
>> Łukasz
>> + 48 606 323 122 http://www.lenart.org.pl/
>>
>
>

Re: Issue with running Struts2 project

Posted by Srineel Mazumdar <sm...@gmail.com>.
Spring Tool Suite.

Right click -> Run On Server.

Let me recheck all configurations and revert back to you.

Thanks,
Srineel


On Tue, Nov 6, 2012 at 9:10 PM, Lukasz Lenart <lu...@apache.org>wrote:

> 2012/11/6 Srineel Mazumdar <sm...@gmail.com>
>
> > Hi,
> >
> > http://localhost:8081/NewPetstore/shop/index.action
> >
> > http://localhost:8081/NewPetstore/shop/addItemToCart.action
> >
> > Also I noticed that struts.xml is missing in classes folder. Do you think
> > thats the issue ?
> >
>
> For sure ;-) What IDE do you use ? How do you deploy the app ?
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>

Re: Issue with running Struts2 project

Posted by Lukasz Lenart <lu...@apache.org>.
2012/11/6 Srineel Mazumdar <sm...@gmail.com>

> Hi,
>
> http://localhost:8081/NewPetstore/shop/index.action
>
> http://localhost:8081/NewPetstore/shop/addItemToCart.action
>
> Also I noticed that struts.xml is missing in classes folder. Do you think
> thats the issue ?
>

For sure ;-) What IDE do you use ? How do you deploy the app ?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

Re: Issue with running Struts2 project

Posted by Srineel Mazumdar <sm...@gmail.com>.
Hi,

http://localhost:8081/NewPetstore/shop/index.action

http://localhost:8081/NewPetstore/shop/addItemToCart.action

Also I noticed that struts.xml is missing in classes folder. Do you think
thats the issue ?

Regards,
Srineel


On Tue, Nov 6, 2012 at 9:03 PM, Lukasz Lenart <lu...@apache.org>wrote:

> 2012/11/6 Srineel Mazumdar <sm...@gmail.com>
>
> > Hi,
> >
> > Stacktraces
> > *There is no Action mapped for namespace /shop and action name index. -
> >
>
> What url do you call ?
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>

Re: Issue with running Struts2 project

Posted by Lukasz Lenart <lu...@apache.org>.
2012/11/6 Srineel Mazumdar <sm...@gmail.com>

> Hi,
>
> Stacktraces
> *There is no Action mapped for namespace /shop and action name index. -
>

What url do you call ?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

Re: Issue with running Struts2 project

Posted by Srineel Mazumdar <sm...@gmail.com>.
Hi,

Stacktraces
*There is no Action mapped for namespace /shop and action name index. -
[unknown location]*

    com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:186)
    org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:497)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
    org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
    com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
    com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
    org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
    com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
    com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
    com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
    com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
    com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
    com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
    com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
    com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
    com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
    com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
    com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
    com.sun.grizzly.ContextTask.run(ContextTask.java:69)
    com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
    com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
    java.lang.Thread.run(Thread.java:619)


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

You are seeing this page because development mode is enabled. Development
mode, or devMode, enables extra debugging behaviors and reports to assist
developers. To disable this mode, set:

  struts.devMode=false

in your WEB-INF/classes/struts.properties file.



On Tue, Nov 6, 2012 at 8:47 PM, Srineel Mazumdar <sm...@gmail.com>wrote:

> Yes.
>
> I am continuously searching the answer in google. I will turn on the
> devMode and share the stacktrace.
>
> Regards,
> Srineel
>
>
> On Tue, Nov 6, 2012 at 8:29 PM, Lukasz Lenart <lu...@apache.org>wrote:
>
>> Did you try to ask Uncle Google ?
>>
>>
>> http://stackoverflow.com/questions/11803837/deploying-struts-2-and-jersey-in-glassfish
>> http://www.java.net/node/669714
>>
>> Could you set logging to DEBUG and turn on devMode ?
>>
>>
>> Regards
>> --
>> Łukasz
>> + 48 606 323 122 http://www.lenart.org.pl/
>>
>
>

Re: Issue with running Struts2 project

Posted by Srineel Mazumdar <sm...@gmail.com>.
Yes.

I am continuously searching the answer in google. I will turn on the
devMode and share the stacktrace.

Regards,
Srineel


On Tue, Nov 6, 2012 at 8:29 PM, Lukasz Lenart <lu...@apache.org>wrote:

> Did you try to ask Uncle Google ?
>
>
> http://stackoverflow.com/questions/11803837/deploying-struts-2-and-jersey-in-glassfish
> http://www.java.net/node/669714
>
> Could you set logging to DEBUG and turn on devMode ?
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>

Re: Issue with running Struts2 project

Posted by Lukasz Lenart <lu...@apache.org>.
Did you try to ask Uncle Google ?

http://stackoverflow.com/questions/11803837/deploying-struts-2-and-jersey-in-glassfish
http://www.java.net/node/669714

Could you set logging to DEBUG and turn on devMode ?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

Re: Issue with running Struts2 project

Posted by Srineel Mazumdar <sm...@gmail.com>.
Hi

Actually I have a requirement for a maintenance project which was done in
2.0.6. So to be conversant with 2.0.6, I am using the jars.

Regards,
Srineel


On Tue, Nov 6, 2012 at 7:54 PM, Lukasz Lenart <lu...@apache.org>wrote:

> 2012/11/6 Srineel Mazumdar <sm...@gmail.com>
>
> > I am using Struts 2.0.6.Getting the following error.
> >
>
> Why ?
>
> And image was removed
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>

Re: Issue with running Struts2 project

Posted by Lukasz Lenart <lu...@apache.org>.
2012/11/6 Srineel Mazumdar <sm...@gmail.com>

> I am using Struts 2.0.6.Getting the following error.
>

Why ?

And image was removed


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

Re: Issue with running Struts2 project

Posted by Srineel Mazumdar <sm...@gmail.com>.
Hi,

I am using Struts 2.0.6.Getting the following error.

[image: Inline image 1]


On Tue, Nov 6, 2012 at 7:14 PM, Lukasz Lenart <lu...@apache.org>wrote:

> 2012/11/6 Srineel Mazumdar <sm...@gmail.com>
>
> >     <filter>
> >         <filter-name>struts</filter-name>
> >
> >
> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
> >     </filter>
> >
>
> The problem is here, you're using deprecated version of the filter
>
>
> http://struts.apache.org/2.x/struts2-core/apidocs/org/apache/struts2/dispatcher/FilterDispatcher.html
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>

Re: Issue with running Struts2 project

Posted by Lukasz Lenart <lu...@apache.org>.
2012/11/6 Srineel Mazumdar <sm...@gmail.com>

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

The problem is here, you're using deprecated version of the filter

http://struts.apache.org/2.x/struts2-core/apidocs/org/apache/struts2/dispatcher/FilterDispatcher.html


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

Re: Issue with running Struts2 project

Posted by Srineel Mazumdar <sm...@gmail.com>.
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 <lu...@apache.org>wrote:

> 2012/11/5 Srineel Mazumdar <sm...@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/
>

Re: Issue with running Struts2 project

Posted by Lukasz Lenart <lu...@apache.org>.
2012/11/5 Srineel Mazumdar <sm...@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/

Re: Issue with running Struts2 project

Posted by Srineel Mazumdar <sm...@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.

Regards,
Srineel


On Mon, Nov 5, 2012 at 3:51 PM, Srineel Mazumdar <sm...@gmail.com>wrote:

> Hi Lukasz,
>
> Thanks for your reply.
>
> I made the following changes based on your suggestion :
>
> 1) scope = "prototype" : Added this in applicationContext.xml to avoid
> making the action classes as singleton
> 2) Corrected the package names of the action classes in struts.xml
> 3) Rechecked struts.xml. It has the following entry :
>
> <action name ="index" class ="com.home.practice.shop.DoNothingAction">
>  <result name="success">/WEB-INF/jsp/struts/index.jsp<result/>
> </action>
>
> Code in DoNothingAction :
>
> public class DoNothingAction extends BaseAction {
>
> /* Public Methods */
>
> public String execute() throws Exception {
>  return "success";
> }
> }
>
> Even then I am getting 404 error. Can you please help ?
>
> Regards,
> Srineel
>
>
> On Mon, Nov 5, 2012 at 1:20 PM, Lukasz Lenart <lu...@apache.org>wrote:
>
>> 2012/11/5 Srineel Mazumdar <sm...@gmail.com>:
>> > Hi,
>> >
>> > I am new to Struts2 and for learning I am doing my own project. I am
>> facing
>> > the following issue and need help in fixing:
>> >
>> > http://localhost:8081/NewPetstore : This URL is opening the index page.
>> >
>> > However
>> > http://localhost:8081/NewPetstore/shop/index.do shows 404 .
>>
>> There is no action named index in namespace /shop, second you're
>> mixing Struts 1 with Struts 2 which is wrong :\ Next thing, your
>> actions are Singletons which is very, very bad. Maybe start with
>> something simpler and add other components step by step ;-)
>>
>>
>> Regards
>>
>> --
>> Łukasz
>> + 48 606 323 122 http://www.lenart.org.pl/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>

Re: Issue with running Struts2 project

Posted by Srineel Mazumdar <sm...@gmail.com>.
Hi Lukasz,

Thanks for your reply.

I made the following changes based on your suggestion :

1) scope = "prototype" : Added this in applicationContext.xml to avoid
making the action classes as singleton
2) Corrected the package names of the action classes in struts.xml
3) Rechecked struts.xml. It has the following entry :

<action name ="index" class ="com.home.practice.shop.DoNothingAction">
<result name="success">/WEB-INF/jsp/struts/index.jsp<result/>
</action>

Code in DoNothingAction :

public class DoNothingAction extends BaseAction {

/* Public Methods */

public String execute() throws Exception {
return "success";
}
}

Even then I am getting 404 error. Can you please help ?

Regards,
Srineel


On Mon, Nov 5, 2012 at 1:20 PM, Lukasz Lenart <lu...@apache.org>wrote:

> 2012/11/5 Srineel Mazumdar <sm...@gmail.com>:
> > Hi,
> >
> > I am new to Struts2 and for learning I am doing my own project. I am
> facing
> > the following issue and need help in fixing:
> >
> > http://localhost:8081/NewPetstore : This URL is opening the index page.
> >
> > However
> > http://localhost:8081/NewPetstore/shop/index.do shows 404 .
>
> There is no action named index in namespace /shop, second you're
> mixing Struts 1 with Struts 2 which is wrong :\ Next thing, your
> actions are Singletons which is very, very bad. Maybe start with
> something simpler and add other components step by step ;-)
>
>
> Regards
>
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Issue with running Struts2 project

Posted by Lukasz Lenart <lu...@apache.org>.
2012/11/5 Srineel Mazumdar <sm...@gmail.com>:
> Hi,
>
> I am new to Struts2 and for learning I am doing my own project. I am facing
> the following issue and need help in fixing:
>
> http://localhost:8081/NewPetstore : This URL is opening the index page.
>
> However
> http://localhost:8081/NewPetstore/shop/index.do shows 404 .

There is no action named index in namespace /shop, second you're
mixing Struts 1 with Struts 2 which is wrong :\ Next thing, your
actions are Singletons which is very, very bad. Maybe start with
something simpler and add other components step by step ;-)


Regards

-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org