smooks / smooks-edi-cartridge

Smooks EDI & EDIFACT cartridges for reading as well as writing EDI
https://www.smooks.org
Other
22 stars 13 forks source link

Regression in M2 SNAPSHOT compared to M1 #56

Closed phax closed 4 years ago

phax commented 4 years ago

Hi guys, when filtering an EDIFACT message with validation mode "Full" I get the following error message when doing so. That worked without problems in M1:

Exception in thread "main" org.smooks.cdr.SmooksConfigurationException: Error invoking @PostConstruct method 'initialize' on class 'org.smooks.cartridges.dfdl.parser.DfdlParser'.
    at org.smooks.cdr.lifecycle.phase.AbstractLifecyclePhase.invoke(AbstractLifecyclePhase.java:78)
    at org.smooks.cdr.lifecycle.phase.PostConstructLifecyclePhase.doApplyLifecycle(PostConstructLifecyclePhase.java:88)
    at org.smooks.cdr.lifecycle.phase.AbstractLifecyclePhase.applyLifecycle(AbstractLifecyclePhase.java:60)
    at org.smooks.cdr.lifecycle.DefaultLifecycleManager.applyPhase(DefaultLifecycleManager.java:52)
    at org.smooks.delivery.JavaContentHandlerFactory$1.apply(JavaContentHandlerFactory.java:99)
    at org.smooks.delivery.JavaContentHandlerFactory$1.apply(JavaContentHandlerFactory.java:85)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
    at org.smooks.delivery.JavaContentHandlerFactory.create(JavaContentHandlerFactory.java:85)
    at org.smooks.delivery.DefaultContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.addContentDeliveryUnit(DefaultContentDeliveryConfigBuilder.java:520)
    at org.smooks.delivery.DefaultContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyContentDeliveryUnitStrategy(DefaultContentDeliveryConfigBuilder.java:464)
    at org.smooks.delivery.DefaultContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyStrategy(DefaultContentDeliveryConfigBuilder.java:451)
    at org.smooks.delivery.DefaultContentDeliveryConfigBuilder$SmooksResourceConfigurationTableIterator.iterate(DefaultContentDeliveryConfigBuilder.java:602)
    at org.smooks.delivery.DefaultContentDeliveryConfigBuilder$SmooksResourceConfigurationTableIterator.access$300(DefaultContentDeliveryConfigBuilder.java:582)
    at org.smooks.delivery.DefaultContentDeliveryConfigBuilder.extractContentHandlers(DefaultContentDeliveryConfigBuilder.java:393)
    at org.smooks.delivery.DefaultContentDeliveryConfigBuilder.load(DefaultContentDeliveryConfigBuilder.java:255)
    at org.smooks.delivery.DefaultContentDeliveryConfigBuilder.build(DefaultContentDeliveryConfigBuilder.java:138)
    at org.smooks.container.standalone.StandaloneExecutionContext.<init>(StandaloneExecutionContext.java:118)
    at org.smooks.container.standalone.StandaloneExecutionContext.<init>(StandaloneExecutionContext.java:92)
    at org.smooks.Smooks.createExecutionContext(Smooks.java:458)
    at org.smooks.Smooks.createExecutionContext(Smooks.java:416)
    at org.smooks.Smooks.filterSource(Smooks.java:490)
    at SmooksEdifactToXML.runSmooksTransform(SmooksEdifactToXML.java:83)
    at SmooksEdifactToXML.main(SmooksEdifactToXML.java:97)
Caused by: org.smooks.cdr.SmooksConfigurationException: org.smooks.cdr.SmooksConfigurationException: java.lang.RuntimeException: org.apache.daffodil.japi.InvalidUsageException: 'Full' validation not allowed when using a restored parser.
    at org.smooks.cartridges.edi.EdiDataProcessorFactory.createDataProcessor(EdiDataProcessorFactory.java:87)
    at org.smooks.cartridges.dfdl.parser.DfdlParser.initialize(DfdlParser.java:175)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.smooks.cdr.lifecycle.phase.AbstractLifecyclePhase.invoke(AbstractLifecyclePhase.java:74)
    ... 22 more
Caused by: org.smooks.cdr.SmooksConfigurationException: java.lang.RuntimeException: org.apache.daffodil.japi.InvalidUsageException: 'Full' validation not allowed when using a restored parser.
    at org.smooks.cartridges.edifact.EdifactDataProcessorFactory.doCreateDataProcessor(EdifactDataProcessorFactory.java:138)
    at org.smooks.cartridges.edi.EdiDataProcessorFactory.createDataProcessor(EdiDataProcessorFactory.java:85)
    ... 28 more
Caused by: java.lang.RuntimeException: org.apache.daffodil.japi.InvalidUsageException: 'Full' validation not allowed when using a restored parser.
    at org.smooks.cartridges.dfdl.DataProcessorFactory.lambda$0(DataProcessorFactory.java:110)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
    at org.smooks.cartridges.dfdl.DataProcessorFactory.compileOrGet(DataProcessorFactory.java:105)
    at org.smooks.cartridges.edifact.EdifactDataProcessorFactory.doCreateDataProcessor(EdifactDataProcessorFactory.java:136)
    ... 29 more
Caused by: org.apache.daffodil.japi.InvalidUsageException: 'Full' validation not allowed when using a restored parser.
    at org.apache.daffodil.japi.DataProcessor.withValidationMode(Daffodil.scala:590)
    at org.smooks.cartridges.dfdl.DfdlSchema.compile(DfdlSchema.java:123)
    at org.smooks.cartridges.dfdl.DataProcessorFactory.lambda$0(DataProcessorFactory.java:108)
    ... 32 more

Any ideas what that might have caused?

cjmamo commented 4 years ago

I get the same error on 2.0.0-M1. Can you post the Smooks config?

phax commented 4 years ago

Like this:

Smooks SMOOKS = new Smooks ();
final EdifactReaderConfigurator cfg = new EdifactReaderConfigurator ("/d06b/EDIFACT-Messages.dfdl.xsd");
cfg.setMessageTypes (Arrays.asList ("RESMSG", "REPREM", "CONDRA", "MEDREQ", "REMADV"));
cfg.setValidationMode (ValidationMode.Limited).setCacheOnDisk (Boolean.TRUE);
SMOOKS.setReaderConfig (cfg);

Try with or without the 3rd line

cjmamo commented 4 years ago

I couldn't observe any difference in behaviour between M1 and M2-SNAPSHOT even with the given snippet. When cacheOnDisk is enabled, validationMode needs to be set to off or limited since Apache Daffodil cannot restore the parser with full validation mode.

phax commented 4 years ago

Maybe that is related to the other PR, that allows the cached file on disk to be read. Since M1 was always creating new files that might not have shown up

cjmamo commented 4 years ago

I ran your snippet without any specified messageTypes and the schema was successfully loaded from disk in M1 and M2-SNAPSHOT unless I set the validation mode to full.

phax commented 4 years ago

But as soon as you specify at least 2 message types, the disk cache breaks - right?

cjmamo commented 4 years ago

Yes, it doesn't load the cached schema.

phax commented 4 years ago

Sorry - the details are alaready too far away :/