Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.smooks.cdr.SmooksConfigurationException: Unable to locate Smooks digest configuration '/META-INF/xsd/smooks/edi-2.0.xsd-smooks.xml' for extended resource configuration namespace 'https://www.smooks.org/xsd/smooks/edi-2.0.xsd'. This resource must be available on the classpath. at org.smooks.cdr.XMLConfigDigester.assertExtendedConfigOK(XMLConfigDigester.java:554) #360

Closed
agnissh opened this issue Sep 26, 2020 · 8 comments
Assignees
Labels
type: bug Something isn't working

Comments

@agnissh
Copy link

agnissh commented Sep 26, 2020

Hello!

When trying to perform edi to xml transformation I am getting below error. (TRACE below)
Unable to locate Smooks digest configuration '/META-INF/xsd/smooks/edi-2.0.xsd-smooks.xml'

  • It works fine if I am making one call at a time to initiate Smooks.
    i.e. // Instantiate Smooks with the config...
    Smooks smooks = new Smooks(smookConfigPath);

  • It throws the below error when I am trying to concurrently perform the transformation by using ExecutorService

Using JAVA 8.
Please let me know if more details are required.

org.smooks.cdr.SmooksConfigurationException: Unable to locate Smooks digest configuration '/META-INF/xsd/smooks/edi-2.0.xsd-smooks.xml' for extended resource configuration namespace 'https://www.smooks.org/xsd/smooks/edi-2.0.xsd'. This resource must be available on the classpath.
at org.smooks.cdr.XMLConfigDigester.assertExtendedConfigOK(XMLConfigDigester.java:554)
at org.smooks.cdr.XMLConfigDigester.getExtenededConfigDigester(XMLConfigDigester.java:519)
at org.smooks.cdr.XMLConfigDigester.digestExtendedResourceConfig(XMLConfigDigester.java:477)
at org.smooks.cdr.XMLConfigDigester.digestV12XSDValidatedConfig(XMLConfigDigester.java:276)
at org.smooks.cdr.XMLConfigDigester.digestConfigRecursively(XMLConfigDigester.java:231)
at org.smooks.cdr.XMLConfigDigester.digestConfig(XMLConfigDigester.java:201)
at org.smooks.cdr.SmooksResourceConfigurationStore.registerResources(SmooksResourceConfigurationStore.java:246)
at org.smooks.Smooks.addConfigurations(Smooks.java:364)
at org.smooks.Smooks.addConfigurations(Smooks.java:336)
at org.smooks.Smooks.(Smooks.java:177)

@claudemamo
Copy link
Member

Smooks should be initiated only once. Can you post the Java code which starts Smooks and filters the doc?

@agnissh
Copy link
Author

agnissh commented Sep 28, 2020

Hi @claudemamo ,

Thank you so much for the response.
We have a common function in Utility class for converting RAW EDI to XML.
The reason for calling convertToXML multiple is because the message content is different for FeedEntry.

public String convertToXml(String messageContent, String smookConfigPath) {
    byte[] messageIn = messageContent.getBytes();
    Locale defaultLocale = Locale.getDefault();
    Locale.setDefault(new Locale("en", "IE"));

    // Instantiate Smooks with the config...
    Smooks smooks = new Smooks(smookConfigPath);

    try {
        // Create an exec context - no profiles....
        ExecutionContext executionContext = smooks.createExecutionContext();
        StringResult result = new StringResult();
        smooks.filterSource(executionContext, new StreamSource(new ByteArrayInputStream(messageIn)), result);
        Locale.setDefault(defaultLocale);
        //smooks.close();
        return result.getResult();
    } catch (Exception Ex) {
        logger.error(Ex.printStackTrace())
        throw Ex;
    } finally {
        smooks.close();
    }
}

This above common function is called from a ServiceClass=>

List < CompletableFuture < String >> futures = evaluateXMLFeed.entrySet().parallelStream().map(eachRecord - > CompletableFuture.supplyAsync(
    () - > {
        try {
            String messageContent_PerKey = new String(evaluateXMLFeed.get(eachRecord.getKey()));
            //Call to ConvertXML
            String xmlText = utility.convertToXml(messageContent_PerKey, "/<ResourcesFolder>/smooks-config.xml");

            //Processing Logic Further
            
            return ("ProcessContent");

        } catch (Exception ex) {
            errorFiles.add(eachRecord.getKey());
            Thread.currentThread().interrupt();
            logger.error("Failed to process=>" + eachRecord.getKey() + ex.getMessage());
            return "Error";
        }


    }, executor)).collect(Collectors.toList());

@claudemamo claudemamo self-assigned this Sep 28, 2020
@claudemamo
Copy link
Member

It appears to be a defect. I'll follow it up but, in the meantime, can you use Smook profiles instead? It should even lead to better performance.

@claudemamo claudemamo added the type: bug Something isn't working label Sep 28, 2020
@claudemamo claudemamo added this to the v2.0.0-M2 milestone Sep 28, 2020
@agnissh
Copy link
Author

agnissh commented Oct 5, 2020

Thank you @claudemamo for the suggestion. We tried that actually our conversion logic remain the for a specific type of payload and does not vary depending on the content. Any suggestion on when this fix will be be available ?

@claudemamo
Copy link
Member

I might be misunderstanding the problem. If your Smooks configuration remains the same across executions, then you should construct Smooks once outside the parallelStream block. Only the createExecutionContext and filterSource methods need to be inside the block.

@agnissh
Copy link
Author

agnissh commented Oct 8, 2020

Hi @claudemamo , thank you!! i followed your recommendation and that results in below error . For single threaded execution it works fine.

Caused by: org.xml.sax.SAXException: SAX2 driver class org.smooks.cartridges.dfdl.parser.DfdlParser not found
java.lang.ClassNotFoundException: org.smooks.cartridges.dfdl.parser.DfdlParser
at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:230)
at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:221)
at org.smooks.delivery.AbstractParser.createXMLReader(AbstractParser.java:313)
at org.smooks.delivery.sax.SAXParser.parse(SAXParser.java:89)
at org.smooks.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:112)

@claudemamo
Copy link
Member

Please post the updated Java code Agnish along with the configs. I will try to reproduce it locally.

@claudemamo claudemamo modified the milestones: v2.0.0-M2, v2.0.0-M3 Nov 28, 2020
@claudemamo claudemamo removed this from the v2.0.0-M3 milestone Mar 26, 2021
@claudemamo
Copy link
Member

Closing stale issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Development

No branches or pull requests

2 participants