PetStore - Solution of fixing the "item.attribute" exception

I have downloaded Petstore 1.3.2 version two days ago and faced the same issue. It is unfortunate that this crucial application for J2EE learners does not run because of this bug.
This issue might happen due to two overloaded getAttribute methods in com.sun.j2ee.blueprints.catalog.model.Item class which failed to render the Item value using JSTL tag.
I have resolved this by following steps:

I. Java Changes:
1. Open file C:/petstore1.3.2/src/components/catalog/src/com/sun/j2ee/blueprints/catalog/model/Item.java and make the following change to
the existing getAttribute() method:

public String getAttribute1() {
        return attribute1;
    }


2. Open file C:/petstore1.3.2/src/components/cart/src/com/sun/j2ee/blueprints/cart/ejb/ShoppingCartLocalEJB.java and make the following change to
the existing getAttribute() method:

// convert catalog item to cart item
               CartItem ci = new CartItem(item.getItemId(),
                                      item.getProductId(),
                                      item.getCategory(),
                                      item.getProductName(),
                                      item.getAttribute1(),
                                      value.intValue(),
                                      item.getListCost());


II. JSP changes:
Change the EL expressions in the folliwng files to " ${item.attribute1}":
C:/petstore1.3.2/src/apps/petstore/src/docroot/item.jsp"(59,16): <c:out value="${item.attribute}"/>
C:/petstore1.3.2/src/apps/petstore/src/docroot/product.jsp"(100,19):    <c:out value="${item.attribute}" />
C:/petstore1.3.2/src/apps/petstore/src/docroot/search.jsp"(109,25):          <c:out value="${item.attribute}"/>
C:/petstore1.3.2/src/apps/petstore/src/docroot/ja/item.jsp"(60,16): <c:out value="${item.attribute}"/>
C:/petstore1.3.2/src/apps/petstore/src/docroot/ja/product.jsp"(102,19):    <c:out value="${item.attribute}" />
C:/petstore1.3.2/src/apps/petstore/src/docroot/ja/search.jsp"(111,25):          <c:out value="${item.attribute}"/><c:out value="${item.productName}"/>
C:/petstore1.3.2/src/apps/petstore/src/docroot/zh/item.jsp"(60,16): <c:out value="${item.attribute}"/><c:out value="${item.productName}"/>
C:/petstore1.3.2/src/apps/petstore/src/docroot/zh/product.jsp"(102,19):    <c:out value="${item.attribute}" /><c:out value="${item.productName}"/>
C:/petstore1.3.2/src/apps/petstore/src/docroot/zh/search.jsp"(111,25):          <c:out value="${item.attribute}"/><c:out value="${item.productName}"/>


III. Build Process:
1. Open C:/petstore1.3.2/src/build.properties file and make sure that the following properties are configured properly:
j2ee.server.name=localhost
j2ee.server.port=8000
javac.debug=off
j2ee.home=C://j2sdkee1.3.1
#Script suffixes on windows
j2ee-script-suffix=.bat
jwsdp-script-suffix=.bat

2. Then follow the build steps:
i. cd %J2EE_HOME%/bin and then cloudscape -start
ii. cd %J2EE_HOME%/bin and then j2ee -verbose
iii. cd C:/petstore1.3.2/src and then build.bat undeploy - Undeploys application
iv. build.bat clean - Clean up build folders.
v. build.bat core - Run fresh build.
vi. build.bat deploy - Deploy fresh build.

Hope this helps others facing the same problem.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值