You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Daniel McGreal <da...@redbite.com> on 2014/05/20 17:31:56 UTC

Multiple spring deployers?

Hi Karaf users,

I have a Spring bundle which calls a third party library which itself calls a native library. Because of some unfortunate yet understandable decisions of the third party, I cannot have a @Bean created more than once.

What's happening for me is that the first load of Karaf and initialisation of my bundles, everything works fine. But on the second load, I hit UnsatisfiedLinkExceptions with the message that "already loaded in another classloader".

It seems that somehow after the first successful run, my Spring configuration is being loaded twice.

My bundles:

list -t 0
START LEVEL 100 , List Threshold: 0
 ID | State    | Lvl | Version               | Name
------------------------------------------------------------------------------------------------------------------
  0 | Active   |   0 | 4.2.1                 | System Bundle
  1 | Active   |   5 | 1.4.0                 | OPS4J Base - Lang
  2 | Active   |   5 | 2.2.0.20130927-173417 | bndlib
  3 | Active   |   5 | 1.7.0                 | OPS4J Pax Swissbox :: Bnd Utils
  4 | Active   |   5 | 1.6.0                 | OPS4J Pax Url - Maven Commons
  5 | Active   |   5 | 1.6.0                 | OPS4J Pax Url - aether:
  6 | Active   |   5 | 1.6.0                 | OPS4J Pax Url - wrap:
  7 | Active   |   8 | 1.7.2                 | OPS4J Pax Logging - API
  8 | Active   |   8 | 1.7.2                 | OPS4J Pax Logging - Service
  9 | Active   |  10 | 3.0.1                 | Apache Karaf :: Service :: Guard
 10 | Active   |  10 | 1.6.0                 | Apache Felix Configuration Admin Service
 11 | Active   |  11 | 3.2.8                 | Apache Felix File Install
 12 | Active   |  12 | 4.1                   | ASM all classes with debug info
 13 | Active   |  20 | 1.1.0                 | Apache Aries Util
 14 | Active   |  20 | 1.0.0                 | Apache Aries Proxy API
 15 | Active   |  20 | 1.0.2                 | Apache Aries Proxy Service
 16 | Active   |  20 | 1.0.0                 | Apache Aries Blueprint API
 17 | Active   |  20 | 1.0.3                 | Apache Aries Blueprint CM
 18 | Resolved |  20 | 1.0.0                 | Apache Aries Blueprint Core Compatiblity Fragment Bundle, Hosts: 19
 19 | Active   |  20 | 1.4.0                 | Apache Aries Blueprint Core, Fragments: 18
 20 | Active   |  24 | 3.0.1                 | Apache Karaf :: Deployer :: Spring
 21 | Active   |  24 | 3.0.1                 | Apache Karaf :: Deployer :: Blueprint
 22 | Active   |  24 | 3.0.1                 | Apache Karaf :: Deployer :: Wrap Non OSGi Jar
 23 | Active   |  25 | 3.0.1                 | Apache Karaf :: Region :: Core
 24 | Active   |  25 | 3.0.1                 | Apache Karaf :: Features :: Core
 25 | Active   |  26 | 3.0.1                 | Apache Karaf :: Deployer :: Features
 26 | Active   |  30 | 2.11.0                | JLine
 27 | Active   |  30 | 0.2.1                 | JLEdit :: Core
 28 | Active   |  30 | 1.11                  | jansi
 29 | Active   |  30 | 1.4.0                 | OPS4J Base - Util - Property
 30 | Active   |  30 | 1.4.0                 | OPS4J Base - Util - XML
 31 | Active   |  30 | 1.4.0                 | OPS4J Base - Util - Collections
 32 | Active   |  30 | 1.6.0                 | OPS4J Pax Url - Commons
 33 | Active   |  30 | 1.7.0                 | OPS4J Pax Swissbox :: Property
 34 | Active   |  30 | 1.4.0                 | OPS4J Base - Net
 35 | Active   |  30 | 1.4.0                 | OPS4J Base - Monitors
 36 | Active   |  30 | 3.0.1                 | Apache Karaf :: Features :: Command
 37 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell :: Console
 38 | Active   |  30 | 3.0.1                 | Apache Karaf :: JAAS :: Modules
 39 | Active   |  30 | 3.0.1                 | Apache Karaf :: JAAS :: Config
 40 | Active   |  30 | 3.0.1                 | Apache Karaf :: JAAS :: Boot
 41 | Active   |  30 | 0.9.0                 | Apache Mina SSHD :: Core
 42 | Active   |  30 | 3.0.1                 | Apache Karaf :: Bundle :: Commands
 43 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell :: Table
 44 | Active   |  30 | 3.0.1                 | Apache Karaf :: Bundle :: Core
 45 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell :: Help System
 46 | Active   |  30 | 3.0.1                 | Apache Karaf :: System :: Core
 47 | Active   |  30 | 3.0.1                 | Apache Karaf :: System :: Shell Commands
 48 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell :: Various Commands
 49 | Active   |  30 | 1.0.0                 | Apache Aries Quiesce API
 50 | Active   |  30 | 3.0.1                 | Apache Karaf :: ConfigAdmin :: Core
 51 | Active   |  30 | 3.0.1                 | Apache Karaf :: ConfigAdmin :: Commands
 52 | Active   |  30 | 0.10.0                | Apache Felix Gogo Runtime
 53 | Active   |  30 | 3.0.1                 | Apache Karaf :: Instance :: Core
 54 | Active   |  30 | 3.0.1                 | Apache Karaf :: Instance :: Command
 55 | Active   |  30 | 3.0.1                 | Apache Karaf :: JAAS :: Command
 56 | Active   |  30 | 3.0.1                 | Apache Karaf :: Diagnostic :: Core
 57 | Active   |  30 | 3.0.1                 | Apache Karaf :: Diagnostic :: Command
 58 | Active   |  30 | 3.0.1                 | Apache Karaf :: Log :: Core
 59 | Active   |  30 | 3.0.1                 | Apache Karaf :: Log :: Command
 60 | Active   |  30 | 3.0.1                 | Apache Karaf :: Service :: Core
 61 | Active   |  30 | 3.0.1                 | Apache Karaf :: Service :: Command
 62 | Active   |  30 | 3.0.1                 | Apache Karaf :: Package :: Core
 63 | Active   |  30 | 3.0.1                 | Apache Karaf :: Package :: Commands
 64 | Active   |  30 | 1.0.0.v20110524       | Region Digraph
 65 | Active   |  30 | 3.0.1                 | Apache Karaf :: Region :: Persistence
 66 | Active   |  30 | 3.0.1                 | Apache Karaf :: Region :: Shell Commands
 67 | Active   |  30 | 3.0.1                 | Apache Karaf :: KAR :: Core
 68 | Active   |  30 | 3.0.1                 | Apache Karaf :: KAR :: Command
 69 | Active   |  30 | 3.0.1                 | Apache Karaf :: Deployer :: Karaf Archive (.kar)
 70 | Active   |  30 | 2.0.7                 | Apache MINA Core
 71 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell :: SSH
 72 | Active   |  30 | 3.0.1                 | Apache Karaf :: Management
 73 | Active   |  30 | 1.1.0                 | Apache Aries JMX API
 74 | Active   |  30 | 1.1.1                 | Apache Aries JMX Core
 75 | Active   |  30 | 1.1.0                 | Apache Aries JMX Blueprint API
 76 | Active   |  30 | 1.1.0                 | Apache Aries JMX Blueprint Core
 77 | Active   |  30 | 1.0.0                 | Apache Aries JMX Whiteboard
 78 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | entity.definition
 79 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | couchbase-lite
 80 | Active   |  80 | 1.9.2                 | Data mapper for Jackson JSON processor
 81 | Active   |  80 | 3.7                   | or.apache.poi
 82 | Active   |  80 | 1.1.3                 | Commons Logging
 83 | Failure  |  80 | 0.0.1.BUILD-SNAPSHOT  | data
 84 | Active   |  80 | 1.9.2                 | Jackson JSON processor
 85 | Active   |  80 | 1.3                   | commons-codec
 86 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | stockcheck.definition
 87 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | sweelee.web
 88 | Active   |  80 | 2.4.0                 | XMLBeans Development Kit
 89 | Active   |  80 | 0.0.0                 | vaadin.xml
 90 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | import.definition
 91 | Active   |  80 | 1.6.1                 | dom4j DOM Processor
 92 | Active   |  30 | 2.2.0                 | Apache ServiceMix :: Specs :: Activation API 1.4
 93 | Active   |  30 | 1.0                   | Servlet 3.0
 94 | Active   |  30 | 1.4.4                 | JavaMail API (compat)
 95 | Active   |  30 | 1.1.1                 | geronimo-jta_1.1_spec
 96 | Active   |  30 | 1.0.1                 | Annotation 1.1
 97 | Active   |  30 | 1.1                   | Java Authentication SPI for Containers
 98 | Active   |  30 | 8.1.14.v20131031      | Jetty :: Aggregate :: All Server
 99 | Active   |  30 | 1.6.0                 | OPS4J Pax Swissbox :: OSGi Core
100 | Active   |  30 | 1.6.0                 | OPS4J Pax Swissbox :: Optional JCL
101 | Active   |  20 | 3.16.0                | Apache XBean OSGI Bundle Utilities
102 | Active   |  20 | 3.16.0                | Apache XBean :: ASM 4 shaded (repackaged)
103 | Active   |  20 | 3.16                  | Apache XBean :: Reflect
104 | Active   |  20 | 3.16.0                | Apache XBean :: Finder shaded (repackaged)
105 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - API
106 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Service SPI
107 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Runtime
108 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Jetty
109 | Active   |  30 | 3.0.1                 | Apache Karaf :: HTTP :: Core
110 | Active   |  30 | 3.0.1                 | Apache Karaf :: HTTP :: Commands
111 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Jsp Support
112 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Extender - Whiteboard
113 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Extender - WAR
114 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - FileInstall Deployer
115 | Active   |  30 | 1.4.2                 | OPS4J Pax Url - war
116 | Active   |  30 | 1.4.2                 | OPS4J Pax Url - Commons
117 | Active   |  30 | 1.6.0                 | OPS4J Pax Swissbox :: Bnd Utils
118 | Active   |  30 | 1.6.0                 | OPS4J Pax Swissbox :: Property
119 | Active   |  30 | 1.43.0                | aQute Bundle Tool Library
120 | Active   |  30 | 3.0.1                 | Apache Karaf :: Web :: Core
121 | Active   |  30 | 3.0.1                 | Apache Karaf :: Web :: Commands
122 | Active   |  80 | 7.1.15                | vaadin-server
123 | Active   |  80 | 7.1.15                | vaadin-client-compiled
124 | Active   |  80 | 7.1.15                | vaadin-shared
125 | Active   |  80 | 1.0.2                 | vaadin-shared-deps
126 | Active   |  80 | 7.1.15                | vaadin-themes
127 | Active   |  80 | 1.6.3                 | jsoup
128 | Active   |  30 | 1.0.0.6               | Apache ServiceMix :: Bundles :: aopalliance
129 | Active   |  30 | 3.2.4.RELEASE         | Spring Core
130 | Active   |  30 | 3.2.4.RELEASE         | Spring Expression Language
131 | Active   |  30 | 3.2.4.RELEASE         | Spring Beans
132 | Active   |  30 | 3.2.4.RELEASE         | Spring AOP
133 | Active   |  30 | 3.2.4.RELEASE         | Spring Context
134 | Active   |  30 | 3.2.4.RELEASE         | Spring Context Support
135 | Active   |  30 | 3.0.0.1               | Apache ServiceMix :: Bundles :: cglib
136 | Active   |  30 | 1.2.1                 | spring-osgi-io
137 | Active   |  30 | 1.2.1                 | spring-osgi-core
138 | Active   |  30 | 1.2.1                 | spring-osgi-extender
139 | Active   |  30 | 1.2.1                 | spring-osgi-annotation
140 | Active   |  30 | 3.0.1                 | Apache Karaf :: Bundle :: SpringStateService
141 | Active   |  30 | 3.2.4.RELEASE         | Spring Web
142 | Active   |  30 | 3.2.4.RELEASE         | Spring Web Servlet
143 | Active   |  30 | 1.2.1                 | spring-osgi-web


The spring application is #83 (enigmatically called "data") and has a Spring-DM configuration file which just creates a JavaConfig bean, one of which is being instantiated twice. I put some logging into this bean definition:
System.out.println("Making a database from: "+ Thread.currentThread().getContextClassLoader());
On the second load of Karaf, this line appears twice with "Making a database from: BundleDelegatingClassLoader for [null (data)]" for both outputs, the second of which throws the UnsatisfiedLinkException and fails to load the bundle. If I stop and start the bundle again, the same thing happens. If I rm -rf data and re-run Karaf the application works fine after installing the necessary features.

Any suggestions?
Best, Dan.




Re: Multiple spring deployers?

Posted by Charlie Mordant <cm...@gmail.com>.
So, to complete my previous post, eclipse gemini could also handle
spring-dm namespaces, but it looks like you're not using it.
If you really want to have a spring architecture backed with spring, you
should go in this way, as gemini is the natural spring-dm successor (sorry
my aries companions).
In the other way, Aries is much more mature, so if you're not tied to
spring, go for it!

Regards again...


2014-05-20 22:45 GMT+02:00 Charlie Mordant <cm...@gmail.com>:

> Hi,
>
> I don't think blueprint could take your config as you're using spring-dm
> namespace.
> As an advice, I would consider migrating from spring-dm to blueprint, as
> the jars are no longer supported and fairly unstable (I encountered many
> issues using them).
> Concerning the first to other launch ok/nok, can you look at duplicate
> package export (i.e. some jetty packages that are not in the same
> version...).
> I 'don't know if there is a simple grep command to see this kind of common
> problem I faced multiple times, maybe JB can answer this :).
>
> Regards, Charlie
>
>
> 2014-05-20 18:20 GMT+02:00 Dan <d....@gmail.com>:
>
> Hi again,
>>
>> Could spring-dm and spring-dm-web both be picking up the spring
>> configuration? It's in META-INF/osgi-config.xml and looks like this:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <beans xmlns="http://www.springframework.org/schema/beans"
>>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>  xsi:schemaLocation="http://www.springframework.org/schema/beans
>> http://www.springframework.org/schema/beans/spring-beans.xsd
>>  http://www.springframework.org/schema/context
>> http://www.springframework.org/schema/context/spring-context.xsd
>>  http://www.springframework.org/schema/osgi
>> http://www.springframework.org/schema/osgi/spring-osgi.xsd"
>>  xmlns:context="http://www.springframework.org/schema/context"
>>  xmlns:osgi="http://www.springframework.org/schema/osgi">
>>
>>  <context:annotation-config/>
>>  <bean class="data.Configuration"></bean> <!-- The JavaConfig class -->
>>  <osgi:service ref="database" auto-export="interfaces"></osgi:service>
>> </beans>
>>
>> Alternatively, could the blueprint extender be picking up this bundle?
>>
>> Why only subsequent launches, not the first?
>>
>> Many thanks for any support offered,
>> Dan.
>>
>> On 20 May 2014, at 16:31, Daniel McGreal wrote:
>>
>> Hi Karaf users,
>>
>> I have a Spring bundle which calls a third party library which itself
>> calls a native library. Because of some unfortunate yet understandable
>> decisions of the third party, I cannot have a @Bean created more than once.
>>
>> What's happening for me is that the first load of Karaf and
>> initialisation of my bundles, everything works fine. But on the second
>> load, I hit UnsatisfiedLinkExceptions with the message that "already loaded
>> in another classloader".
>>
>> It seems that somehow after the first successful run, my Spring
>> configuration is being loaded twice.
>>
>> My bundles:
>>
>> list -t 0
>> START LEVEL 100 , List Threshold: 0
>>  ID | State    | Lvl | Version               | Name
>>
>> ------------------------------------------------------------------------------------------------------------------
>>   0 | Active   |   0 | 4.2.1                 | System Bundle
>>   1 | Active   |   5 | 1.4.0                 | OPS4J Base - Lang
>>   2 | Active   |   5 | 2.2.0.20130927-173417 | bndlib
>>   3 | Active   |   5 | 1.7.0                 | OPS4J Pax Swissbox :: Bnd
>> Utils
>>   4 | Active   |   5 | 1.6.0                 | OPS4J Pax Url - Maven
>> Commons
>>   5 | Active   |   5 | 1.6.0                 | OPS4J Pax Url - aether:
>>   6 | Active   |   5 | 1.6.0                 | OPS4J Pax Url - wrap:
>>   7 | Active   |   8 | 1.7.2                 | OPS4J Pax Logging - API
>>   8 | Active   |   8 | 1.7.2                 | OPS4J Pax Logging - Service
>>   9 | Active   |  10 | 3.0.1                 | Apache Karaf :: Service ::
>> Guard
>>  10 | Active   |  10 | 1.6.0                 | Apache Felix Configuration
>> Admin Service
>>  11 | Active   |  11 | 3.2.8                 | Apache Felix File Install
>>  12 | Active   |  12 | 4.1                   | ASM all classes with debug
>> info
>>  13 | Active   |  20 | 1.1.0                 | Apache Aries Util
>>  14 | Active   |  20 | 1.0.0                 | Apache Aries Proxy API
>>  15 | Active   |  20 | 1.0.2                 | Apache Aries Proxy Service
>>  16 | Active   |  20 | 1.0.0                 | Apache Aries Blueprint API
>>  17 | Active   |  20 | 1.0.3                 | Apache Aries Blueprint CM
>>  18 | Resolved |  20 | 1.0.0                 | Apache Aries Blueprint
>> Core Compatiblity Fragment Bundle, Hosts: 19
>>  19 | Active   |  20 | 1.4.0                 | Apache Aries Blueprint
>> Core, Fragments: 18
>>  20 | Active   |  24 | 3.0.1                 | Apache Karaf :: Deployer
>> :: Spring
>>  21 | Active   |  24 | 3.0.1                 | Apache Karaf :: Deployer
>> :: Blueprint
>>  22 | Active   |  24 | 3.0.1                 | Apache Karaf :: Deployer
>> :: Wrap Non OSGi Jar
>>  23 | Active   |  25 | 3.0.1                 | Apache Karaf :: Region ::
>> Core
>>  24 | Active   |  25 | 3.0.1                 | Apache Karaf :: Features
>> :: Core
>>  25 | Active   |  26 | 3.0.1                 | Apache Karaf :: Deployer
>> :: Features
>>  26 | Active   |  30 | 2.11.0                | JLine
>>  27 | Active   |  30 | 0.2.1                 | JLEdit :: Core
>>  28 | Active   |  30 | 1.11                  | jansi
>>  29 | Active   |  30 | 1.4.0                 | OPS4J Base - Util -
>> Property
>>  30 | Active   |  30 | 1.4.0                 | OPS4J Base - Util - XML
>>  31 | Active   |  30 | 1.4.0                 | OPS4J Base - Util -
>> Collections
>>  32 | Active   |  30 | 1.6.0                 | OPS4J Pax Url - Commons
>>  33 | Active   |  30 | 1.7.0                 | OPS4J Pax Swissbox ::
>> Property
>>  34 | Active   |  30 | 1.4.0                 | OPS4J Base - Net
>>  35 | Active   |  30 | 1.4.0                 | OPS4J Base - Monitors
>>  36 | Active   |  30 | 3.0.1                 | Apache Karaf :: Features
>> :: Command
>>  37 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell ::
>> Console
>>  38 | Active   |  30 | 3.0.1                 | Apache Karaf :: JAAS ::
>> Modules
>>  39 | Active   |  30 | 3.0.1                 | Apache Karaf :: JAAS ::
>> Config
>>  40 | Active   |  30 | 3.0.1                 | Apache Karaf :: JAAS ::
>> Boot
>>  41 | Active   |  30 | 0.9.0                 | Apache Mina SSHD :: Core
>>  42 | Active   |  30 | 3.0.1                 | Apache Karaf :: Bundle ::
>> Commands
>>  43 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell ::
>> Table
>>  44 | Active   |  30 | 3.0.1                 | Apache Karaf :: Bundle ::
>> Core
>>  45 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell ::
>> Help System
>>  46 | Active   |  30 | 3.0.1                 | Apache Karaf :: System ::
>> Core
>>  47 | Active   |  30 | 3.0.1                 | Apache Karaf :: System ::
>> Shell Commands
>>  48 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell ::
>> Various Commands
>>  49 | Active   |  30 | 1.0.0                 | Apache Aries Quiesce API
>>  50 | Active   |  30 | 3.0.1                 | Apache Karaf ::
>> ConfigAdmin :: Core
>>  51 | Active   |  30 | 3.0.1                 | Apache Karaf ::
>> ConfigAdmin :: Commands
>>  52 | Active   |  30 | 0.10.0                | Apache Felix Gogo Runtime
>>  53 | Active   |  30 | 3.0.1                 | Apache Karaf :: Instance
>> :: Core
>>  54 | Active   |  30 | 3.0.1                 | Apache Karaf :: Instance
>> :: Command
>>  55 | Active   |  30 | 3.0.1                 | Apache Karaf :: JAAS ::
>> Command
>>  56 | Active   |  30 | 3.0.1                 | Apache Karaf :: Diagnostic
>> :: Core
>>  57 | Active   |  30 | 3.0.1                 | Apache Karaf :: Diagnostic
>> :: Command
>>  58 | Active   |  30 | 3.0.1                 | Apache Karaf :: Log :: Core
>>  59 | Active   |  30 | 3.0.1                 | Apache Karaf :: Log ::
>> Command
>>  60 | Active   |  30 | 3.0.1                 | Apache Karaf :: Service ::
>> Core
>>  61 | Active   |  30 | 3.0.1                 | Apache Karaf :: Service ::
>> Command
>>  62 | Active   |  30 | 3.0.1                 | Apache Karaf :: Package ::
>> Core
>>  63 | Active   |  30 | 3.0.1                 | Apache Karaf :: Package ::
>> Commands
>>  64 | Active   |  30 | 1.0.0.v20110524       | Region Digraph
>>  65 | Active   |  30 | 3.0.1                 | Apache Karaf :: Region ::
>> Persistence
>>  66 | Active   |  30 | 3.0.1                 | Apache Karaf :: Region ::
>> Shell Commands
>>  67 | Active   |  30 | 3.0.1                 | Apache Karaf :: KAR :: Core
>>  68 | Active   |  30 | 3.0.1                 | Apache Karaf :: KAR ::
>> Command
>>  69 | Active   |  30 | 3.0.1                 | Apache Karaf :: Deployer
>> :: Karaf Archive (.kar)
>>  70 | Active   |  30 | 2.0.7                 | Apache MINA Core
>>  71 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell ::
>> SSH
>>  72 | Active   |  30 | 3.0.1                 | Apache Karaf :: Management
>>  73 | Active   |  30 | 1.1.0                 | Apache Aries JMX API
>>  74 | Active   |  30 | 1.1.1                 | Apache Aries JMX Core
>>  75 | Active   |  30 | 1.1.0                 | Apache Aries JMX Blueprint
>> API
>>  76 | Active   |  30 | 1.1.0                 | Apache Aries JMX Blueprint
>> Core
>>  77 | Active   |  30 | 1.0.0                 | Apache Aries JMX Whiteboard
>>  78 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | entity.definition
>>  79 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | couchbase-lite
>>  80 | Active   |  80 | 1.9.2                 | Data mapper for Jackson
>> JSON processor
>>  81 | Active   |  80 | 3.7                   | or.apache.poi
>>  82 | Active   |  80 | 1.1.3                 | Commons Logging
>>  83 | Failure  |  80 | 0.0.1.BUILD-SNAPSHOT  | data
>>  84 | Active   |  80 | 1.9.2                 | Jackson JSON processor
>>  85 | Active   |  80 | 1.3                   | commons-codec
>>  86 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | stockcheck.definition
>>  87 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | sweelee.web
>>  88 | Active   |  80 | 2.4.0                 | XMLBeans Development Kit
>>  89 | Active   |  80 | 0.0.0                 | vaadin.xml
>>  90 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | import.definition
>>  91 | Active   |  80 | 1.6.1                 | dom4j DOM Processor
>>  92 | Active   |  30 | 2.2.0                 | Apache ServiceMix :: Specs
>> :: Activation API 1.4
>>  93 | Active   |  30 | 1.0                   | Servlet 3.0
>>  94 | Active   |  30 | 1.4.4                 | JavaMail API (compat)
>>  95 | Active   |  30 | 1.1.1                 | geronimo-jta_1.1_spec
>>  96 | Active   |  30 | 1.0.1                 | Annotation 1.1
>>  97 | Active   |  30 | 1.1                   | Java Authentication SPI
>> for Containers
>>  98 | Active   |  30 | 8.1.14.v20131031      | Jetty :: Aggregate :: All
>> Server
>>  99 | Active   |  30 | 1.6.0                 | OPS4J Pax Swissbox :: OSGi
>> Core
>> 100 | Active   |  30 | 1.6.0                 | OPS4J Pax Swissbox ::
>> Optional JCL
>> 101 | Active   |  20 | 3.16.0                | Apache XBean OSGI Bundle
>> Utilities
>> 102 | Active   |  20 | 3.16.0                | Apache XBean :: ASM 4
>> shaded (repackaged)
>> 103 | Active   |  20 | 3.16                  | Apache XBean :: Reflect
>> 104 | Active   |  20 | 3.16.0                | Apache XBean :: Finder
>> shaded (repackaged)
>> 105 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - API
>> 106 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Service SPI
>> 107 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Runtime
>> 108 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Jetty
>> 109 | Active   |  30 | 3.0.1                 | Apache Karaf :: HTTP ::
>> Core
>> 110 | Active   |  30 | 3.0.1                 | Apache Karaf :: HTTP ::
>> Commands
>> 111 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Jsp Support
>> 112 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Extender -
>> Whiteboard
>> 113 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Extender -
>> WAR
>> 114 | Active   |  30 | 3.1.0                 | OPS4J Pax Web -
>> FileInstall Deployer
>> 115 | Active   |  30 | 1.4.2                 | OPS4J Pax Url - war
>> 116 | Active   |  30 | 1.4.2                 | OPS4J Pax Url - Commons
>> 117 | Active   |  30 | 1.6.0                 | OPS4J Pax Swissbox :: Bnd
>> Utils
>> 118 | Active   |  30 | 1.6.0                 | OPS4J Pax Swissbox ::
>> Property
>> 119 | Active   |  30 | 1.43.0                | aQute Bundle Tool Library
>> 120 | Active   |  30 | 3.0.1                 | Apache Karaf :: Web :: Core
>> 121 | Active   |  30 | 3.0.1                 | Apache Karaf :: Web ::
>> Commands
>> 122 | Active   |  80 | 7.1.15                | vaadin-server
>> 123 | Active   |  80 | 7.1.15                | vaadin-client-compiled
>> 124 | Active   |  80 | 7.1.15                | vaadin-shared
>> 125 | Active   |  80 | 1.0.2                 | vaadin-shared-deps
>> 126 | Active   |  80 | 7.1.15                | vaadin-themes
>> 127 | Active   |  80 | 1.6.3                 | jsoup
>> 128 | Active   |  30 | 1.0.0.6               | Apache ServiceMix ::
>> Bundles :: aopalliance
>> 129 | Active   |  30 | 3.2.4.RELEASE         | Spring Core
>> 130 | Active   |  30 | 3.2.4.RELEASE         | Spring Expression Language
>> 131 | Active   |  30 | 3.2.4.RELEASE         | Spring Beans
>> 132 | Active   |  30 | 3.2.4.RELEASE         | Spring AOP
>> 133 | Active   |  30 | 3.2.4.RELEASE         | Spring Context
>> 134 | Active   |  30 | 3.2.4.RELEASE         | Spring Context Support
>> 135 | Active   |  30 | 3.0.0.1               | Apache ServiceMix ::
>> Bundles :: cglib
>> 136 | Active   |  30 | 1.2.1                 | spring-osgi-io
>> 137 | Active   |  30 | 1.2.1                 | spring-osgi-core
>> 138 | Active   |  30 | 1.2.1                 | spring-osgi-extender
>> 139 | Active   |  30 | 1.2.1                 | spring-osgi-annotation
>> 140 | Active   |  30 | 3.0.1                 | Apache Karaf :: Bundle ::
>> SpringStateService
>> 141 | Active   |  30 | 3.2.4.RELEASE         | Spring Web
>> 142 | Active   |  30 | 3.2.4.RELEASE         | Spring Web Servlet
>> 143 | Active   |  30 | 1.2.1                 | spring-osgi-web
>>
>>
>> The spring application is #83 (enigmatically called "data") and has a
>> Spring-DM configuration file which just creates a JavaConfig bean, one of
>> which is being instantiated twice. I put some logging into this bean
>> definition:
>> System.out.println("Making a database from: "+
>> Thread.currentThread().getContextClassLoader());
>> On the second load of Karaf, this line appears twice with "Making a
>> database from: BundleDelegatingClassLoader for [null (data)]" for both
>> outputs, the second of which throws the UnsatisfiedLinkException and fails
>> to load the bundle. If I stop and start the bundle again, the same thing
>> happens. If I rm -rf data and re-run Karaf the application works fine after
>> installing the necessary features.
>>
>> Any suggestions?
>> Best, Dan.
>>
>>
>>
>>
>>
>

Re: Multiple spring deployers?

Posted by Charlie Mordant <cm...@gmail.com>.
Hi,

I don't think blueprint could take your config as you're using spring-dm
namespace.
As an advice, I would consider migrating from spring-dm to blueprint, as
the jars are no longer supported and fairly unstable (I encountered many
issues using them).
Concerning the first to other launch ok/nok, can you look at duplicate
package export (i.e. some jetty packages that are not in the same
version...).
I 'don't know if there is a simple grep command to see this kind of common
problem I faced multiple times, maybe JB can answer this :).

Regards, Charlie


2014-05-20 18:20 GMT+02:00 Dan <d....@gmail.com>:

> Hi again,
>
> Could spring-dm and spring-dm-web both be picking up the spring
> configuration? It's in META-INF/osgi-config.xml and looks like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
> http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context.xsd
> http://www.springframework.org/schema/osgi
> http://www.springframework.org/schema/osgi/spring-osgi.xsd"
> xmlns:context="http://www.springframework.org/schema/context"
> xmlns:osgi="http://www.springframework.org/schema/osgi">
>
> <context:annotation-config/>
> <bean class="data.Configuration"></bean> <!-- The JavaConfig class -->
> <osgi:service ref="database" auto-export="interfaces"></osgi:service>
> </beans>
>
> Alternatively, could the blueprint extender be picking up this bundle?
>
> Why only subsequent launches, not the first?
>
> Many thanks for any support offered,
> Dan.
>
> On 20 May 2014, at 16:31, Daniel McGreal wrote:
>
> Hi Karaf users,
>
> I have a Spring bundle which calls a third party library which itself
> calls a native library. Because of some unfortunate yet understandable
> decisions of the third party, I cannot have a @Bean created more than once.
>
> What's happening for me is that the first load of Karaf and initialisation
> of my bundles, everything works fine. But on the second load, I hit
> UnsatisfiedLinkExceptions with the message that "already loaded in another
> classloader".
>
> It seems that somehow after the first successful run, my Spring
> configuration is being loaded twice.
>
> My bundles:
>
> list -t 0
> START LEVEL 100 , List Threshold: 0
>  ID | State    | Lvl | Version               | Name
>
> ------------------------------------------------------------------------------------------------------------------
>   0 | Active   |   0 | 4.2.1                 | System Bundle
>   1 | Active   |   5 | 1.4.0                 | OPS4J Base - Lang
>   2 | Active   |   5 | 2.2.0.20130927-173417 | bndlib
>   3 | Active   |   5 | 1.7.0                 | OPS4J Pax Swissbox :: Bnd
> Utils
>   4 | Active   |   5 | 1.6.0                 | OPS4J Pax Url - Maven
> Commons
>   5 | Active   |   5 | 1.6.0                 | OPS4J Pax Url - aether:
>   6 | Active   |   5 | 1.6.0                 | OPS4J Pax Url - wrap:
>   7 | Active   |   8 | 1.7.2                 | OPS4J Pax Logging - API
>   8 | Active   |   8 | 1.7.2                 | OPS4J Pax Logging - Service
>   9 | Active   |  10 | 3.0.1                 | Apache Karaf :: Service ::
> Guard
>  10 | Active   |  10 | 1.6.0                 | Apache Felix Configuration
> Admin Service
>  11 | Active   |  11 | 3.2.8                 | Apache Felix File Install
>  12 | Active   |  12 | 4.1                   | ASM all classes with debug
> info
>  13 | Active   |  20 | 1.1.0                 | Apache Aries Util
>  14 | Active   |  20 | 1.0.0                 | Apache Aries Proxy API
>  15 | Active   |  20 | 1.0.2                 | Apache Aries Proxy Service
>  16 | Active   |  20 | 1.0.0                 | Apache Aries Blueprint API
>  17 | Active   |  20 | 1.0.3                 | Apache Aries Blueprint CM
>  18 | Resolved |  20 | 1.0.0                 | Apache Aries Blueprint Core
> Compatiblity Fragment Bundle, Hosts: 19
>  19 | Active   |  20 | 1.4.0                 | Apache Aries Blueprint
> Core, Fragments: 18
>  20 | Active   |  24 | 3.0.1                 | Apache Karaf :: Deployer ::
> Spring
>  21 | Active   |  24 | 3.0.1                 | Apache Karaf :: Deployer ::
> Blueprint
>  22 | Active   |  24 | 3.0.1                 | Apache Karaf :: Deployer ::
> Wrap Non OSGi Jar
>  23 | Active   |  25 | 3.0.1                 | Apache Karaf :: Region ::
> Core
>  24 | Active   |  25 | 3.0.1                 | Apache Karaf :: Features ::
> Core
>  25 | Active   |  26 | 3.0.1                 | Apache Karaf :: Deployer ::
> Features
>  26 | Active   |  30 | 2.11.0                | JLine
>  27 | Active   |  30 | 0.2.1                 | JLEdit :: Core
>  28 | Active   |  30 | 1.11                  | jansi
>  29 | Active   |  30 | 1.4.0                 | OPS4J Base - Util - Property
>  30 | Active   |  30 | 1.4.0                 | OPS4J Base - Util - XML
>  31 | Active   |  30 | 1.4.0                 | OPS4J Base - Util -
> Collections
>  32 | Active   |  30 | 1.6.0                 | OPS4J Pax Url - Commons
>  33 | Active   |  30 | 1.7.0                 | OPS4J Pax Swissbox ::
> Property
>  34 | Active   |  30 | 1.4.0                 | OPS4J Base - Net
>  35 | Active   |  30 | 1.4.0                 | OPS4J Base - Monitors
>  36 | Active   |  30 | 3.0.1                 | Apache Karaf :: Features ::
> Command
>  37 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell ::
> Console
>  38 | Active   |  30 | 3.0.1                 | Apache Karaf :: JAAS ::
> Modules
>  39 | Active   |  30 | 3.0.1                 | Apache Karaf :: JAAS ::
> Config
>  40 | Active   |  30 | 3.0.1                 | Apache Karaf :: JAAS :: Boot
>  41 | Active   |  30 | 0.9.0                 | Apache Mina SSHD :: Core
>  42 | Active   |  30 | 3.0.1                 | Apache Karaf :: Bundle ::
> Commands
>  43 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell ::
> Table
>  44 | Active   |  30 | 3.0.1                 | Apache Karaf :: Bundle ::
> Core
>  45 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell ::
> Help System
>  46 | Active   |  30 | 3.0.1                 | Apache Karaf :: System ::
> Core
>  47 | Active   |  30 | 3.0.1                 | Apache Karaf :: System ::
> Shell Commands
>  48 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell ::
> Various Commands
>  49 | Active   |  30 | 1.0.0                 | Apache Aries Quiesce API
>  50 | Active   |  30 | 3.0.1                 | Apache Karaf :: ConfigAdmin
> :: Core
>  51 | Active   |  30 | 3.0.1                 | Apache Karaf :: ConfigAdmin
> :: Commands
>  52 | Active   |  30 | 0.10.0                | Apache Felix Gogo Runtime
>  53 | Active   |  30 | 3.0.1                 | Apache Karaf :: Instance ::
> Core
>  54 | Active   |  30 | 3.0.1                 | Apache Karaf :: Instance ::
> Command
>  55 | Active   |  30 | 3.0.1                 | Apache Karaf :: JAAS ::
> Command
>  56 | Active   |  30 | 3.0.1                 | Apache Karaf :: Diagnostic
> :: Core
>  57 | Active   |  30 | 3.0.1                 | Apache Karaf :: Diagnostic
> :: Command
>  58 | Active   |  30 | 3.0.1                 | Apache Karaf :: Log :: Core
>  59 | Active   |  30 | 3.0.1                 | Apache Karaf :: Log ::
> Command
>  60 | Active   |  30 | 3.0.1                 | Apache Karaf :: Service ::
> Core
>  61 | Active   |  30 | 3.0.1                 | Apache Karaf :: Service ::
> Command
>  62 | Active   |  30 | 3.0.1                 | Apache Karaf :: Package ::
> Core
>  63 | Active   |  30 | 3.0.1                 | Apache Karaf :: Package ::
> Commands
>  64 | Active   |  30 | 1.0.0.v20110524       | Region Digraph
>  65 | Active   |  30 | 3.0.1                 | Apache Karaf :: Region ::
> Persistence
>  66 | Active   |  30 | 3.0.1                 | Apache Karaf :: Region ::
> Shell Commands
>  67 | Active   |  30 | 3.0.1                 | Apache Karaf :: KAR :: Core
>  68 | Active   |  30 | 3.0.1                 | Apache Karaf :: KAR ::
> Command
>  69 | Active   |  30 | 3.0.1                 | Apache Karaf :: Deployer ::
> Karaf Archive (.kar)
>  70 | Active   |  30 | 2.0.7                 | Apache MINA Core
>  71 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell :: SSH
>  72 | Active   |  30 | 3.0.1                 | Apache Karaf :: Management
>  73 | Active   |  30 | 1.1.0                 | Apache Aries JMX API
>  74 | Active   |  30 | 1.1.1                 | Apache Aries JMX Core
>  75 | Active   |  30 | 1.1.0                 | Apache Aries JMX Blueprint
> API
>  76 | Active   |  30 | 1.1.0                 | Apache Aries JMX Blueprint
> Core
>  77 | Active   |  30 | 1.0.0                 | Apache Aries JMX Whiteboard
>  78 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | entity.definition
>  79 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | couchbase-lite
>  80 | Active   |  80 | 1.9.2                 | Data mapper for Jackson
> JSON processor
>  81 | Active   |  80 | 3.7                   | or.apache.poi
>  82 | Active   |  80 | 1.1.3                 | Commons Logging
>  83 | Failure  |  80 | 0.0.1.BUILD-SNAPSHOT  | data
>  84 | Active   |  80 | 1.9.2                 | Jackson JSON processor
>  85 | Active   |  80 | 1.3                   | commons-codec
>  86 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | stockcheck.definition
>  87 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | sweelee.web
>  88 | Active   |  80 | 2.4.0                 | XMLBeans Development Kit
>  89 | Active   |  80 | 0.0.0                 | vaadin.xml
>  90 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | import.definition
>  91 | Active   |  80 | 1.6.1                 | dom4j DOM Processor
>  92 | Active   |  30 | 2.2.0                 | Apache ServiceMix :: Specs
> :: Activation API 1.4
>  93 | Active   |  30 | 1.0                   | Servlet 3.0
>  94 | Active   |  30 | 1.4.4                 | JavaMail API (compat)
>  95 | Active   |  30 | 1.1.1                 | geronimo-jta_1.1_spec
>  96 | Active   |  30 | 1.0.1                 | Annotation 1.1
>  97 | Active   |  30 | 1.1                   | Java Authentication SPI for
> Containers
>  98 | Active   |  30 | 8.1.14.v20131031      | Jetty :: Aggregate :: All
> Server
>  99 | Active   |  30 | 1.6.0                 | OPS4J Pax Swissbox :: OSGi
> Core
> 100 | Active   |  30 | 1.6.0                 | OPS4J Pax Swissbox ::
> Optional JCL
> 101 | Active   |  20 | 3.16.0                | Apache XBean OSGI Bundle
> Utilities
> 102 | Active   |  20 | 3.16.0                | Apache XBean :: ASM 4
> shaded (repackaged)
> 103 | Active   |  20 | 3.16                  | Apache XBean :: Reflect
> 104 | Active   |  20 | 3.16.0                | Apache XBean :: Finder
> shaded (repackaged)
> 105 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - API
> 106 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Service SPI
> 107 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Runtime
> 108 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Jetty
> 109 | Active   |  30 | 3.0.1                 | Apache Karaf :: HTTP :: Core
> 110 | Active   |  30 | 3.0.1                 | Apache Karaf :: HTTP ::
> Commands
> 111 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Jsp Support
> 112 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Extender -
> Whiteboard
> 113 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Extender -
> WAR
> 114 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - FileInstall
> Deployer
> 115 | Active   |  30 | 1.4.2                 | OPS4J Pax Url - war
> 116 | Active   |  30 | 1.4.2                 | OPS4J Pax Url - Commons
> 117 | Active   |  30 | 1.6.0                 | OPS4J Pax Swissbox :: Bnd
> Utils
> 118 | Active   |  30 | 1.6.0                 | OPS4J Pax Swissbox ::
> Property
> 119 | Active   |  30 | 1.43.0                | aQute Bundle Tool Library
> 120 | Active   |  30 | 3.0.1                 | Apache Karaf :: Web :: Core
> 121 | Active   |  30 | 3.0.1                 | Apache Karaf :: Web ::
> Commands
> 122 | Active   |  80 | 7.1.15                | vaadin-server
> 123 | Active   |  80 | 7.1.15                | vaadin-client-compiled
> 124 | Active   |  80 | 7.1.15                | vaadin-shared
> 125 | Active   |  80 | 1.0.2                 | vaadin-shared-deps
> 126 | Active   |  80 | 7.1.15                | vaadin-themes
> 127 | Active   |  80 | 1.6.3                 | jsoup
> 128 | Active   |  30 | 1.0.0.6               | Apache ServiceMix ::
> Bundles :: aopalliance
> 129 | Active   |  30 | 3.2.4.RELEASE         | Spring Core
> 130 | Active   |  30 | 3.2.4.RELEASE         | Spring Expression Language
> 131 | Active   |  30 | 3.2.4.RELEASE         | Spring Beans
> 132 | Active   |  30 | 3.2.4.RELEASE         | Spring AOP
> 133 | Active   |  30 | 3.2.4.RELEASE         | Spring Context
> 134 | Active   |  30 | 3.2.4.RELEASE         | Spring Context Support
> 135 | Active   |  30 | 3.0.0.1               | Apache ServiceMix ::
> Bundles :: cglib
> 136 | Active   |  30 | 1.2.1                 | spring-osgi-io
> 137 | Active   |  30 | 1.2.1                 | spring-osgi-core
> 138 | Active   |  30 | 1.2.1                 | spring-osgi-extender
> 139 | Active   |  30 | 1.2.1                 | spring-osgi-annotation
> 140 | Active   |  30 | 3.0.1                 | Apache Karaf :: Bundle ::
> SpringStateService
> 141 | Active   |  30 | 3.2.4.RELEASE         | Spring Web
> 142 | Active   |  30 | 3.2.4.RELEASE         | Spring Web Servlet
> 143 | Active   |  30 | 1.2.1                 | spring-osgi-web
>
>
> The spring application is #83 (enigmatically called "data") and has a
> Spring-DM configuration file which just creates a JavaConfig bean, one of
> which is being instantiated twice. I put some logging into this bean
> definition:
> System.out.println("Making a database from: "+
> Thread.currentThread().getContextClassLoader());
> On the second load of Karaf, this line appears twice with "Making a
> database from: BundleDelegatingClassLoader for [null (data)]" for both
> outputs, the second of which throws the UnsatisfiedLinkException and fails
> to load the bundle. If I stop and start the bundle again, the same thing
> happens. If I rm -rf data and re-run Karaf the application works fine after
> installing the necessary features.
>
> Any suggestions?
> Best, Dan.
>
>
>
>
>

Re: Multiple spring deployers?

Posted by Dan <d....@gmail.com>.
Hi again,

Could spring-dm and spring-dm-web both be picking up the spring configuration? It's in META-INF/osgi-config.xml and looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
		http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:osgi="http://www.springframework.org/schema/osgi">

	<context:annotation-config/>
	<bean class="data.Configuration"></bean> <!-- The JavaConfig class -->
	<osgi:service ref="database" auto-export="interfaces"></osgi:service>
</beans>

Alternatively, could the blueprint extender be picking up this bundle?

Why only subsequent launches, not the first?

Many thanks for any support offered,
Dan.

On 20 May 2014, at 16:31, Daniel McGreal wrote:

> Hi Karaf users,
> 
> I have a Spring bundle which calls a third party library which itself calls a native library. Because of some unfortunate yet understandable decisions of the third party, I cannot have a @Bean created more than once.
> 
> What's happening for me is that the first load of Karaf and initialisation of my bundles, everything works fine. But on the second load, I hit UnsatisfiedLinkExceptions with the message that "already loaded in another classloader".
> 
> It seems that somehow after the first successful run, my Spring configuration is being loaded twice.
> 
> My bundles:
> 
> list -t 0
> START LEVEL 100 , List Threshold: 0
>  ID | State    | Lvl | Version               | Name
> ------------------------------------------------------------------------------------------------------------------
>   0 | Active   |   0 | 4.2.1                 | System Bundle
>   1 | Active   |   5 | 1.4.0                 | OPS4J Base - Lang
>   2 | Active   |   5 | 2.2.0.20130927-173417 | bndlib
>   3 | Active   |   5 | 1.7.0                 | OPS4J Pax Swissbox :: Bnd Utils
>   4 | Active   |   5 | 1.6.0                 | OPS4J Pax Url - Maven Commons
>   5 | Active   |   5 | 1.6.0                 | OPS4J Pax Url - aether:
>   6 | Active   |   5 | 1.6.0                 | OPS4J Pax Url - wrap:
>   7 | Active   |   8 | 1.7.2                 | OPS4J Pax Logging - API
>   8 | Active   |   8 | 1.7.2                 | OPS4J Pax Logging - Service
>   9 | Active   |  10 | 3.0.1                 | Apache Karaf :: Service :: Guard
>  10 | Active   |  10 | 1.6.0                 | Apache Felix Configuration Admin Service
>  11 | Active   |  11 | 3.2.8                 | Apache Felix File Install
>  12 | Active   |  12 | 4.1                   | ASM all classes with debug info
>  13 | Active   |  20 | 1.1.0                 | Apache Aries Util
>  14 | Active   |  20 | 1.0.0                 | Apache Aries Proxy API
>  15 | Active   |  20 | 1.0.2                 | Apache Aries Proxy Service
>  16 | Active   |  20 | 1.0.0                 | Apache Aries Blueprint API
>  17 | Active   |  20 | 1.0.3                 | Apache Aries Blueprint CM
>  18 | Resolved |  20 | 1.0.0                 | Apache Aries Blueprint Core Compatiblity Fragment Bundle, Hosts: 19
>  19 | Active   |  20 | 1.4.0                 | Apache Aries Blueprint Core, Fragments: 18
>  20 | Active   |  24 | 3.0.1                 | Apache Karaf :: Deployer :: Spring
>  21 | Active   |  24 | 3.0.1                 | Apache Karaf :: Deployer :: Blueprint
>  22 | Active   |  24 | 3.0.1                 | Apache Karaf :: Deployer :: Wrap Non OSGi Jar
>  23 | Active   |  25 | 3.0.1                 | Apache Karaf :: Region :: Core
>  24 | Active   |  25 | 3.0.1                 | Apache Karaf :: Features :: Core
>  25 | Active   |  26 | 3.0.1                 | Apache Karaf :: Deployer :: Features
>  26 | Active   |  30 | 2.11.0                | JLine
>  27 | Active   |  30 | 0.2.1                 | JLEdit :: Core
>  28 | Active   |  30 | 1.11                  | jansi
>  29 | Active   |  30 | 1.4.0                 | OPS4J Base - Util - Property
>  30 | Active   |  30 | 1.4.0                 | OPS4J Base - Util - XML
>  31 | Active   |  30 | 1.4.0                 | OPS4J Base - Util - Collections
>  32 | Active   |  30 | 1.6.0                 | OPS4J Pax Url - Commons
>  33 | Active   |  30 | 1.7.0                 | OPS4J Pax Swissbox :: Property
>  34 | Active   |  30 | 1.4.0                 | OPS4J Base - Net
>  35 | Active   |  30 | 1.4.0                 | OPS4J Base - Monitors
>  36 | Active   |  30 | 3.0.1                 | Apache Karaf :: Features :: Command
>  37 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell :: Console
>  38 | Active   |  30 | 3.0.1                 | Apache Karaf :: JAAS :: Modules
>  39 | Active   |  30 | 3.0.1                 | Apache Karaf :: JAAS :: Config
>  40 | Active   |  30 | 3.0.1                 | Apache Karaf :: JAAS :: Boot
>  41 | Active   |  30 | 0.9.0                 | Apache Mina SSHD :: Core
>  42 | Active   |  30 | 3.0.1                 | Apache Karaf :: Bundle :: Commands
>  43 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell :: Table
>  44 | Active   |  30 | 3.0.1                 | Apache Karaf :: Bundle :: Core
>  45 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell :: Help System
>  46 | Active   |  30 | 3.0.1                 | Apache Karaf :: System :: Core
>  47 | Active   |  30 | 3.0.1                 | Apache Karaf :: System :: Shell Commands
>  48 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell :: Various Commands
>  49 | Active   |  30 | 1.0.0                 | Apache Aries Quiesce API
>  50 | Active   |  30 | 3.0.1                 | Apache Karaf :: ConfigAdmin :: Core
>  51 | Active   |  30 | 3.0.1                 | Apache Karaf :: ConfigAdmin :: Commands
>  52 | Active   |  30 | 0.10.0                | Apache Felix Gogo Runtime
>  53 | Active   |  30 | 3.0.1                 | Apache Karaf :: Instance :: Core
>  54 | Active   |  30 | 3.0.1                 | Apache Karaf :: Instance :: Command
>  55 | Active   |  30 | 3.0.1                 | Apache Karaf :: JAAS :: Command
>  56 | Active   |  30 | 3.0.1                 | Apache Karaf :: Diagnostic :: Core
>  57 | Active   |  30 | 3.0.1                 | Apache Karaf :: Diagnostic :: Command
>  58 | Active   |  30 | 3.0.1                 | Apache Karaf :: Log :: Core
>  59 | Active   |  30 | 3.0.1                 | Apache Karaf :: Log :: Command
>  60 | Active   |  30 | 3.0.1                 | Apache Karaf :: Service :: Core
>  61 | Active   |  30 | 3.0.1                 | Apache Karaf :: Service :: Command
>  62 | Active   |  30 | 3.0.1                 | Apache Karaf :: Package :: Core
>  63 | Active   |  30 | 3.0.1                 | Apache Karaf :: Package :: Commands
>  64 | Active   |  30 | 1.0.0.v20110524       | Region Digraph
>  65 | Active   |  30 | 3.0.1                 | Apache Karaf :: Region :: Persistence
>  66 | Active   |  30 | 3.0.1                 | Apache Karaf :: Region :: Shell Commands
>  67 | Active   |  30 | 3.0.1                 | Apache Karaf :: KAR :: Core
>  68 | Active   |  30 | 3.0.1                 | Apache Karaf :: KAR :: Command
>  69 | Active   |  30 | 3.0.1                 | Apache Karaf :: Deployer :: Karaf Archive (.kar)
>  70 | Active   |  30 | 2.0.7                 | Apache MINA Core
>  71 | Active   |  30 | 3.0.1                 | Apache Karaf :: Shell :: SSH
>  72 | Active   |  30 | 3.0.1                 | Apache Karaf :: Management
>  73 | Active   |  30 | 1.1.0                 | Apache Aries JMX API
>  74 | Active   |  30 | 1.1.1                 | Apache Aries JMX Core
>  75 | Active   |  30 | 1.1.0                 | Apache Aries JMX Blueprint API
>  76 | Active   |  30 | 1.1.0                 | Apache Aries JMX Blueprint Core
>  77 | Active   |  30 | 1.0.0                 | Apache Aries JMX Whiteboard
>  78 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | entity.definition
>  79 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | couchbase-lite
>  80 | Active   |  80 | 1.9.2                 | Data mapper for Jackson JSON processor
>  81 | Active   |  80 | 3.7                   | or.apache.poi
>  82 | Active   |  80 | 1.1.3                 | Commons Logging
>  83 | Failure  |  80 | 0.0.1.BUILD-SNAPSHOT  | data
>  84 | Active   |  80 | 1.9.2                 | Jackson JSON processor
>  85 | Active   |  80 | 1.3                   | commons-codec
>  86 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | stockcheck.definition
>  87 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | sweelee.web
>  88 | Active   |  80 | 2.4.0                 | XMLBeans Development Kit
>  89 | Active   |  80 | 0.0.0                 | vaadin.xml
>  90 | Active   |  80 | 0.0.1.BUILD-SNAPSHOT  | import.definition
>  91 | Active   |  80 | 1.6.1                 | dom4j DOM Processor
>  92 | Active   |  30 | 2.2.0                 | Apache ServiceMix :: Specs :: Activation API 1.4
>  93 | Active   |  30 | 1.0                   | Servlet 3.0
>  94 | Active   |  30 | 1.4.4                 | JavaMail API (compat)
>  95 | Active   |  30 | 1.1.1                 | geronimo-jta_1.1_spec
>  96 | Active   |  30 | 1.0.1                 | Annotation 1.1
>  97 | Active   |  30 | 1.1                   | Java Authentication SPI for Containers
>  98 | Active   |  30 | 8.1.14.v20131031      | Jetty :: Aggregate :: All Server
>  99 | Active   |  30 | 1.6.0                 | OPS4J Pax Swissbox :: OSGi Core
> 100 | Active   |  30 | 1.6.0                 | OPS4J Pax Swissbox :: Optional JCL
> 101 | Active   |  20 | 3.16.0                | Apache XBean OSGI Bundle Utilities
> 102 | Active   |  20 | 3.16.0                | Apache XBean :: ASM 4 shaded (repackaged)
> 103 | Active   |  20 | 3.16                  | Apache XBean :: Reflect
> 104 | Active   |  20 | 3.16.0                | Apache XBean :: Finder shaded (repackaged)
> 105 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - API
> 106 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Service SPI
> 107 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Runtime
> 108 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Jetty
> 109 | Active   |  30 | 3.0.1                 | Apache Karaf :: HTTP :: Core
> 110 | Active   |  30 | 3.0.1                 | Apache Karaf :: HTTP :: Commands
> 111 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Jsp Support
> 112 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Extender - Whiteboard
> 113 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - Extender - WAR
> 114 | Active   |  30 | 3.1.0                 | OPS4J Pax Web - FileInstall Deployer
> 115 | Active   |  30 | 1.4.2                 | OPS4J Pax Url - war
> 116 | Active   |  30 | 1.4.2                 | OPS4J Pax Url - Commons
> 117 | Active   |  30 | 1.6.0                 | OPS4J Pax Swissbox :: Bnd Utils
> 118 | Active   |  30 | 1.6.0                 | OPS4J Pax Swissbox :: Property
> 119 | Active   |  30 | 1.43.0                | aQute Bundle Tool Library
> 120 | Active   |  30 | 3.0.1                 | Apache Karaf :: Web :: Core
> 121 | Active   |  30 | 3.0.1                 | Apache Karaf :: Web :: Commands
> 122 | Active   |  80 | 7.1.15                | vaadin-server
> 123 | Active   |  80 | 7.1.15                | vaadin-client-compiled
> 124 | Active   |  80 | 7.1.15                | vaadin-shared
> 125 | Active   |  80 | 1.0.2                 | vaadin-shared-deps
> 126 | Active   |  80 | 7.1.15                | vaadin-themes
> 127 | Active   |  80 | 1.6.3                 | jsoup
> 128 | Active   |  30 | 1.0.0.6               | Apache ServiceMix :: Bundles :: aopalliance
> 129 | Active   |  30 | 3.2.4.RELEASE         | Spring Core
> 130 | Active   |  30 | 3.2.4.RELEASE         | Spring Expression Language
> 131 | Active   |  30 | 3.2.4.RELEASE         | Spring Beans
> 132 | Active   |  30 | 3.2.4.RELEASE         | Spring AOP
> 133 | Active   |  30 | 3.2.4.RELEASE         | Spring Context
> 134 | Active   |  30 | 3.2.4.RELEASE         | Spring Context Support
> 135 | Active   |  30 | 3.0.0.1               | Apache ServiceMix :: Bundles :: cglib
> 136 | Active   |  30 | 1.2.1                 | spring-osgi-io
> 137 | Active   |  30 | 1.2.1                 | spring-osgi-core
> 138 | Active   |  30 | 1.2.1                 | spring-osgi-extender
> 139 | Active   |  30 | 1.2.1                 | spring-osgi-annotation
> 140 | Active   |  30 | 3.0.1                 | Apache Karaf :: Bundle :: SpringStateService
> 141 | Active   |  30 | 3.2.4.RELEASE         | Spring Web
> 142 | Active   |  30 | 3.2.4.RELEASE         | Spring Web Servlet
> 143 | Active   |  30 | 1.2.1                 | spring-osgi-web
> 
> 
> The spring application is #83 (enigmatically called "data") and has a Spring-DM configuration file which just creates a JavaConfig bean, one of which is being instantiated twice. I put some logging into this bean definition:
> System.out.println("Making a database from: "+ Thread.currentThread().getContextClassLoader());
> On the second load of Karaf, this line appears twice with "Making a database from: BundleDelegatingClassLoader for [null (data)]" for both outputs, the second of which throws the UnsatisfiedLinkException and fails to load the bundle. If I stop and start the bundle again, the same thing happens. If I rm -rf data and re-run Karaf the application works fine after installing the necessary features.
> 
> Any suggestions?
> Best, Dan.
> 
> 
>