-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Description
to test some features of spring-boot-devtools
, I created a spring boot app using spring boot 1.5.3.RELEASE
from Spring Initializr, before writing anything I ran this app, but lines of red error message showed up:
it seemed that something is wrong with this fresh app, so I checked my pom file and tried to find the dependencies mentioned in the error message, with the help of IDEA I generated a maven diagram:
jaxb-api
was transitively introduced by a dependency mssql-jdbc
added by Spring Initializr, but the error message says that
D:.m2\repository\com\sun\xml\bind\jaxb-impl\2.2.3-1\jaxb-api.jar does not exist
apparently the groupId of jaxb-api.jar
is wrong, to figure out what happened, I spent some time debugging spring-boot-devtools
, and traced the source of above mentioned error message, here is what happened:
private static List<URL> getUrlsFromManifestClassPathAttribute(JarFile jarFile)
throws IOException {
Manifest manifest = jarFile.getManifest();
if (manifest == null) {
return Collections.<URL>emptyList();
}
String classPath = manifest.getMainAttributes()
.getValue(Attributes.Name.CLASS_PATH);
if (!StringUtils.hasText(classPath)) {
return Collections.emptyList();
}
String[] entries = StringUtils.delimitedListToStringArray(classPath, " ");
List<URL> urls = new ArrayList<>(entries.length);
File parent = new File(jarFile.getName()).getParentFile();
for (String entry : entries) {
try {
File referenced = new File(parent, entry);
if (referenced.exists()) {
urls.add(referenced.toURI().toURL());
}
else {
System.err.println("Ignoring Class-Path entry " + entry + " found in "
+ jarFile.getName() + " as " + referenced
+ " does not exist");
}
}
catch (MalformedURLException ex) {
throw new IllegalStateException(
"Class-Path attribute contains malformed URL", ex);
}
}
return urls;
}
devtools reads MANIFEST.MF
from jaxb-impl-2.2.3.jar
and extracts the Class-Path
attribute from it, then split the content of Class-Path
into entries each of which then used to build corresponding URL, the content of MANIFEST.MF
is pasted below:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 1.5.0_22-b03 (Sun Microsystems Inc.)
Specification-Title: Java Architecture for XML Binding
Specification-Version: 2.2.2
Specification-Vendor: Oracle Corporation
Implementation-Title: JAXB Reference Implementation
Implementation-Version: 2.2.3
Implementation-Vendor: Oracle Corporation
Implementation-Vendor-Id: com.sun
Extension-Name: com.sun.xml.bind
Build-Id: hudson-jaxb-ri-2.2.3-3
Class-Path: jaxb-api.jar activation.jar jsr173_1.0_api.jar jaxb1-impl.
jar
Name: com.sun.xml.bind.v2.runtime
Implementation-Version: 2.2.3-hudson-jaxb-ri-2.2.3-3-
according to the logic of method getUrlsFromManifestClassPathAttribute
, devtools tries to find jaxb-api.jar
from the same directory where jaxb-impl-2.2.3.jar
resides, but the correct groupId of jaxb-api
is javax.xml.bind
.
I also tried downgrading the version of spring boot from 1.5.3.RELEASE
to 1.5.2.RELEASE
, the error message disappeared, so I guess this is a bug of devtools ?
I checked the commits of org.springframework.boot.devtools.restart.ChangeableUrls
, and found a commit which seemed to be an update for devtools.
is this a bug ? that red error message is pretty annoying, so I'm looking for a way to disable that.
thx in advance.