Custom workflow issue in TS 16.2 - not able to parse XML using Dom4jUtils

Hi,

We have recently migrated to TS 16.2 from TS 7.2 on Windows server 2012.

We have one custom workflow where we have one task in which is parsing XML file using the below code:

File f = new File(task.getArea().getFile(new CSAreaRelativePath("page_sitemap.xml")).getVPath().toString());
Document dcrDoc = Dom4jUtils.newDocument(f);
if (dcrDoc != null) {
LOGGER.warn("[execute] in if dcrDoc");
try {
String xmlStr = dcrDoc.asXML();
LOGGER.warn("xmlStr: " + xmlStr);
}
catch (Exception e) {
LOGGER.warn("check sitemap version: " + e);
try {
task.chooseTransition("ProcessSiteMap Failure", "Failure fixing ProcessSitemap");
LOGGER.warn("Failed Transition complete");
}
catch (Exception et){
LOGGER.error(et.getMessage());
}
}

Above piece is code is working fine in old server(TS 7.2 ) but in new TS 16.2 it is always going to catch block and after putting the more loggers I found out that somehow Document dcrDoc = Dom4jUtils.newDocument(f); have an issue.

As far as XML is concerned, XML is well formatted and valid. I was wondering whether I am having this issue due to some missing jar?

I have very limited knowledge of JAVA so I would really appreciate any kind of help on this issue.

Thanks,
NK

Comments

  • Les Bleus
    edited May 29, 2018 #2

    What error (exception) are you seeing? Can you check if that particular jar version is different between 7.2 and 16.2?

  • Niraj_Kumar
    edited May 30, 2018 #3

    I have compared dom4j-1.6.1 on both servers and version was same and the exception I am getting:

    "WARN com.folder.workflow.task.ProcessSiteMap () - check sitemap version: java.lang.RuntimeException: Error while parsing XML file: \IISserver\default\main\mybranch\main_branch\WORKAREA\my-workarea\page_sitemap.xml"

  • page_sitemap.xml - Is this same on both servers?

  • yes it same on both server in fact it has been copied to new server as part of content migration.

  • Niraj_Kumar
    edited June 7, 2018 #6

    In which Jar file com.interwoven.livesite.dom4j.Dom4jUtils class is avialable?

  • it's inside livesite-runtime.jar.

    You could put your logic into try-catch block and see what's the actual path of the page_sitemap.xml

    Something like this

    try {
        final String dcrPath = task.getArea().getFile(new CSAreaRelativePath("page_sitemap.xml")).getVPath().toString();
        LOGGER.debug("String: " + String);
    
        File f = new File(dcrPath);
        Document dcrDoc = Dom4jUtils.newDocument(f);
    
        String xmlStr = dcrDoc.asXML();
        LOGGER.warn("xmlStr: " + xmlStr);
    } catch (Exception e) {
        LOGGER.warn("check sitemap version: " + e);
        try {
            task.chooseTransition("ProcessSiteMap Failure", "Failure fixing ProcessSitemap");
            LOGGER.warn("Failed Transition complete");
        } 
        catch (Exception et){
            LOGGER.error(et.getMessage());
        }
    }
    
    
  • Thanks Chau!

    I have my code written under try catch block and path of page_sitemap.xml is correct.
    logger is not able to print anything after below line:
    Document dcrDoc = Dom4jUtils.newDocument(f);

    so I am guessing it has something to do with Dom4jUtils(dom4j jar).

    Thanks,
    Niraj Kumar

  • If something went wrong in a try{} block, you would always get an exception in the catch{} bock. You have to update your LOGGER statement to log the stacktrace properly.

    } catch (Exception e) {
        LOGGER.error("check sitemap version: ", e);        // this is the correct way to log the exception in Java
        ....
    }
    
    
  • Hi Felix,

    Thanks for suggestion.

    If I hardcode the path of page_sitemap.xml in my java file I was able to bypass the above exception but again it's failing again when its getting the file dynamically.

    Any advice.

    TIA
    Niraj Kumar

TeamSite Developer Resources

  • Docker Automation

  • LiveSite Content Services (LSCS) REST API

  • Single Page Application (SPA) Modules

  • TeamSite Add-ons

If you are interested in gaining full access to the content, you can register for a My Support account here.
image
OpenText CE Products
TeamSite
APIs