Hi Claude and Team Members,
I created a function in which I’m trying to convert the interchange XML to EDI. It was all working fine when the EDIFACT-MESSAGES.dfdl.xsd was present in the resources directory. However, when I moved this to the folder outside of the src folder, which we do when we want to save the files outside of the JAR, it’s not able to load the file; I’m getting, file not found error. I tried different ways to pass the file like {relativePath} or {absolutePath} or file:/{absolutePath} or file:///{absolutePath}, but none seems to work; I’m getting FileNotFound error. Also, for the paths like file:/{absolutePath} or file:///{absolutePath}, I see it’s appending the ‘/‘ before the path which is definitely not a valid path but when I’m passing the absolutePath like this ‘/Users/Akash….’ It’s not appending the extra slash.
I need to make it pick the files present outside the src folder, which is inside the ExternalDirectory. Could you please help me here.
Error Messages -
When passed the relative Path -
`Caused by: org.smooks.api.SmooksConfigException: Required resource /ExternalDirectory/EDIFACT/EDIFACT-Messages.dfdl.xsd was not found.
Classpath is unknown. Hint: are you sure you have added the right EDIFACT schema pack to the Java classpath?`
When Passed the path like file:/{absolutePath} or file:///{absolutePath} -> here it’s adding extra ‘/‘
- `Caused by: org.smooks.api.SmooksConfigException: Required resource /file:/Users/akashverma/MainProject/json_to_edifact/ExternalDirectory/EDIFACT/EDIFACT-Messages.dfdl.xsd as not found.
Classpath is unknown. Hint: are you sure you have added the right EDIFACT schema pack to the Java classpath?`
When passing the absolute path like this - /Users/akashverma/MainProject/json_to_edifact/ExternalDirectory/EDIFACT/EDIFACT-Messages.dfdl.xsd getting the same error but it’s not appending the ‘/‘
- `Caused by: org.smooks.api.SmooksConfigException: Required resource /Users/akashverma/MainProject/json_to_edifact/ExternalDirectory/EDIFACT/EDIFACT-Messages.dfdl.xsd as not found.
Classpath is unknown. Hint: are you sure you have added the right EDIFACT schema pack to the Java classpath?`
Code -
protected static String convertInterchangeToEdifact(Object interchange, String version, List<String> messageType) {
And Below is the structure of my package
MainProject
-> JSON_TO_EDIFACT
-> SRC->MAIN->JAVA->com.json-to-edifact>Template->IMPL-> JsonToEDITemplateBuilderServiceImpl.JAVA
-> ExternalDirectory->EDIFACT->EDIFACT-MESSAGES.dfdl.xsd
Also, I found it breaks inside the below function
protected String readVersion(Parameter<String> schemaUriParameter) throws XPathExpressionException, ParserConfigurationException, IOException, SAXException
{ DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = documentBuilder.parse(Misc.getRequiredResource((String)schemaUriParameter.getValue()).toString()); // -> breaks here
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
return (String)xpath.compile("/schema/annotation/appinfo[@source='http://www.ibm.com/dfdl/edi/un/edifact']/text()").evaluate(document, XPathConstants.STRING); }`
Thanks,
Akash.