2

I am using IBM WCS 7 aurorab2b store.

I want to retrieve the description of a partNumber entered by user. I am getting catentryID = 14726 and langId as -1. I tried the following way and I am getting javax.ejb.DuplicateKeyException when creating instance of CatalogEntryDescriptionAccessBean

try{

    String catentID = catlogBean.getCatalogEntryReferenceNumber();
    long catentryID = Long.parseLong(catentID);
    Integer langID = Integer.parseInt(getLanguageId());
    System.out.println("catEntryID:"+catentryID);
    System.out.println("langID:"+langID+"");
    CatalogEntryDescriptionAccessBean catlogDescriptionBean = new CatalogEntryDescriptionAccessBean(catentryID,langID);

    if(catlogDescriptionBean == null)
        System.out.println("catlogDescriptionBean is null");
    else
        System.out.println("catlogDescriptionBean is not null");

    description = catlogDescriptionBean.getShortDescription();
}
catch(Exception e){
    System.out.println("EXCEPTION IN DESCRPTN");
    e.printStackTrace();
}
Michał Trybus
  • 11,526
  • 3
  • 30
  • 42
Narendra Jaggi
  • 1,297
  • 11
  • 33

1 Answers1

1

Please note calling the constructor of access bean will Maps to a corresponding ejbCreate method in the home interface of the EJB. which means you are creating new record which already exist.

use the following way to get description using access beans:

CatalogEntryAccessBean catEntryAB = new CatalogEntryAccessBean();
catEntryAB.setInitKey_catalogEntryReferenceNumber(catentry_id);

catEntryAB.refreshCopyHelper();

CatalogEntryDescriptionAccessBean catEntryDescAB = catEntryAB.getDescription(langId);

you need yo catch suitable exceptions thrown by bean EJBs and get the description from catEntryDescAB object.

Update : 2nd way to achieve same :

String longDesc = CatalogEntryCache.getDescription(catEntryAB , 
                        this.commandContext.getLanguageId(), getStoreId()).getLongDescription()

please note in JSPs , WCS is using Solr to get production information , please read ProductDisplay.jsp to see the wcf services used and corresponding access/search profiles.

hope that answers your question.

Thanks

Abed

Abed Yaseen
  • 522
  • 4
  • 12
  • thanks for replying! I am getting instance of CatalogEntryAccessBean by iterating enumeration returned by findByPartNumbersAndStore(java.lang.String[] partNumbers, java.lang.Integer storeId) , So after getting the instance of CatalogEntryAccessBean & i can get catentryID by getCatalogEntryReferenceNumber. so now again I have to do catEntryAB.setInitKey_catalogEntryReferenceNumber(catentry_id); ??? catentId is already present is it require to pass again before – Narendra Jaggi Jun 06 '15 at 09:34
  • No , if you have the access bean ready from previous operations , then you can used it with calling setInitKey_catalogEntryReferenceNumber(catentry_id) again . – Abed Yaseen Jun 06 '15 at 10:55
  • CatalogEntryAccessBean catalogAccessBean = new CatalogEntryAccessBean(); Enumeration enumeration = catalogAccessBean.findByPartNumbersAndStore(partNumberArray, getStoreId()); while(enumeration.hasMoreElements()){ CatalogEntryAccessBean catlogBean = (CatalogEntryAccessBean)enumeration.nextElement(); CatalogEntryDescriptionAccessBean catlogDescriptionBean = catlogBean.getDescription(); – Narendra Jaggi Jun 06 '15 at 11:03
  • For catlogBean.getDescription(); m getting duplicate exception – Narendra Jaggi Jun 06 '15 at 11:05
  • use getDescription(langId); . i need to look at exception stacktrace – Abed Yaseen Jun 06 '15 at 14:45
  • getDescription takes Integer langId and Throws: NamingException FinderException CreateException RemoteException , check your code and fix your number format exception . i've done that many times and it is working for me – Abed Yaseen Jun 06 '15 at 16:49
  • Rad will give warning sign for these 4 exception for ejb that I handled, the exception is different from all these thatsy I put the question – Narendra Jaggi Jun 06 '15 at 16:52
  • just updated my answer above , try 2nd way to do this String longDesc = CatalogEntryCache.getDescription(catEntryAB , this.commandContext.getLanguageId(), getStoreId()).getLongDescription() . please note both are working with me . if this did not work for you . then you have something else in you application – Abed Yaseen Jun 06 '15 at 17:51
  • Thanks @Abed finally both ways are working, second way is the better way as it reduce no. of statements, – Narendra Jaggi Jun 08 '15 at 15:34