Facing NullPointer In Google Cloud for Application.

57 views
Skip to first unread message

Ashish Singh

unread,
Feb 6, 2025, 8:55:55 PMFeb 6
to Smooks Users
Hi Team,
I am doing edi to xml.Project works fine when run as spring boot application in local system .
But when i build image and deploy in google cloud .See below error .

 Cache miss for key jar:file:/opt/ais.jar!/BOOT-INF/classes!/edi/204/edi204.dfdl.xsd:Off:true:false. Compiling and caching DFDL schema jar:file:/opt/ais.jar!/BOOT-INF/classes!/edi/204/edi204.dfdl.xsd...
2025-02-07 01:28:25.546 DEBUG [applicationintegration:app:properties,2cdebc0b5f0dc21d,2cdebc0b5f0dc21d] 1 --- [ntainer#0-0-C-1] c.b.a.service.impl.EdiParserServiceImpl  : Exception occurred while parsing edi org.smooks.api.SmooksConfigException: Error invoking @PostConstruct method 'postConstruct' on class 'org.smooks.cartridges.edi.parser.EdiParser'.

        at org.smooks.engine.lifecycle.AbstractLifecyclePhase.invoke(AbstractLifecyclePhase.java:79)
        at org.smooks.engine.lifecycle.PostConstructLifecyclePhase.doApply(PostConstructLifecyclePhase.java:89)
        at org.smooks.engine.lifecycle.AbstractLifecyclePhase.apply(AbstractLifecyclePhase.java:61)
        at org.smooks.engine.lifecycle.DefaultLifecycleManager.applyPhase(DefaultLifecycleManager.java:53)
        at org.smooks.engine.delivery.JavaContentHandlerFactory.create(JavaContentHandlerFactory.java:94)
        at org.smooks.engine.delivery.DefaultContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.addContentHandler(DefaultContentDeliveryConfigBuilder.java:499)
        at org.smooks.engine.delivery.DefaultContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyContentDeliveryUnitStrategy(DefaultContentDeliveryConfigBuilder.java:441)
        at org.smooks.engine.delivery.DefaultContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyStrategy(DefaultContentDeliveryConfigBuilder.java:428)
        at org.smooks.engine.delivery.DefaultContentDeliveryConfigBuilder$ResourceConfigTableIterator.iterate(DefaultContentDeliveryConfigBuilder.java:581)
        at org.smooks.engine.delivery.DefaultContentDeliveryConfigBuilder$ResourceConfigTableIterator.access$200(DefaultContentDeliveryConfigBuilder.java:560)
        at org.smooks.engine.delivery.DefaultContentDeliveryConfigBuilder.extractContentHandlers(DefaultContentDeliveryConfigBuilder.java:387)
        at org.smooks.engine.delivery.DefaultContentDeliveryConfigBuilder.load(DefaultContentDeliveryConfigBuilder.java:276)
        at org.smooks.engine.delivery.DefaultContentDeliveryConfigBuilder.build(DefaultContentDeliveryConfigBuilder.java:168)
        at org.smooks.engine.delivery.DefaultContentDeliveryRuntimeFactory.create(DefaultContentDeliveryRuntimeFactory.java:92)
        at org.smooks.engine.DefaultExecutionContext.<init>(DefaultExecutionContext.java:121)
        at org.smooks.engine.DefaultExecutionContext.<init>(DefaultExecutionContext.java:97)
        at org.smooks.Smooks.createExecutionContext(Smooks.java:451)
        at org.smooks.Smooks.createExecutionContext(Smooks.java:417)
        at org.smooks.Smooks.filterSource(Smooks.java:491)
        at com.blumeglobal.applicationIntegration.service.impl.EdiParserServiceImpl.parseFile(EdiParserServiceImpl.java:76)
        at com.blumeglobal.applicationIntegration.workflow.MessageReceivingWorkFlow.parseMessage(MessageReceivingWorkFlow.java:163)
        at com.blumeglobal.applicationIntegration.service.impl.MessageReceivingWorkflowServiceImpl.processMessage(MessageReceivingWorkflowServiceImpl.java:79)
        at com.blumeglobal.applicationIntegration.service.impl.MessageReceivingWorkflowServiceImpl$$FastClassBySpringCGLIB$$b772d21d.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
        at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:64)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
        at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
        at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:102)

Caused by: org.smooks.cartridges.dfdl.DfdlSmooksException: java.lang.NullPointerException
        at org.smooks.cartridges.dfdl.DataProcessorFactory.lambda$compileOrGet$0(DataProcessorFactory.java:123)

        at java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1853)
        at org.smooks.cartridges.dfdl.DataProcessorFactory.compileOrGet(DataProcessorFactory.java:117)
        at org.smooks.cartridges.dfdl.DataProcessorFactory.createDataProcessor(DataProcessorFactory.java:88)
        at org.smooks.cartridges.dfdl.parser.DfdlParser.postConstruct(DfdlParser.java:188)
        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.engine.lifecycle.AbstractLifecyclePhase.invoke(AbstractLifecyclePhase.java:75)
        ... 84 more
Caused by: java.lang.NullPointerException
        at java.io.File.<init>(File.java:277)
        at org.smooks.cartridges.dfdl.DfdlSchema.compile(DfdlSchema.java:113)
        at org.smooks.cartridges.dfdl.DataProcessorFactory.lambda$compileOrGet$0(DataProcessorFactory.java:121)

        ... 93 more

I feel its not able to find the xsd file because it fails on this 
line
final File binSchemaFile = new File(WORKING_DIRECTORY + new File(uri.getPath()).getName() + ".dat");

But if I go in container and check for path printed in log xsd file is there.

FilePath Printed in log:
 Compiling and caching DFDL schema jar:file:/opt/ais.jar!/BOOT-INF/classes!/edi/204/edi204.dfdl.xsd

Screenshot 2025-02-06 175351.png
Any suggestion would be helpful.


Claude Mamo

unread,
Feb 7, 2025, 6:38:28 AMFeb 7
to smook...@googlegroups.com
Just a hunch, have you tried setting the Smooks classloader to the class classloader?

smooks = new Smooks(new DefaultApplicationContextBuilder().withClassLoader(this.getClass().getClassLoader()).build());

Claude

--
You received this message because you are subscribed to the Google Groups "Smooks Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smooks-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/smooks-user/a1631ef0-e813-455a-9977-4fbca043f9a2n%40googlegroups.com.

Ashish Singh

unread,
Feb 8, 2025, 1:04:37 AMFeb 8
to Smooks Users
Hi Claude thanks for response. Unfortunately still facing same issue .

Ashish Singh

unread,
Feb 8, 2025, 3:53:33 AMFeb 8
to Smooks Users
Hi Claude,
I was able to resolve the issue, but I had to make a slight change in the DfDlSchema code.
Following change was made

 if (cacheOnDisk) {

            final File binSchemaFile = new File(WORKING_DIRECTORY + new File(uri.getPath()).getName() + ".dat");
            binSchemaFile.getParentFile().mkdirs();
            if (binSchemaFile.exists()) {
                LOGGER.info("Loading compiled DFDL schema from {}", binSchemaFile.getAbsolutePath());
                dataProcessor = Daffodil.compiler().reload(binSchemaFile);
            } else {
                dataProcessor = compileSource();
                LOGGER.info("Saving compiled DFDL schema to {}", binSchemaFile.getAbsolutePath());
                dataProcessor.save(Channels.newChannel(Files.newOutputStream(binSchemaFile.toPath())));
            }
        }
To 

if (cacheOnDisk)
        {
            final File binSchemaFile = new File(WORKING_DIRECTORY + getFileName() + ".dat");
            binSchemaFile.getParentFile().mkdirs();
            if (binSchemaFile.exists())
            {
                LOGGER.info("Loading compiled DFDL schema from {}", binSchemaFile.getAbsolutePath());
                dataProcessor = Daffodil.compiler().reload(binSchemaFile);
            }
            else
            {
                dataProcessor = compileSource();
                LOGGER.info("Saving compiled DFDL schema to {}", binSchemaFile.getAbsolutePath());
                dataProcessor.save(Channels.newChannel(Files.newOutputStream(binSchemaFile.toPath())));
            }
        }

and added below method  :
 public String getFileName()
    {
        return uri.toString().substring(uri.toString().lastIndexOf('/') + 1);
    }

When the application is run in gcp from boot jar.
and following code was evaluated ::  new File(uri.getPath()).getName() 
uri.getPath() always resulted in null. so replaced it with   getFileName() method.

I have tested for both Edi and Edifact flow, code works fine now. Wanted to know your views if this would cause any issues.
As of now in my flows, it's working fine both in local as well as in GCP.

Claude Mamo

unread,
Feb 10, 2025, 3:30:36 AMFeb 10
to smook...@googlegroups.com
Awesome! Glad to hear that! Could you open an issue and create a PR? It should be fine to merge if all the tests pass.

Reply all
Reply to author
Forward
0 new messages