[ 
https://issues.apache.org/jira/browse/AMQ-4642?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen resolved AMQ-4642.
------------------------------

       Resolution: Fixed
    Fix Version/s:     (was: 5.10.0)
                   5.9.0

Gary has fixed this as part of AMQ-4682

> 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
>          Components: Broker
>    Affects Versions: 5.6.0, 5.7.0, 5.8.0
>            Reporter: Thomas Swindells
>            Assignee: Claus Ibsen
>            Priority: Minor
>              Labels: easyfix
>             Fix For: 5.9.0
>
>
> 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 was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to