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
-
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"
0 -
yes it same on both server in fact it has been copied to new server as part of content migration.
0 -
In which Jar file com.interwoven.livesite.dom4j.Dom4jUtils class is avialable?
0 -
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()); } }
0 -
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 Kumar0 -
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 .... }
0 -
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 Kumar0
Categories
- All Categories
- 111 Developer Announcements
- 49 Articles
- 103 General Questions
- 123 IM Services
- 40 OpenText Hackathon
- 31 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 897 Cloud Fax and Notifications
- 77 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 123 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 1 XM Fax
- 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.