Thomas Swindells created AMQ-4642:
-------------------------------------
Summary: regression: SpringSslContext no longer supports
classpath:filename syntax for referencing files
Key: AMQ-4642
URL: https://issues.apache.org/jira/browse/AMQ-4642
Project: ActiveMQ
Issue Type: Bug
Affects Versions: 5.8.0, 5.7.0, 5.6.0
Reporter: Thomas Swindells
Previously keyStore and trustStore were Spring resources rather than strings.
This meant the spring standard classpath:location syntax could be used to
specify the file, eg:
<bean id="sslContext"
class="org.apache.activemq.spring.SpringSslContext">
<property name="keyStore" value="classpath:key.ks" />
<property name="keyStorePassword" value="password" />
<property name="trustStore" value="classpath:trust.ts" />
<property name="trustStorePassword" value="password" />
</bean>
The change for AMQ-3268 means that this no longer works instead throwing the
exception:
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'sslContext': Invocation of init method failed; nested
exception is java.net.MalformedURLException: unknown protocol: classpath
at
org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
Caused by: java.net.MalformedURLException: unknown protocol: classpath
The reason is in org.apache.activemq.spring.Utils:
public static Resource resourceFromString(String uri) throws
MalformedURLException {
Resource resource;
File file = new File(uri);
if (file.exists()) {
resource = new FileSystemResource(uri);
} else if (ResourceUtils.isUrl(uri)) {
resource = new UrlResource(uri);
} else {
resource = new ClassPathResource(uri);
}
return resource;
}
The ResourceUtils.isUrl has explicit code to return true if the uri startsWith
classpath, however UrlResource doesn't handle this.
A fix may be to change the line to be
resource = new UrlResource(ResourceUtils.getURL(uri));
ResourceUtils will then handle the classpath url, resolve it and return a valid
url. An alternative fix would be for this code to do an explicit check for
classpath: itself and if it is found pass the substring into ClassPathResource.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira