Return-Path: X-Original-To: apmail-camel-issues-archive@minotaur.apache.org Delivered-To: apmail-camel-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1D9D0FDDF for ; Sun, 24 Mar 2013 20:07:16 +0000 (UTC) Received: (qmail 60860 invoked by uid 500); 24 Mar 2013 20:07:16 -0000 Delivered-To: apmail-camel-issues-archive@camel.apache.org Received: (qmail 60833 invoked by uid 500); 24 Mar 2013 20:07:16 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 60757 invoked by uid 99); 24 Mar 2013 20:07:15 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 24 Mar 2013 20:07:15 +0000 Date: Sun, 24 Mar 2013 20:07:15 +0000 (UTC) From: "Piotr Klimczak (JIRA)" To: issues@camel.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (CAMEL-5940) camel-cache - Add option to cache component to easily configure ehcache XML file to load by default MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-5940?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13612214#comment-13612214 ] Piotr Klimczak edited comment on CAMEL-5940 at 3/24/13 8:07 PM: ---------------------------------------------------------------- Hi Henryk, It seems that in your last example you've hitted same "issue" as me- yesterday. The ResourceHelper in resolveMandatoryResourceAsInputStream method uses CamelContext's classResolver which is DefaultClassResolver (in junit test cases). Then the DefaultClassResolver in loadResourceAsStream method is using ObjectHelper's loadResourceAsStream method. The loadResourceAsStream method has a body as shown below: {code} /** * Attempts to load the given resource as a stream using the thread context * class loader or the class loader used to load this class * * @param name the name of the resource to load * @return the stream or null if it could not be loaded */ public static InputStream loadResourceAsStream(String name) { InputStream in = null; String resolvedName = resolveUriPath(name); ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); if (contextClassLoader != null) { in = contextClassLoader.getResourceAsStream(resolvedName); } if (in == null) { in = ObjectHelper.class.getClassLoader().getResourceAsStream(resolvedName); } return in; } {code} In your example (whis is same I've tried yesterday) the problem is with: {code} "classpath:/com/my/app/ehcache/config.xml" {code} Your example resource would be never found because it has the leading "/". This code {code} getClassLoader().getResourceAsStream(resolvedName) {code} expects the resolvedName to be without leading "/". If provided, then it fails. It works much different than: {code} getClass().getResourceAsStream(resolvedName) {code} was (Author: nannou9): Hi Henryk, It seems that in your last example you've hitted same "issue" as me- yesterday. The ResourceHelper in resolveMandatoryResourceAsInputStream method uses CamelContext's classResolver which is DefaultClassResolver (in junit test cases). Then the DefaultClassResolver in loadResourceAsStream method is using ObjectHelper's loadResourceAsStream method. The loadResourceAsStream method has a body as shown below: {body} /** * Attempts to load the given resource as a stream using the thread context * class loader or the class loader used to load this class * * @param name the name of the resource to load * @return the stream or null if it could not be loaded */ public static InputStream loadResourceAsStream(String name) { InputStream in = null; String resolvedName = resolveUriPath(name); ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); if (contextClassLoader != null) { in = contextClassLoader.getResourceAsStream(resolvedName); } if (in == null) { in = ObjectHelper.class.getClassLoader().getResourceAsStream(resolvedName); } return in; } {body} In your example (whis is same I've tried yesterday) the problem is with: {code} "classpath:/com/my/app/ehcache/config.xml" {code} Your example resource would be never found because it has the leading "/". This code {code} getClassLoader().getResourceAsStream(resolvedName) {code} expects the resolvedName to be without leading "/". If provided, then it fails. It works much different than: {code} getClass().getResourceAsStream(resolvedName) {code} > camel-cache - Add option to cache component to easily configure ehcache XML file to load by default > --------------------------------------------------------------------------------------------------- > > Key: CAMEL-5940 > URL: https://issues.apache.org/jira/browse/CAMEL-5940 > Project: Camel > Issue Type: Improvement > Components: camel-cache > Reporter: Claus Ibsen > Fix For: 2.11.1 > > > See > By default ehache.xml is loaded from classpath. We should make it possible to configure CacheComponent with a string option that refers to the resource to load. > Then people can do something a like: > {code} > > > > {code} -- 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