Spring 5.1: missing package import

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Spring 5.1: missing package import

Markus Rathgeb
Hi,

in some product we are using Spring by the Karaf provided features.
We tried to bump from Spring 5.0 to 5.1 (both provided by the Karaf
Spring feature repository).

The current feature repo
(https://repo1.maven.org/maven2/org/apache/karaf/features/spring/4.2.6/spring-4.2.6-features.xml)
provided the Spring versions 5.0.14.RELEASE and 5.1.7.RELEASE.

With respect to the error I would like to report, let's have a look at
the changed of a specific class of "spring-messaging":

git diff v5.0.14.RELEASE...v5.1.7.RELEASE --
spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java

```
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -22,11 +22,11 @@ import java.util.HashSet;
 import java.util.Set;

 import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;

 import org.springframework.lang.Nullable;
 import org.springframework.messaging.Message;
 import org.springframework.messaging.MessageHeaders;
+import org.springframework.messaging.simp.SimpLogging;
 import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
 import org.springframework.messaging.simp.SimpMessageType;
 import org.springframework.util.Assert;
@@ -52,7 +52,7 @@ import org.springframework.util.StringUtils;
  */
 public class DefaultUserDestinationResolver implements
UserDestinationResolver {

-       private static final Log logger =
LogFactory.getLog(DefaultUserDestinationResolver.class);
+       private static final Log logger =
SimpLogging.forLogName(DefaultUserDestinationResolver.class);


        private final SimpUserRegistry userRegistry;
```

Instead of "org.apache.commons.logging.LogFactory" the newly
introduced class "org.springframework.messaging.simp.SimpLogging" is
used.

That class is using the class "org.springframework.core.log.LogDelegateFactory".

The package "org.springframework.core.log" is not added to the
"Package-Imports".

This leads to the following error:

```
Caused by: java.lang.ClassNotFoundException:
org.springframework.core.log.LogDelegateFactory not found by
org.apache.servicemix.bundles.spring-messaging [119]
        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1639)
~[?:?]
        at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
~[?:?]
        at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053)
~[?:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:?]
        at org.springframework.messaging.simp.SimpLogging.forLog(SimpLogging.java:67)
~[?:?]
        at org.springframework.messaging.simp.SimpLogging.forLogName(SimpLogging.java:56)
~[?:?]
        at org.springframework.messaging.simp.user.DefaultUserDestinationResolver.<clinit>(DefaultUserDestinationResolver.java:55)
~[?:?]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) ~[?:?]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
~[?:?]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
~[?:?]
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
~[?:?]
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:172)
~[?:?]
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:117)
~[?:?]
        at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:300)
~[?:?]
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:285)
~[?:?]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1325)
~[?:?]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1171)
~[?:?]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
~[?:?]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
~[?:?]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
~[?:?]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
~[?:?]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
~[?:?]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
~[?:?]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849)
~[?:?]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
~[?:?]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
~[?:?]
        at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:701)
~[?:?]
        at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:667)
~[?:?]
        at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:715)
~[?:?]
        at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:590)
~[?:?]
        at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:529)
~[?:?]
        at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:169)
~[?:?]
        at javax.servlet.GenericServlet.init(GenericServlet.java:244) ~[?:?]
        at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:670)
~[?:?]
        ... 34 more
```

After adding "org.springframework.core.log" to the "Import-Package"
manifest entry of "org.apache.servicemix.bundles.spring-messaging" the
error is gone and spring-messaging 5.1 works as expected (similar to
5.0) in OSGi.
Reply | Threaded
Open this post in threaded view
|

Re: Spring 5.1: missing package import

Jean-Baptiste Onofré
Good catch, I missed this one. Let me fix that.

Thanks

Regards
JB

On 13/06/2019 10:10, Markus Rathgeb wrote:

> Hi,
>
> in some product we are using Spring by the Karaf provided features.
> We tried to bump from Spring 5.0 to 5.1 (both provided by the Karaf
> Spring feature repository).
>
> The current feature repo
> (https://repo1.maven.org/maven2/org/apache/karaf/features/spring/4.2.6/spring-4.2.6-features.xml)
> provided the Spring versions 5.0.14.RELEASE and 5.1.7.RELEASE.
>
> With respect to the error I would like to report, let's have a look at
> the changed of a specific class of "spring-messaging":
>
> git diff v5.0.14.RELEASE...v5.1.7.RELEASE --
> spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java
>
> ```
>   * you may not use this file except in compliance with the License.
>   * You may obtain a copy of the License at
>   *
> - *      http://www.apache.org/licenses/LICENSE-2.0
> + *      https://www.apache.org/licenses/LICENSE-2.0
>   *
>   * Unless required by applicable law or agreed to in writing, software
>   * distributed under the License is distributed on an "AS IS" BASIS,
> @@ -22,11 +22,11 @@ import java.util.HashSet;
>  import java.util.Set;
>
>  import org.apache.commons.logging.Log;
> -import org.apache.commons.logging.LogFactory;
>
>  import org.springframework.lang.Nullable;
>  import org.springframework.messaging.Message;
>  import org.springframework.messaging.MessageHeaders;
> +import org.springframework.messaging.simp.SimpLogging;
>  import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
>  import org.springframework.messaging.simp.SimpMessageType;
>  import org.springframework.util.Assert;
> @@ -52,7 +52,7 @@ import org.springframework.util.StringUtils;
>   */
>  public class DefaultUserDestinationResolver implements
> UserDestinationResolver {
>
> -       private static final Log logger =
> LogFactory.getLog(DefaultUserDestinationResolver.class);
> +       private static final Log logger =
> SimpLogging.forLogName(DefaultUserDestinationResolver.class);
>
>
>         private final SimpUserRegistry userRegistry;
> ```
>
> Instead of "org.apache.commons.logging.LogFactory" the newly
> introduced class "org.springframework.messaging.simp.SimpLogging" is
> used.
>
> That class is using the class "org.springframework.core.log.LogDelegateFactory".
>
> The package "org.springframework.core.log" is not added to the
> "Package-Imports".
>
> This leads to the following error:
>
> ```
> Caused by: java.lang.ClassNotFoundException:
> org.springframework.core.log.LogDelegateFactory not found by
> org.apache.servicemix.bundles.spring-messaging [119]
>         at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1639)
> ~[?:?]
>         at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
> ~[?:?]
>         at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053)
> ~[?:?]
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:?]
>         at org.springframework.messaging.simp.SimpLogging.forLog(SimpLogging.java:67)
> ~[?:?]
>         at org.springframework.messaging.simp.SimpLogging.forLogName(SimpLogging.java:56)
> ~[?:?]
>         at org.springframework.messaging.simp.user.DefaultUserDestinationResolver.<clinit>(DefaultUserDestinationResolver.java:55)
> ~[?:?]
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method) ~[?:?]
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> ~[?:?]
>         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> ~[?:?]
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> ~[?:?]
>         at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:172)
> ~[?:?]
>         at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:117)
> ~[?:?]
>         at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:300)
> ~[?:?]
>         at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:285)
> ~[?:?]
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1325)
> ~[?:?]
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1171)
> ~[?:?]
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
> ~[?:?]
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
> ~[?:?]
>         at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
> ~[?:?]
>         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
> ~[?:?]
>         at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
> ~[?:?]
>         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
> ~[?:?]
>         at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849)
> ~[?:?]
>         at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
> ~[?:?]
>         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
> ~[?:?]
>         at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:701)
> ~[?:?]
>         at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:667)
> ~[?:?]
>         at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:715)
> ~[?:?]
>         at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:590)
> ~[?:?]
>         at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:529)
> ~[?:?]
>         at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:169)
> ~[?:?]
>         at javax.servlet.GenericServlet.init(GenericServlet.java:244) ~[?:?]
>         at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:670)
> ~[?:?]
>         ... 34 more
> ```
>
> After adding "org.springframework.core.log" to the "Import-Package"
> manifest entry of "org.apache.servicemix.bundles.spring-messaging" the
> error is gone and spring-messaging 5.1 works as expected (similar to
> 5.0) in OSGi.
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Spring 5.1: missing package import

Markus Rathgeb
Hi JB,

have you already had a change to fix it?
I did not realize any new commit (is this the correct repository):
https://github.com/apache/servicemix-bundles/commits/master

Best regards,
Markus

Am Do., 13. Juni 2019 um 10:32 Uhr schrieb Jean-Baptiste Onofré
<[hidden email]>:

>
> Good catch, I missed this one. Let me fix that.
>
> Thanks
>
> Regards
> JB
>
> On 13/06/2019 10:10, Markus Rathgeb wrote:
> > Hi,
> >
> > in some product we are using Spring by the Karaf provided features.
> > We tried to bump from Spring 5.0 to 5.1 (both provided by the Karaf
> > Spring feature repository).
> >
> > The current feature repo
> > (https://repo1.maven.org/maven2/org/apache/karaf/features/spring/4.2.6/spring-4.2.6-features.xml)
> > provided the Spring versions 5.0.14.RELEASE and 5.1.7.RELEASE.
> >
> > With respect to the error I would like to report, let's have a look at
> > the changed of a specific class of "spring-messaging":
> >
> > git diff v5.0.14.RELEASE...v5.1.7.RELEASE --
> > spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java
> >
> > ```
> >   * you may not use this file except in compliance with the License.
> >   * You may obtain a copy of the License at
> >   *
> > - *      http://www.apache.org/licenses/LICENSE-2.0
> > + *      https://www.apache.org/licenses/LICENSE-2.0
> >   *
> >   * Unless required by applicable law or agreed to in writing, software
> >   * distributed under the License is distributed on an "AS IS" BASIS,
> > @@ -22,11 +22,11 @@ import java.util.HashSet;
> >  import java.util.Set;
> >
> >  import org.apache.commons.logging.Log;
> > -import org.apache.commons.logging.LogFactory;
> >
> >  import org.springframework.lang.Nullable;
> >  import org.springframework.messaging.Message;
> >  import org.springframework.messaging.MessageHeaders;
> > +import org.springframework.messaging.simp.SimpLogging;
> >  import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
> >  import org.springframework.messaging.simp.SimpMessageType;
> >  import org.springframework.util.Assert;
> > @@ -52,7 +52,7 @@ import org.springframework.util.StringUtils;
> >   */
> >  public class DefaultUserDestinationResolver implements
> > UserDestinationResolver {
> >
> > -       private static final Log logger =
> > LogFactory.getLog(DefaultUserDestinationResolver.class);
> > +       private static final Log logger =
> > SimpLogging.forLogName(DefaultUserDestinationResolver.class);
> >
> >
> >         private final SimpUserRegistry userRegistry;
> > ```
> >
> > Instead of "org.apache.commons.logging.LogFactory" the newly
> > introduced class "org.springframework.messaging.simp.SimpLogging" is
> > used.
> >
> > That class is using the class "org.springframework.core.log.LogDelegateFactory".
> >
> > The package "org.springframework.core.log" is not added to the
> > "Package-Imports".
> >
> > This leads to the following error:
> >
> > ```
> > Caused by: java.lang.ClassNotFoundException:
> > org.springframework.core.log.LogDelegateFactory not found by
> > org.apache.servicemix.bundles.spring-messaging [119]
> >         at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1639)
> > ~[?:?]
> >         at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
> > ~[?:?]
> >         at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053)
> > ~[?:?]
> >         at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:?]
> >         at org.springframework.messaging.simp.SimpLogging.forLog(SimpLogging.java:67)
> > ~[?:?]
> >         at org.springframework.messaging.simp.SimpLogging.forLogName(SimpLogging.java:56)
> > ~[?:?]
> >         at org.springframework.messaging.simp.user.DefaultUserDestinationResolver.<clinit>(DefaultUserDestinationResolver.java:55)
> > ~[?:?]
> >         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> > Method) ~[?:?]
> >         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> > ~[?:?]
> >         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> > ~[?:?]
> >         at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> > ~[?:?]
> >         at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:172)
> > ~[?:?]
> >         at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:117)
> > ~[?:?]
> >         at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:300)
> > ~[?:?]
> >         at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:285)
> > ~[?:?]
> >         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1325)
> > ~[?:?]
> >         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1171)
> > ~[?:?]
> >         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
> > ~[?:?]
> >         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
> > ~[?:?]
> >         at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
> > ~[?:?]
> >         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
> > ~[?:?]
> >         at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
> > ~[?:?]
> >         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
> > ~[?:?]
> >         at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849)
> > ~[?:?]
> >         at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
> > ~[?:?]
> >         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
> > ~[?:?]
> >         at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:701)
> > ~[?:?]
> >         at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:667)
> > ~[?:?]
> >         at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:715)
> > ~[?:?]
> >         at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:590)
> > ~[?:?]
> >         at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:529)
> > ~[?:?]
> >         at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:169)
> > ~[?:?]
> >         at javax.servlet.GenericServlet.init(GenericServlet.java:244) ~[?:?]
> >         at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:670)
> > ~[?:?]
> >         ... 34 more
> > ```
> >
> > After adding "org.springframework.core.log" to the "Import-Package"
> > manifest entry of "org.apache.servicemix.bundles.spring-messaging" the
> > error is gone and spring-messaging 5.1 works as expected (similar to
> > 5.0) in OSGi.
> >
>
> --
> Jean-Baptiste Onofré
> [hidden email]
> http://blog.nanthrax.net
> Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Spring 5.1: missing package import

Jean-Baptiste Onofré
Hi,

I will merge the fix later today. I've created the Jira to track and
include in next release cycle.

Regards
JB

On 17/06/2019 09:17, Markus Rathgeb wrote:

> Hi JB,
>
> have you already had a change to fix it?
> I did not realize any new commit (is this the correct repository):
> https://github.com/apache/servicemix-bundles/commits/master
>
> Best regards,
> Markus
>
> Am Do., 13. Juni 2019 um 10:32 Uhr schrieb Jean-Baptiste Onofré
> <[hidden email]>:
>>
>> Good catch, I missed this one. Let me fix that.
>>
>> Thanks
>>
>> Regards
>> JB
>>
>> On 13/06/2019 10:10, Markus Rathgeb wrote:
>>> Hi,
>>>
>>> in some product we are using Spring by the Karaf provided features.
>>> We tried to bump from Spring 5.0 to 5.1 (both provided by the Karaf
>>> Spring feature repository).
>>>
>>> The current feature repo
>>> (https://repo1.maven.org/maven2/org/apache/karaf/features/spring/4.2.6/spring-4.2.6-features.xml)
>>> provided the Spring versions 5.0.14.RELEASE and 5.1.7.RELEASE.
>>>
>>> With respect to the error I would like to report, let's have a look at
>>> the changed of a specific class of "spring-messaging":
>>>
>>> git diff v5.0.14.RELEASE...v5.1.7.RELEASE --
>>> spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java
>>>
>>> ```
>>>   * you may not use this file except in compliance with the License.
>>>   * You may obtain a copy of the License at
>>>   *
>>> - *      http://www.apache.org/licenses/LICENSE-2.0
>>> + *      https://www.apache.org/licenses/LICENSE-2.0
>>>   *
>>>   * Unless required by applicable law or agreed to in writing, software
>>>   * distributed under the License is distributed on an "AS IS" BASIS,
>>> @@ -22,11 +22,11 @@ import java.util.HashSet;
>>>  import java.util.Set;
>>>
>>>  import org.apache.commons.logging.Log;
>>> -import org.apache.commons.logging.LogFactory;
>>>
>>>  import org.springframework.lang.Nullable;
>>>  import org.springframework.messaging.Message;
>>>  import org.springframework.messaging.MessageHeaders;
>>> +import org.springframework.messaging.simp.SimpLogging;
>>>  import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
>>>  import org.springframework.messaging.simp.SimpMessageType;
>>>  import org.springframework.util.Assert;
>>> @@ -52,7 +52,7 @@ import org.springframework.util.StringUtils;
>>>   */
>>>  public class DefaultUserDestinationResolver implements
>>> UserDestinationResolver {
>>>
>>> -       private static final Log logger =
>>> LogFactory.getLog(DefaultUserDestinationResolver.class);
>>> +       private static final Log logger =
>>> SimpLogging.forLogName(DefaultUserDestinationResolver.class);
>>>
>>>
>>>         private final SimpUserRegistry userRegistry;
>>> ```
>>>
>>> Instead of "org.apache.commons.logging.LogFactory" the newly
>>> introduced class "org.springframework.messaging.simp.SimpLogging" is
>>> used.
>>>
>>> That class is using the class "org.springframework.core.log.LogDelegateFactory".
>>>
>>> The package "org.springframework.core.log" is not added to the
>>> "Package-Imports".
>>>
>>> This leads to the following error:
>>>
>>> ```
>>> Caused by: java.lang.ClassNotFoundException:
>>> org.springframework.core.log.LogDelegateFactory not found by
>>> org.apache.servicemix.bundles.spring-messaging [119]
>>>         at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1639)
>>> ~[?:?]
>>>         at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
>>> ~[?:?]
>>>         at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053)
>>> ~[?:?]
>>>         at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:?]
>>>         at org.springframework.messaging.simp.SimpLogging.forLog(SimpLogging.java:67)
>>> ~[?:?]
>>>         at org.springframework.messaging.simp.SimpLogging.forLogName(SimpLogging.java:56)
>>> ~[?:?]
>>>         at org.springframework.messaging.simp.user.DefaultUserDestinationResolver.<clinit>(DefaultUserDestinationResolver.java:55)
>>> ~[?:?]
>>>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>>> Method) ~[?:?]
>>>         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>>> ~[?:?]
>>>         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>>> ~[?:?]
>>>         at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
>>> ~[?:?]
>>>         at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:172)
>>> ~[?:?]
>>>         at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:117)
>>> ~[?:?]
>>>         at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:300)
>>> ~[?:?]
>>>         at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:285)
>>> ~[?:?]
>>>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1325)
>>> ~[?:?]
>>>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1171)
>>> ~[?:?]
>>>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
>>> ~[?:?]
>>>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
>>> ~[?:?]
>>>         at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
>>> ~[?:?]
>>>         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
>>> ~[?:?]
>>>         at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
>>> ~[?:?]
>>>         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
>>> ~[?:?]
>>>         at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849)
>>> ~[?:?]
>>>         at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
>>> ~[?:?]
>>>         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
>>> ~[?:?]
>>>         at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:701)
>>> ~[?:?]
>>>         at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:667)
>>> ~[?:?]
>>>         at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:715)
>>> ~[?:?]
>>>         at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:590)
>>> ~[?:?]
>>>         at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:529)
>>> ~[?:?]
>>>         at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:169)
>>> ~[?:?]
>>>         at javax.servlet.GenericServlet.init(GenericServlet.java:244) ~[?:?]
>>>         at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:670)
>>> ~[?:?]
>>>         ... 34 more
>>> ```
>>>
>>> After adding "org.springframework.core.log" to the "Import-Package"
>>> manifest entry of "org.apache.servicemix.bundles.spring-messaging" the
>>> error is gone and spring-messaging 5.1 works as expected (similar to
>>> 5.0) in OSGi.
>>>
>>
>> --
>> Jean-Baptiste Onofré
>> [hidden email]
>> http://blog.nanthrax.net
>> Talend - http://www.talend.com

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com