Ok, I tried, but still failed.
<bundle>mvn:org.ops4j.pax.swissbox/pax-swissbox-property/1.8.2</bundle>
<bundle>mvn:org.ops4j.pax.url/pax-url-commons/2.4.3</bundle>
<bundle>mvn:org.ops4j.pax.url/pax-url-classpath/2.4.3</bundle>
<configfile finalname="${karaf.etc}/my.config.cfg">
classpath:my.config.cfg
</configfile>
Here is what the logs shows (reduced):
Installing bundles:
...
mvn:org.ops4j.base/ops4j-base-io/1.5.0
mvn:org.ops4j.base/ops4j-base-lang/1.5.0
mvn:org.ops4j.base/ops4j-base-monitors/1.5.0
mvn:org.ops4j.base/ops4j-base-net/1.5.0
mvn:org.ops4j.base/ops4j-base-spi/1.5.0
mvn:org.ops4j.base/ops4j-base-store/1.5.0
mvn:org.ops4j.base/ops4j-base-util-property/1.5.0
mvn:org.ops4j.pax.swissbox/pax-swissbox-core/1.8.2
mvn:org.ops4j.pax.swissbox/pax-swissbox-extender/1.8.2
mvn:org.ops4j.pax.swissbox/pax-swissbox-framework/1.8.2
mvn:org.ops4j.pax.swissbox/pax-swissbox-lifecycle/1.8.2
mvn:org.ops4j.pax.swissbox/pax-swissbox-property/1.8.2
mvn:org.ops4j.pax.swissbox/pax-swissbox-tracker/1.8.2
mvn:org.ops4j.pax.tipi/org.ops4j.pax.tipi.hamcrest.core/1.3.0.1
mvn:org.ops4j.pax.tipi/org.ops4j.pax.tipi.junit/4.12.0.1
mvn:org.ops4j.pax.url/pax-url-classpath/2.4.3
mvn:org.ops4j.pax.url/pax-url-commons/2.4.3
...
Creating configuration file ...
target/exam/9ccc2e04-a3d4-49ca-b704-ec0b11c00c29/etc/my.config.cfg
Unknown protocol: classpath
Error installing boot features
java.net.MalformedURLException: Unknown protocol: classpath
at java.net.URL.<init>(URL.java:620)[:1.8.0_45]
at java.net.URL.<init>(URL.java:483)[:1.8.0_45]
at java.net.URL.<init>(URL.java:432)[:1.8.0_45]
at
org.apache.karaf.features.internal.service.FeatureConfigInstaller.installConfigurationFile(FeatureConfigInstaller.java:210)[9:org.apache.karaf.features.core:4.0.3]
at
org.apache.karaf.features.internal.service.FeatureConfigInstaller.installFeatureConfigs(FeatureConfigInstaller.java:120)[9:org.apache.karaf.features.core:4.0.3]
at
org.apache.karaf.features.internal.service.FeaturesServiceImpl.installFeature(FeaturesServiceImpl.java:1156)[9:org.apache.karaf.features.core:4.0.3]
at
org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:769)[9:org.apache.karaf.features.core:4.0.3]
at
org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1079)[9:org.apache.karaf.features.core:4.0.3]
at
org.apache.karaf.features.internal.service.FeaturesServiceImpl$1.call(FeaturesServiceImpl.java:975)[9:org.apache.karaf.features.core:4.0.3]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_45]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_45]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_45]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_45]
Caused by: java.lang.IllegalStateException: Unknown protocol: classpath
at
org.apache.felix.framework.URLHandlersStreamHandlerProxy.parseURL(URLHandlersStreamHandlerProxy.java:373)[org.apache.felix.framework-5.4.0.jar:]
at java.net.URL.<init>(URL.java:615)[:1.8.0_45]
... 12 more
From the above, the mvn:org.ops4j.pax.url/pax-url-classpath/2.4.3 is being
installed before the classpath protocol is used. Any ideas?
Best regards,
Alex soto
> On Sep 9, 2016, at 12:16 PM, Jean-Baptiste Onofré <[email protected]
> <mailto:[email protected]>> wrote:
>
> Hi Alex,
>
> You have to install pax-url-classpath bundle to have the classpath URL
> handler.
>
> On the other hand, now (since Karaf 4.0.5), both <config/> and <configfile/>
> creates a cfg file in the etc folder.
>
> Regards
> JB
>
> On 09/09/2016 06:04 PM, Alex Soto wrote:
>> I guess it is not loaded by default. Added this to my features.xml:
>>
>> <bundle>classpath:mylib.jar</bundle>
>>
>> produced error: "Unknown protocol: classpath". Also tried
>> /bundle:install/ in the interactive console, which produced the same error.
>> Is this something that can be easily solved by deploying an extra
>> bundle? If so, which one?
>>
>> More generally, what is the best practice to automatically deploy a
>> default cfg file in the etc directory when using the <configFile> tag of
>> features.xml?
>>
>>
>> Best regards,
>> Alex soto
>>
>>
>>
>>> On Sep 9, 2016, at 10:33 AM, Jean-Baptiste Onofré <[email protected]
>>> <mailto:[email protected]>
>>> <mailto:[email protected] <mailto:[email protected]>>> wrote:
>>>
>>> I'm not sure the classpath URL handler is loaded.
>>>
>>> If you do bundle:install classpath:....
>>>
>>> do you have any issue ?
>>>
>>> Regards
>>> JB
>>>
>>> On 09/09/2016 04:27 PM, Alex Soto wrote:
>>>> No, I am not using blueprint (at least in this context), this is a URL
>>>> in the features.xml file. I am trying to deploy a default config file
>>>> as part of my feature. Karaf documentation does not mention all
>>>> possible URLs it supports. It says:
>>>>
>>>> "The file URL is any URL supported by Apache Karaf (see the
>>>> [Artifacts repositories and URLs|urls] of the user guide for
>>>> details)."
>>>>
>>>>
>>>> and then:
>>>>
>>>> "However, Karaf provides several URL handlers, in addition to the
>>>> usual ones (file, http, etc…). One of these is the Maven URL
>>>> handler, which allow reusing maven repositories to point to
>>>> the bundles.”
>>>>
>>>>
>>>>
>>>> So, I thought that "the usual ones" included any of the OPS4J Pax URLs
>>>> described here:
>>>>
>>>> https://ops4j1.jira.com/wiki/display/paxurl/Classpath+Protocol
>>>> <https://ops4j1.jira.com/wiki/display/paxurl/Classpath+Protocol>
>>>>
>>>> Aren’t OPS4J Pax URL handlers included in the default Karaf distribution?
>>>>
>>>> Best regards,
>>>> Alex soto
>>>>
>>>>
>>>>
>>>>> On Sep 9, 2016, at 10:16 AM, Jean-Baptiste Onofré <[email protected]
>>>>> <mailto:[email protected]>
>>>>> <mailto:[email protected] <mailto:[email protected]>>> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> classpath is not a regular URL: AFAIK, classpath: is a specific Spring
>>>>> URL (not a blueprint regular URL).
>>>>>
>>>>> Do you use the blueprint spring extender ?
>>>>>
>>>>> Regards
>>>>> JB
>>>>>
>>>>> On 09/09/2016 03:42 PM, Alex Soto wrote:
>>>>>> Hello,
>>>>>>
>>>>>> I am trying to deploy a config file which is a resource of one of the
>>>>>> deployed bundles. I write the features.xml
>>>>>>
>>>>>> <configfile finalname="${karaf.etc}/my.config.cfg">
>>>>>> classpath://my <classpath://my> :: bundle/my.config.cfg
>>>>>> </configfile>
>>>>>>
>>>>>>
>>>>>>
>>>>>> When I run integration tests (PAX-EXAM) I get this error:
>>>>>>
>>>>>> Error installing boot features
>>>>>> java.net.MalformedURLException: Unknown protocol: classpath
>>>>>> at java.net.URL.<init>(URL.java:620)[:1.8.0_45]
>>>>>> at java.net.URL.<init>(URL.java:483)[:1.8.0_45]
>>>>>> at java.net.URL.<init>(URL.java:432)[:1.8.0_45]
>>>>>> at
>>>>>> org.apache.karaf.features.internal.service.FeatureConfigInstaller.installConfigurationFile(FeatureConfigInstaller.java:210)[9:org.apache.karaf.features.core:4.0.3]
>>>>>> at
>>>>>> org.apache.karaf.features.internal.service.FeatureConfigInstaller.installFeatureConfigs(FeatureConfigInstaller.java:120)[9:org.apache.karaf.features.core:4.0.3]
>>>>>> at
>>>>>> org.apache.karaf.features.internal.service.FeaturesServiceImpl.installFeature(FeaturesServiceImpl.java:1156)[9:org.apache.karaf.features.core:4.0.3]
>>>>>> at
>>>>>> org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:769)[9:org.apache.karaf.features.core:4.0.3]
>>>>>> at
>>>>>> org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1079)[9:org.apache.karaf.features.core:4.0.3]
>>>>>> at
>>>>>> org.apache.karaf.features.internal.service.FeaturesServiceImpl$1.call(FeaturesServiceImpl.java:975)[9:org.apache.karaf.features.core:4.0.3]
>>>>>> at
>>>>>> java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_45]
>>>>>> at
>>>>>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_45]
>>>>>> at
>>>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_45]
>>>>>> at java.lang.Thread.run(Thread.java:745)[:1.8.0_45]
>>>>>> Caused by: java.lang.IllegalStateException: Unknown protocol:
>>>>>> classpath
>>>>>> at
>>>>>> org.apache.felix.framework.URLHandlersStreamHandlerProxy.parseURL(URLHandlersStreamHandlerProxy.java:373)[org.apache.felix.framework-5.4.0.jar:]
>>>>>> at java.net.URL.<init>(URL.java:615)[:1.8.0_45]
>>>>>> ... 12 more
>>>>>>
>>>>>>
>>>>>> Looks it does not recognize the /classpath/ URL handler. How can make
>>>>>> this work? I would like the cfg files to be in the bundle that
>>>>>> uses it.
>>>>>>
>>>>>> Best regards,
>>>>>> Alex soto
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> Jean-Baptiste Onofré
>>>>> [email protected] <mailto:[email protected]>
>>>>> <mailto:[email protected] <mailto:[email protected]>>
>>>>> <mailto:[email protected] <mailto:[email protected]>>
>>>>> http://blog.nanthrax.net <http://blog.nanthrax.net/>
>>>>> <http://blog.nanthrax.net/ <http://blog.nanthrax.net/>>
>>>>> Talend - http://www.talend.com <http://www.talend.com/>
>>>>> <http://www.talend.com/ <http://www.talend.com/>>
>>>>
>>>
>>> --
>>> Jean-Baptiste Onofré
>>> [email protected] <mailto:[email protected]>
>>> <mailto:[email protected] <mailto:[email protected]>>
>>> http://blog.nanthrax.net <http://blog.nanthrax.net/>
>>> <http://blog.nanthrax.net/ <http://blog.nanthrax.net/>>
>>> Talend - http://www.talend.com <http://www.talend.com/>
>>> <http://www.talend.com/ <http://www.talend.com/>>
>>
>
> --
> Jean-Baptiste Onofré
> [email protected] <mailto:[email protected]>
> http://blog.nanthrax.net <http://blog.nanthrax.net/>
> Talend - http://www.talend.com <http://www.talend.com/>