atos1990 / orika

Automatically exported from code.google.com/p/orika
0 stars 0 forks source link

Release Orika as OSGI-compatible bundle #8

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
On Wed, Mar 14, 2012 at 9:49 PM, Alan Stewart <alankstewart@gmail.com> wrote:

Can you make the 1.1.0 release jar OSGi compatible? It would save me wrapping 
it with the maven-bundle-plugin

Thanks
Alan

Original issue reported on code.google.com by matt.deb...@gmail.com on 15 Mar 2012 at 4:54

GoogleCodeExporter commented 9 years ago
yes ... this would be really nice.

Greetings
Tom

Original comment by insidegr...@gmail.com on 4 May 2012 at 6:32

GoogleCodeExporter commented 9 years ago
+1 I'm currently having problems because of this when trying to start my app 
(which depends on Orika) within Karaf.

Original comment by galue.al...@gmail.com on 4 Sep 2012 at 9:39

GoogleCodeExporter commented 9 years ago

Original comment by elaat...@gmail.com on 4 Sep 2012 at 11:19

GoogleCodeExporter commented 9 years ago

Original comment by elaat...@gmail.com on 7 Sep 2012 at 7:55

GoogleCodeExporter commented 9 years ago
I installed into talend ESB (osgi implementation based on karaf) with the 
command:
install -s wrap:mvn:ma.glasnost.orika/orika-core/1.4.4

i get the following error:

2014-01-08 16:43:12,472 | ERROR | Refresh Packages | BlueprintContainerImpl     
      | container.BlueprintContainerImpl  393 | 7 - org.apache.aries.b

lueprint.core - 1.1.0 | Unable to start blueprint container for bundle 
com.elsis.istar.opt.stanag4676.formatter.flowcontroller.impl

org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to 
initialize bean stanag4676FormatterFlowcontroller

        at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:714)

        at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)

        at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)

        at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)

        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_15]

        at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_15]

        at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)

        at org.apache.aries.blueprint.di.RefRecipe.internalCreate(RefRecipe.java:62)

        at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:106)

        at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:282)[7:org.apache.aries.blueprint.core:1.1.0]

        at org.apache.aries.blueprint.container.ServiceRecipe.internalGetService(ServiceRecipe.java:249)[7:org.apache.aries.blueprint.core:1.1.0]

        at org.apache.aries.blueprint.container.ServiceRecipe.getService(ServiceRecipe.java:351)[7:org.apache.aries.blueprint.core:1.1.0]

        at org.apache.aries.blueprint.container.ServiceRecipe$TriggerServiceFactory.getService(ServiceRecipe.java:504)

        at org.eclipse.osgi.internal.serviceregistry.ServiceUse$1.run(ServiceUse.java:141)[osgi-3.8.0.v20120529-1548.jar:]

        at java.security.AccessController.doPrivileged(Native Method)[:1.7.0_15]

        at org.eclipse.osgi.internal.serviceregistry.ServiceUse.getService(ServiceUse.java:139)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:468)[osgi-3.8.0.v20120529-1548.ja

r:]

        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:467)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.getService(BundleContextImpl.java:594)[osgi-3.8.0.v20120529-1548.jar:]

        at org.apache.felix.metatype.internal.ManagedServiceTracker.addingService(ManagedServiceTracker.java:52)[77:org.apache.felix.metatype:1.0.6]

        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:932)[karaf.jar:2.3.1]

        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1)[karaf.jar:2.3.1]

        at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)[karaf.jar:2.3.1]

       at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)[karaf.jar:2.3.1]

        at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:894)[karaf.jar:2.3.1]

        at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)[osgi-3.8.0.v20120529-154

8.jar:]

        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)[osgi-3.8.0.v20120529-1548

.jar:]

        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)[osgi-3.8.0.v20120529-1548.jar:

]

        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)[osgi-3.8.0.v20120529-1548.jar:]

        at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerService(BlueprintContainerImpl.java:439)[7:org.apache.aries.blueprint.c

ore:1.1.0]

        at org.apache.aries.blueprint.container.ServiceRecipe.register(ServiceRecipe.java:190)[7:org.apache.aries.blueprint.core:1.1.0]

        at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerServices(BlueprintContainerImpl.java:690)[7:org.apache.aries.blueprint.

core:1.1.0]

        at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:369)[7:org.apache.aries.blueprint.core:1.1.0]

        at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:261)[7:org.apache.aries.blueprint.core:1.1.0]

        at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:259)[7:org.apache.aries.blueprint.core:1.1.0]

        at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:222)[7:org.apache.aries.blueprint.core:1.1.0]

        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)[11:org.apache.aries

.util:1.1.0]

        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)[11:org.apache.aries

.util:1.1.0]

        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)[11:org.apache.aries.util

:1.1.0]

        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)[11:org.apache.aries.util

:1.1.0]

        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)[11:org.apache.aries.util

:1.1.0]

        at org.eclipse.osgi.framework.internal.core.Framework$10.call(Framework.java:1606)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.notifyHookPrivileged(ServiceRegistry.java:1239)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.notifyHooksPrivileged(ServiceRegistry.java:1222)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.framework.internal.core.Framework.notifyEventHooksPrivileged(Framework.java:1603)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1558)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1505)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1500)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:391)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1177)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.resumeBundles(PackageAdminImpl.java:317)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.processDelta(PackageAdminImpl.java:556)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.doResolveBundles(PackageAdminImpl.java:251)[osgi-3.8.0.v20120529-1548.jar:]

        at org.eclipse.osgi.framework.internal.core.PackageAdminImpl$1.run(PackageAdminImpl.java:174)[osgi-3.8.0.v20120529-1548.jar:]

        at java.lang.Thread.run(Thread.java:722)[:1.7.0_15]

Caused by: java.lang.NoClassDefFoundError: 
com/googlecode/concurrentlinkedhashmap/ConcurrentLinkedHashMap$Builder

        at ma.glasnost.orika.util.HashMapUtility.getConcurrentLinkedHashMap(HashMapUtility.java:46)

        at ma.glasnost.orika.converter.DefaultConverterFactory.<init>(DefaultConverterFactory.java:65)

        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.7.0_15]

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)[:1.7.0_15]

        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.7.0_15]

        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)[:1.7.0_15]

        at java.lang.Class.newInstance0(Class.java:374)[:1.7.0_15]

        at java.lang.Class.newInstance(Class.java:327)[:1.7.0_15]

        at ma.glasnost.orika.impl.UtilityResolver.resolveUtility(UtilityResolver.java:131)

        at ma.glasnost.orika.impl.UtilityResolver.getDefaultConverterFactory(UtilityResolver.java:61)

        at ma.glasnost.orika.impl.DefaultMapperFactory$MapperFactoryBuilder.<init>(DefaultMapperFactory.java:277)

        at ma.glasnost.orika.impl.DefaultMapperFactory$Builder.<init>(DefaultMapperFactory.java:489)

        at com.elsis.istar.opt.stanag4676.formatter.flowcontroller.impl.FormatterProcessingControllerService.init(FormatterProcessingControllerService

.java:42)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_15]

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_15]

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_15]

        at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_15]

        at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:297)

        at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:958)

        at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:712)

        ... 60 more

If i install artifact the same way as the orika
<dependency>
    <groupId>com.googlecode.concurrentlinkedhashmap</groupId>
    <artifactId>concurrentlinkedhashmap-lru</artifactId>
    <version>1.4</version>
</dependency>

i get error about missing package sun.misc which is unrecommended to rely on:
http://stackoverflow.com/questions/8639308/is-the-sun-misc-package-still-availab
le-in-java#answer-8639375

Maybe without bundlizing (OSGifying) - is any way to use Orika in OSGi 
container?

Original comment by Ignas.Tr...@gmail.com on 8 Jan 2014 at 2:51

GoogleCodeExporter commented 9 years ago
If you are getting an error regarding sun.misc when running Orika, you should 
try to use com.googlecode.concurrentlinkedhashmap version 1.2 (JDK1.5) version. 
This has no dependency on Unsafe class. I think Orika uses this version, not 
1.4 anyhow.

Original comment by colm.br...@gmail.com on 28 May 2014 at 10:15

GoogleCodeExporter commented 9 years ago
For everyone interested in using Orika inside an OSGi container.

I could make Orika 1.4.5 work in Karaf by creating an Orika bundle and 
embedding the following dependencies:
* com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.2_jdk5
* com.thoughtworks.paranamer:paranamer:2.3
* com.carrotsearch:java-sizeof:0.0.4

Orika depends also on Javassist and Slf4J but I just import the needed 
packages, as have them already in Karaf.

Because of com.carrotsearch:java-sizeof, I had to add 
"sun.misc;resolution:=optional" import to the manifest, which is kind of 
annoying. Orika don't actually use the single class inside java-sizeof that 
depends on 'sun.misc' package, so setting it as optional should be safe. 
Another, better, approach could be to use ProGuard to remove the unused 
java-sizeof classes and thus get rid of the 'sun.misc' import, but I didn't try 
it yet.

Original comment by cjelm...@gmail.com on 15 Sep 2014 at 8:45

GoogleCodeExporter commented 9 years ago
Great, 
If there is someone how can help with an OSGi build please pull request :)
So it can be available for everybody
* size-of as been added just for error reporting

Cheers 

Original comment by elaat...@gmail.com on 15 Sep 2014 at 1:19