[ 
https://issues.apache.org/jira/browse/TUSCANY-1293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12568011#action_12568011
 ] 

Rajini Sivaram commented on TUSCANY-1293:
-----------------------------------------

The first block tries to run bundle.start() on SDO bundles and its dependent 
bundles (EMF). It will throw an exception if one of these bundles could not be 
resolved. There is a testBundle.start() outside the loop which has dependencies 
on SDO (and hence on its dependencies). So if an exception is thrown by the 
loop, the following testBundle.start() will throw an uncaught exception 
,causing the test to fail. I put the code to catch and print the exception from 
the loop rather than fail at the first exception so that all the bundles which 
failed to resolve can be identified in one run, rather than have to rerun after 
fixing one-by-one. The tests shouldn't really throw an exception now anyway, so 
please feel free to remove the try-catch block if you prefer.


The second catch block corresponds to delegation to the parent classloader 
during ClassLoader.loadClass(), and the exception there is deliberately caught 
and ignored (the child classloader loads the class if the parent classloader 
cannot). So the try-catch is necessary, and the exception doesn't reflect a 
failure.

> SDO does not work with OSGi
> ---------------------------
>
>                 Key: TUSCANY-1293
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1293
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-beta1
>         Environment: OS X Eclipse 3.3 M7
>            Reporter: Bryan Hunt
>            Priority: Blocker
>             Fix For: Java-SDO-Next
>
>         Attachments: sdo-osgi.txt
>
>
> When I execute:
> XSDHelper.INSTANCE.define(schema, null);
> I end up with a NullPointerException.  I've tracked down root cause ...
> The static initializer of the HelperProvider executes this code:
>   provider = getInstance(HelperProvider.class.getClassLoader());
> which ends up calling:
>   HelperProvider provider = loadImplementation(cl, implName);
> implName is null so
>         if (implName == null) {
>             implName = getImplementationName(cl);
>         }
> ends up calling
>   implName = getImplementationName(cl);
> which ends up calling:
>   InputStream is = cl.getResourceAsStream(SERVICE_RESOURCE_NAME);
> where SERVICE_RESORUCE_NAME = 
> "META-INF/services/commonj.sdo.impl.HelperProvider"
> getResourceAsStream() return null because META-INF/services does not exist in 
> the API bundle.  It exists in the IMPL bundle and since you are using the 
> class loader from the API bundle, it won't work.  
> You can set
> -Dcommonj.sdo.impl.HelperProvider=org.apache.tuscany.sdo.helper.HelperProviderImpl
> to get around the above problem, but as soon as 
>   return (HelperProvider) cl.loadClass(implName).newInstance();
> executes, you get a CalssNotFoundException.  Again, this is because you are 
> trying to load a class outside the bundle with the wrong class loader.
>  tried modifying the API manifest by hand to add
> Eclipse-BuddyPolicy: dependent
> and
> Eclipse-BuddyPolicy: global
> Either of those buddy policies will get past the class loader problem 
> (although I believe this is specific to eclipse and won't work for OSGi in 
> general), but when HelperProvider is initializing, you get the following 
> exception:
> java.lang.ExceptionInInitializerError
> at org.apache.tuscany.sdo.impl.AttributeImpl.<clinit>(AttributeImpl.java:126)
> at 
> org.apache.tuscany.sdo.impl.SDOFactoryImpl.createAttribute(SDOFactoryImpl.java:239)
> at org.apache.tuscany.sdo.impl.ClassImpl.<clinit>(ClassImpl.java:68)
> at 
> org.apache.tuscany.sdo.impl.SDOFactoryImpl$SDOEcoreFactory.createEClass(SDOFactoryImpl.java:76)
> at 
> org.apache.tuscany.sdo.impl.SDOPackageImpl.createEClass(SDOPackageImpl.java:622)
> at 
> org.apache.tuscany.sdo.impl.SDOPackageImpl.createPackageContents(SDOPackageImpl.java:550)
> at org.apache.tuscany.sdo.impl.SDOPackageImpl.init(SDOPackageImpl.java:259)
> at org.apache.tuscany.sdo.SDOPackage.<clinit>(SDOPackage.java:76)
> at sun.misc.Unsafe.ensureClassInitialized(Native Method)
> at 
> sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
> at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
> at java.lang.reflect.Field.acquireFieldAccessor(Field.java:917)
> at java.lang.reflect.Field.getFieldAccessor(Field.java:898)
> at java.lang.reflect.Field.get(Field.java:357)
> at org.apache.tuscany.sdo.util.SDOUtil.registerStaticTypes(SDOUtil.java:196)
> at 
> org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.init(ModelFactoryImpl.java:731)
> at org.apache.tuscany.sdo.model.ModelFactory.<clinit>(ModelFactory.java:41)
> at 
> org.apache.tuscany.sdo.helper.TypeHelperImpl.getBuiltInModels(TypeHelperImpl.java:61)
> at org.apache.tuscany.sdo.helper.TypeHelperImpl.<init>(TypeHelperImpl.java:79)
> at 
> org.apache.tuscany.sdo.helper.HelperContextImpl.<init>(HelperContextImpl.java:46)
> at 
> org.apache.tuscany.sdo.helper.HelperProviderImpl.createDefaultHelpers(HelperProviderImpl.java:38)
> at 
> org.apache.tuscany.sdo.rtlib.helper.HelperProviderBase.<init>(HelperProviderBase.java:78)
> at 
> org.apache.tuscany.sdo.helper.HelperProviderImpl.<init>(HelperProviderImpl.java:31)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
> at java.lang.Class.newInstance0(Class.java:350)
> at java.lang.Class.newInstance(Class.java:303)
> at commonj.sdo.impl.HelperProvider.loadImplementation(HelperProvider.java:157)
> at commonj.sdo.impl.HelperProvider.getInstance(HelperProvider.java:126)
> at commonj.sdo.impl.HelperProvider.<clinit>(HelperProvider.java:69)
> at commonj.sdo.helper.XSDHelper.<clinit>(XSDHelper.java:195)
> at notification.sdo.Application.start(Application.java:23)
> at 
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:153)
> at 
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
> at 
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
> at 
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
> at 
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:497)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:436)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1162)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1137)
> Caused by: java.lang.NullPointerException
> at 
> org.apache.tuscany.sdo.impl.AttributeImpl.eStaticClass(AttributeImpl.java:73)
> at org.eclipse.emf.ecore.impl.EObjectImpl.eClass(EObjectImpl.java:224)
> at 
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicInverseAdd(BasicEObjectImpl.java:1413)
> at 
> org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.eInverseAdd(EStructuralFeatureImpl.java:514)
> at 
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eInverseAdd(BasicEObjectImpl.java:1389)
> at org.eclipse.emf.ecore.util.EcoreEList.inverseAdd(EcoreEList.java:282)
> at 
> org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:318)
> at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:626)
> at 
> org.eclipse.emf.ecore.impl.EPackageImpl.createEAttribute(EPackageImpl.java:745)
> at 
> org.apache.tuscany.sdo.impl.FactoryBase.createDocumentRoot(FactoryBase.java:301)
> at org.apache.tuscany.sdo.impl.FactoryBase.initXSD(FactoryBase.java:156)
> at 
> org.apache.tuscany.sdo.model.internal.impl.InternalFactoryImpl.createXSDMetaData(InternalFactoryImpl.java:211)
> at 
> org.apache.tuscany.sdo.model.internal.impl.InternalFactoryImpl.initializeMetaData(InternalFactoryImpl.java:206)
> at 
> org.apache.tuscany.sdo.model.internal.impl.InternalFactoryImpl.init(InternalFactoryImpl.java:172)
> at 
> org.apache.tuscany.sdo.model.internal.InternalFactory.<clinit>(InternalFactory.java:41)
> ... 47 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to