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.

你可能感兴趣的:(c,exception,properties,File,application,Build)