Details
Description
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())
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.
Attachments
Issue Links
- relates to
-
AMQ-4682 runtime configuration - allow selective application of changes to xml configuration without broker restart
-
- Resolved
-