Closed yyjason closed 2 years ago
If you'd like us to spend some time investigating, please take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem.
Did you include the /demo.xml
into the native-image? See this doc for details.
Below is the demo link https://github.com/yyjason/xml-demo
demo.xml is already in resource-config.json.
It doesn't look like that this sample is the one which gives you the error:
mvn clean package
: 'dependencies.dependency[org.example:xml-demo:1.0-SNAPSHOT]' for org.example:xml-demo:1.0-SNAPSHOT is referencing itself. @ line 39, column 21
native
maven profiledemo.xml
Can you please update the sample to something runnable?
sorry, I have pushed the latest version of this demo.
I tried with:
public class XmlApp {
public static void main(String[] args) throws DocumentException {
new XmlReader().loadXml();
}
}
And it fails the same way, so I am wondering if that's Spring Native related. could you try to build a non Spring example with just Native Build Tools and see if you can reproduce or not?
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
java -version: openjdk version "11.0.14" 2022-01-18 OpenJDK Runtime Environment GraalVM CE 22.0.0.2 (build 11.0.14+9-jvmci-22.0-b05) OpenJDK 64-Bit Server VM GraalVM CE 22.0.0.2 (build 11.0.14+9-jvmci-22.0-b05, mixed mode, sharing) spring-boot:2.6.7 spring-native:0.11.5 native-maven-plugin:0.9.11
Usecase import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.io.SAXReader; import org.springframework.beans.factory.InitializingBean;
import java.net.URL;
@Component public class XmlReader implements InitializingBean { private static Logger logger = (Logger) LoggerFactory.getLogger(XmlReader.class); public void loadXml() throws DocumentException, IOException { SAXReader saxReader = new SAXReader();
URL url = XmlReader.class.getResource("/demo.xml");
Document document = saxReader.read(url);
}
}
When running the executable, the following error message appears,which may be related to JDK classes(package com.sun.org.apache.xerces.internal.jaxp) not fully usable Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xmlReader': Invocation of init method failed; nested exception is org.dom4j.DocumentException: null Nested exception: null at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[na:na] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[na:na] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[na:na] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[na:na] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[na:na] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[na:na] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[na:na] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[na:na] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[na:na] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[na:na] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) ~[xml-demo:2.6.7] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) ~[xml-demo:2.6.7] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[xml-demo:2.6.7] at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:164) ~[na:na] at com.example.XmlApp.main(XmlApp.java:18) ~[xml-demo:na] Caused by: org.dom4j.DocumentException: null Nested exception: null at org.dom4j.io.SAXReader.read(SAXReader.java:495) ~[na:na] at org.dom4j.io.SAXReader.read(SAXReader.java:295) ~[na:na] at com.example.xml.XmlReader.loadXml(XmlReader.java:31) ~[xml-demo:na] at com.example.xml.XmlReader.afterPropertiesSet(XmlReader.java:40) ~[xml-demo:na] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[na:na] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[na:na] ... 14 common frames omitted