eclipse-basyx / basyx-java-server-sdk

MIT License
59 stars 47 forks source link

[BUG] Cannot load AASX files with JSON payload #479

Open StenGruener opened 1 month ago

StenGruener commented 1 month ago

Hi all

i fail to load aasx files with json payload into the server.

2024-10-02T14:05:56.462Z INFO 1 --- [ main] a.p.AasEnvironmentPreconfigurationLoader : Loading AAS Environment (1/3) from file 'jsonAO2000.aasx' 2024-10-02T14:05:56.697Z WARN 1 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'preconfigurationLoaderInitializer' defined in URL [jar:file:/application/basyxExecutable.jar!/BOOT-INF/lib/basyx.aasenvironment-core-2.0.0-SNAPSHOT.jar!/org/eclipse/digitaltwin/basyx/aasenvironment/preconfiguration/PreconfigurationLoaderInitializer.class]: deserialization failed 2024-10-02T14:05:56.705Z WARN 1 --- [ main] o.s.b.f.support.DisposableBeanAdapter : Invocation of close method failed on bean with name 'mqttClient': Client is connected (32100) 2024-10-02T14:05:56.725Z INFO 1 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2024-10-02T14:05:56.770Z INFO 1 --- [ main] .s.b.a.l.ConditionEvaluationReportLogger : Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled. 2024-10-02T14:05:56.819Z ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'preconfigurationLoaderInitializer' defined in URL [jar:file:/application/basyxExecutable.jar!/BOOT-INF/lib/basyx.aasenvironment-core-2.0.0-SNAPSHOT.jar!/org/eclipse/digitaltwin/basyx/aasenvironment/preconfiguration/PreconfigurationLoaderInitializer.class]: deserialization failed at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770) ~[spring-beans-6.0.12.jar!/:6.0.12] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) ~[spring-beans-6.0.12.jar!/:6.0.12] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[spring-beans-6.0.12.jar!/:6.0.12] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:325) ~[spring-beans-6.0.12.jar!/:6.0.12] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.12.jar!/:6.0.12] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:323) ~[spring-beans-6.0.12.jar!/:6.0.12] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-6.0.12.jar!/:6.0.12] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:973) ~[spring-beans-6.0.12.jar!/:6.0.12] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:942) ~[spring-context-6.0.12.jar!/:6.0.12] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608) ~[spring-context-6.0.12.jar!/:6.0.12] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.1.4.jar!/:3.1.4] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) ~[spring-boot-3.1.4.jar!/:3.1.4] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) ~[spring-boot-3.1.4.jar!/:3.1.4] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-3.1.4.jar!/:3.1.4] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309) ~[spring-boot-3.1.4.jar!/:3.1.4] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298) ~[spring-boot-3.1.4.jar!/:3.1.4] at org.eclipse.digitaltwin.basyx.aasenvironment.component.AasEnvironmentComponent.main(AasEnvironmentComponent.java:42) ~[classes!/:2.0.0-SNAPSHOT] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[basyxExecutable.jar:2.0.0-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:95) ~[basyxExecutable.jar:2.0.0-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[basyxExecutable.jar:2.0.0-SNAPSHOT] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65) ~[basyxExecutable.jar:2.0.0-SNAPSHOT] Caused by: org.eclipse.digitaltwin.aas4j.v3.dataformat.core.DeserializationException: deserialization failed at org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.XmlDeserializer.read(XmlDeserializer.java:120) ~[aas4j-dataformat-xml-1.0.2.jar!/:na] at org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.AASXDeserializer.read(AASXDeserializer.java:99) ~[aas4j-dataformat-aasx-1.0.2.jar!/:na] at org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.AASXDeserializer.parseReferencedFilePathsFromAASX(AASXDeserializer.java:201) ~[aas4j-dataformat-aasx-1.0.2.jar!/:na] at org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx.AASXDeserializer.getRelatedFiles(AASXDeserializer.java:125) ~[aas4j-dataformat-aasx-1.0.2.jar!/:na] at org.eclipse.digitaltwin.basyx.aasenvironment.environmentloader.CompleteEnvironment.fromInputStream(CompleteEnvironment.java:113) ~[basyx.aasenvironment-core-2.0.0-SNAPSHOT.jar!/:2.0.0-SNAPSHOT] at org.eclipse.digitaltwin.basyx.aasenvironment.environmentloader.CompleteEnvironment.fromFile(CompleteEnvironment.java:96) ~[basyx.aasenvironment-core-2.0.0-SNAPSHOT.jar!/:2.0.0-SNAPSHOT] at org.eclipse.digitaltwin.basyx.aasenvironment.preconfiguration.AasEnvironmentPreconfigurationLoader.loadPreconfiguredEnvironments(AasEnvironmentPreconfigurationLoader.java:85) ~[basyx.aasenvironment-core-2.0.0-SNAPSHOT.jar!/:2.0.0-SNAPSHOT] at org.eclipse.digitaltwin.basyx.aasenvironment.preconfiguration.PreconfigurationLoaderInitializer.loadPreconfiguredEnvironment(PreconfigurationLoaderInitializer.java:68) ~[basyx.aasenvironment-core-2.0.0-SNAPSHOT.jar!/:2.0.0-SNAPSHOT] at org.eclipse.digitaltwin.basyx.aasenvironment.preconfiguration.PreconfigurationLoaderInitializer.afterPropertiesSet(PreconfigurationLoaderInitializer.java:60) ~[basyx.aasenvironment-core-2.0.0-SNAPSHOT.jar!/:2.0.0-SNAPSHOT] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1817) ~[spring-beans-6.0.12.jar!/:6.0.12] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ~[spring-beans-6.0.12.jar!/:6.0.12] ... 24 common frames omitted Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character '{' (code 123) in prolog; expected '<' at [row,col {unknown-source}]: [1,1] at com.fasterxml.jackson.dataformat.xml.XmlFactory._initializeXmlReader(XmlFactory.java:734) ~[jackson-dataformat-xml-2.15.2.jar!/:2.15.2] at com.fasterxml.jackson.dataformat.xml.XmlFactory._createParser(XmlFactory.java:618) ~[jackson-dataformat-xml-2.15.2.jar!/:2.15.2] at com.fasterxml.jackson.dataformat.xml.XmlFactory.createParser(XmlFactory.java:496) ~[jackson-dataformat-xml-2.15.2.jar!/:2.15.2] at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3772) ~[jackson-databind-2.15.2.jar!/:2.15.2] at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3740) ~[jackson-databind-2.15.2.jar!/:2.15.2] at org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.XmlDeserializer.read(XmlDeserializer.java:118) ~[aas4j-dataformat-xml-1.0.2.jar!/:na] ... 34 common frames omitted Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '{' (code 123) in prolog; expected '<' at [row,col {unknown-source}]: [1,1] at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:666) ~[woodstox-core-6.5.1.jar!/:6.5.1] at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2148) ~[woodstox-core-6.5.1.jar!/:6.5.1] at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1180) ~[woodstox-core-6.5.1.jar!/:6.5.1] at com.fasterxml.jackson.dataformat.xml.XmlFactory._initializeXmlReader(XmlFactory.java:729) ~[jackson-dataformat-xml-2.15.2.jar!/:2.15.2] Aas4j should support this https://github.com/eclipse-aas4j/aas4j/issues/287 feature.

I also attach a demo AASX file (please rename to aasx) jsonAO2000docs.zip

Thanks!

StenGruener commented 1 month ago

bump

aaronzi commented 1 month ago

Hi Sten,

we found the problem in the AAS Environment (when using the preconfiguration and the /serialization endpoint. Both currently don't support serializing/deserializing aasx files with json content. Since this is already implemented in aas4j it should be an easy fix.

For reference here is the link to aas4j with the method to be used: aas4j AASXSerializer

Changes need to be made here:

I will put this ticket in our backlog so that it can be implemented in the next weeks.

mdanish98 commented 1 week ago

We are waiting for a new release from AAS4J, because we need the aas4j AASXSerializer methods.