Public Agentserver (Socket c,string confdir) {
This.client = C;
ApplicationContext ac = new Filesystemxmlapplicationcontext (confdir);
This.atsmgr = (atsmgr) ac.getbean ("Atsmgr");
}
Use the Filesystemxmlapplicationcontext method to prepare to take the bean in the container, there is no problem in the window environment, but put on Jenkins found always error, said the file can not find:
/home/docker/.jenkins/jobs/ats/workspace/target/test-classes/utap-ats.xmlorg.springframework.beans.factory.BeanDefinitionStoreException:IOException parsing XML document from file [/home/docker/.jenkins/jobs/ats/workspace/home/docker/.jenkins/jobs/ats/workspace/target/test-classes/ Utap-ats.xml]; Nested exception is java.io.filenotfoundexception:home/docker/.jenkins/jobs/ats/workspace/target/test-classes/ utap-Ats.xml (No such file or directory) at Org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions (Xmlbeandefinitionreader.java :343) at Org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions ( Xmlbeandefinitionreader.java:60V) at Org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions ( Abstractbeandefinitionreader.java:180) at Org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions ( Abstractbeandefinitionreader.java:216) at Org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions ( Abstractbeandefinitionreader.java:187) at Org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions ( Abstractbeandefinitionreader.java:251) at Org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions ( Abstractxmlapplicationcontext.java:127) at Org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions ( Abstractxmlapplicationcontext.java:93) at Org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory ( Abstractrefreshableapplicationcontext.java:129) at Org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory ( Abstractapplicationcontext.java:537) at Org.springframework.context.support.AbstractApplicationContext.refresh (Abstractapplicationcontext.java: 452) at Org.springframework.context.support.FileSystemXmlApplicationContext.<init> (filesystemxmlapplicationcontext.java:140) at Org.springframework.context.support.FileSystemXmlApplicationContext.<init> (filesystemxmlapplicationcontext.java:84) at Com.newland.sri.utap.ats.AgentServer.<init> (agentserver.java:31) at Com.newland.sri.utap.ats.atstest$t1.run (Atstest.java:57) at Java.lang.Thread.run (Thread.java:745) caused By:java.io.FileNotFoundException:home/docker/.jenkins/jobs/ats/workspace/target/test-classes/utap-Ats.xml (No such file or directory) at Java.io.FileInputStream.open0 (Native Method) at JAVA.IO.FILEINPUTSTREAM.O Pen (Fileinputstream.java:195) at Java.io.FileInputStream.<init> (fileinputstream.java:138) at Org.springframework.core.io.FileSystemResource.getInputStream (Filesystemresource.java:115) at Org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions ( Xmlbeandefinitionreader.java:329) ... More
To view the source code discovery, the Filesystemxmlapplicationcontext method handles the path:
protected Resource Getresourcebypath (String path) { ifnull && Path.startswith ("/") ) { = path.substring (1); } return New Filesystemresource (path);} }
With an absolute path, the first slash is removed (and I don't know why, I'm going), so put a slash in front of the code to solve the problem, the code passes:
Public agentserver (Socket c,string confdir) { this. client = C; New Filesystemxmlapplicationcontext ("/" + Confdir); this. Atsmgr = (atsmgr) ac.getbean ("Atsmgr"); }
The absolute path problem of the Filesystemxmlapplicationcontext method