Re: [equinox-dev] Resource not found inside bundle
Thanks a lot, BJ and Raymond!! That helped a lot ... --David On Mon, Jul 28, 2014 at 5:59 PM, BJ Hargrave hargr...@us.ibm.com wrote: The problem is: What is the context class loader of the thread? Did you set one up? OSGi is generally mute on the subject of context class loaders and does not mess with them. Since you know that the resource is visible to your bundle, it would be better to use your class' class loader to call getResources. ClassLoader loader = getClass().getClassLoader(); ... EnumerationURL urls = loader.getResources(api_mapping.xml); -- *BJ Hargrave* Senior Technical Staff Member, IBM OSGi Fellow and CTO of the *OSGi Alliance* http://www.osgi.org/ *hargr...@us.ibm.com* hargr...@us.ibm.com office: +1 386 848 1781 mobile: +1 386 848 3788 From:David Cao govel...@gmail.com To:Equinox development mailing list equinox-dev@eclipse.org Date:2014/07/28 16:51 Subject:Re: [equinox-dev] Resource not found inside bundle Sent by:equinox-dev-boun...@eclipse.org -- So I see conflict answers ... To Raymond, I will give a quick try from the Activator of your method. Thank!! To BJ, the code is something like this, ClassLoader loader = Thread.currentThread().getContextClassLoader(); ... EnumerationURL urls = loader.getResources(api_mapping.xml); ... Do you see a problem? What I am doing here is to convert an existing web app into OSGi framework via Servlet bridge for Tomcat 6. The classloading code is from the non-bundle web app ... thanks a lot!! On Mon, Jul 28, 2014 at 5:14 PM, BJ Hargrave *hargr...@us.ibm.com* hargr...@us.ibm.com wrote: That file does appear to be in the classpath. The picture shows it in WEB-INF/classes which is in the Bundle-ClassPath. What does the code look like that is trying to access the file? -- *BJ Hargrave* Senior Technical Staff Member, IBM OSGi Fellow and CTO of the *OSGi Alliance* http://www.osgi.org/ *hargr...@us.ibm.com* hargr...@us.ibm.com office: *+1 386 848 1781* %2B1%20386%20848%201781 mobile: *+1 386 848 3788* %2B1%20386%20848%203788 From:Raymond Auge *raymond.a...@liferay.com* raymond.a...@liferay.com To:Equinox development mailing list *equinox-dev@eclipse.org* equinox-dev@eclipse.org Date:2014/07/28 16:02 Subject:Re: [equinox-dev] Resource not found inside bundle Sent by:*equinox-dev-boun...@eclipse.org* equinox-dev-boun...@eclipse.org -- That file is not in the classpath of the bundle and so you can't use the resource API. However, you can use the entry API (which talks about the bundle rather than about the bundle's classpath). e.g. URL url = bundle.getEntry(api_mapping.xml); IF you have a class however, and you need to get to the bundle of the class, you can do Bundle bundle = FrameworkUtil.getbundle(this.getClass()); URL url = bundle.getEntry(api_mapping.xml); HTH On Mon, Jul 28, 2014 at 12:57 PM, David Cao *govel...@gmail.com* govel...@gmail.com wrote: Hello there, I have a bundle jar file basically converted from a .war file, with Bundle-ClassPath set as follow, Bundle-Localization: plugin Bundle-ClassPath: *WEB-INF/classes*, WEB-INF/lib/activation-1.1.jar, WEB-INF/lib/antlr-2.7.5.jar, ... Import-Package: javax.servlet, javax.servlet.http, org.osgi.framework;version=1.3.0, org.osgi.service.http;version=1.2.0, org.osgi.util.tracker;version=1.3.1 There is an internal class which depends on a api_mapping.xml file which is located under *WEB-INF/classes* (shown below). However, the class complains unable to find the .xml file. I wonder if I missed some manifest descriptors for resources? does anyone have an idea why this is happening? Thanks a lot!! ___ equinox-dev mailing list *equinox-dev@eclipse.org* equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit *https://dev.eclipse.org/mailman/listinfo/equinox-dev* https://dev.eclipse.org/mailman/listinfo/equinox-dev -- *Raymond Augé* http://www.liferay.com/web/raymond.auge/profile (@rotty3000) Senior Software Architect *Liferay, Inc.* http://www.liferay.com/ (@Liferay) ___ equinox-dev mailing list *equinox-dev@eclipse.org* equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit *https://dev.eclipse.org/mailman/listinfo/equinox-dev* https://dev.eclipse.org/mailman/listinfo/equinox-dev ___ equinox-dev mailing list *equinox-dev@eclipse.org* equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit *https://dev.eclipse.org/mailman/listinfo/equinox-dev* https://dev.eclipse.org/mailman/listinfo
Re: [equinox-dev] Resource not found inside bundle
That file is not in the classpath of the bundle and so you can't use the resource API. However, you can use the entry API (which talks about the bundle rather than about the bundle's classpath). e.g. URL url = bundle.getEntry(api_mapping.xml); IF you have a class however, and you need to get to the bundle of the class, you can do Bundle bundle = FrameworkUtil.getbundle(this.getClass()); URL url = bundle.getEntry(api_mapping.xml); HTH On Mon, Jul 28, 2014 at 12:57 PM, David Cao govel...@gmail.com wrote: Hello there, I have a bundle jar file basically converted from a .war file, with Bundle-ClassPath set as follow, Bundle-Localization: plugin Bundle-ClassPath: *WEB-INF/classes*, WEB-INF/lib/activation-1.1.jar, WEB-INF/lib/antlr-2.7.5.jar, ... Import-Package: javax.servlet, javax.servlet.http, org.osgi.framework;version=1.3.0, org.osgi.service.http;version=1.2.0, org.osgi.util.tracker;version=1.3.1 There is an internal class which depends on a api_mapping.xml file which is located under *WEB-INF/classes* (shown below). However, the class complains unable to find the .xml file. I wonder if I missed some manifest descriptors for resources? does anyone have an idea why this is happening? Thanks a lot!! ___ equinox-dev mailing list equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/equinox-dev -- *Raymond Augé* http://www.liferay.com/web/raymond.auge/profile (@rotty3000) Senior Software Architect *Liferay, Inc.* http://www.liferay.com (@Liferay) ___ equinox-dev mailing list equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/equinox-dev
Re: [equinox-dev] Resource not found inside bundle
That file does appear to be in the classpath. The picture shows it in WEB-INF/classes which is in the Bundle-ClassPath. What does the code look like that is trying to access the file? -- BJ Hargrave Senior Technical Staff Member, IBM OSGi Fellow and CTO of the OSGi Alliance hargr...@us.ibm.com office: +1 386 848 1781 mobile: +1 386 848 3788 From: Raymond Auge raymond.a...@liferay.com To: Equinox development mailing list equinox-dev@eclipse.org Date: 2014/07/28 16:02 Subject:Re: [equinox-dev] Resource not found inside bundle Sent by:equinox-dev-boun...@eclipse.org That file is not in the classpath of the bundle and so you can't use the resource API. However, you can use the entry API (which talks about the bundle rather than about the bundle's classpath). e.g. URL url = bundle.getEntry(api_mapping.xml); IF you have a class however, and you need to get to the bundle of the class, you can do Bundle bundle = FrameworkUtil.getbundle(this.getClass()); URL url = bundle.getEntry(api_mapping.xml); HTH On Mon, Jul 28, 2014 at 12:57 PM, David Cao govel...@gmail.com wrote: Hello there, I have a bundle jar file basically converted from a .war file, with Bundle-ClassPath set as follow, Bundle-Localization: plugin Bundle-ClassPath: WEB-INF/classes, WEB-INF/lib/activation-1.1.jar, WEB-INF/lib/antlr-2.7.5.jar, ... Import-Package: javax.servlet, javax.servlet.http, org.osgi.framework;version=1.3.0, org.osgi.service.http;version=1.2.0, org.osgi.util.tracker;version=1.3.1 There is an internal class which depends on a api_mapping.xml file which is located under WEB-INF/classes (shown below). However, the class complains unable to find the .xml file. I wonder if I missed some manifest descriptors for resources? does anyone have an idea why this is happening? Thanks a lot!! ___ equinox-dev mailing list equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/equinox-dev -- Raymond Augé (@rotty3000) Senior Software Architect Liferay, Inc. (@Liferay) ___ equinox-dev mailing list equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/equinox-dev ___ equinox-dev mailing list equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/equinox-dev
Re: [equinox-dev] Resource not found inside bundle
Yup, sorry, I fudged on the image. On Mon, Jul 28, 2014 at 1:14 PM, BJ Hargrave hargr...@us.ibm.com wrote: That file does appear to be in the classpath. The picture shows it in WEB-INF/classes which is in the Bundle-ClassPath. What does the code look like that is trying to access the file? -- *BJ Hargrave* Senior Technical Staff Member, IBM OSGi Fellow and CTO of the *OSGi Alliance* http://www.osgi.org/ *hargr...@us.ibm.com* hargr...@us.ibm.com office: +1 386 848 1781 mobile: +1 386 848 3788 From:Raymond Auge raymond.a...@liferay.com To:Equinox development mailing list equinox-dev@eclipse.org Date:2014/07/28 16:02 Subject:Re: [equinox-dev] Resource not found inside bundle Sent by:equinox-dev-boun...@eclipse.org -- That file is not in the classpath of the bundle and so you can't use the resource API. However, you can use the entry API (which talks about the bundle rather than about the bundle's classpath). e.g. URL url = bundle.getEntry(api_mapping.xml); IF you have a class however, and you need to get to the bundle of the class, you can do Bundle bundle = FrameworkUtil.getbundle(this.getClass()); URL url = bundle.getEntry(api_mapping.xml); HTH On Mon, Jul 28, 2014 at 12:57 PM, David Cao *govel...@gmail.com* govel...@gmail.com wrote: Hello there, I have a bundle jar file basically converted from a .war file, with Bundle-ClassPath set as follow, Bundle-Localization: plugin Bundle-ClassPath: *WEB-INF/classes*, WEB-INF/lib/activation-1.1.jar, WEB-INF/lib/antlr-2.7.5.jar, ... Import-Package: javax.servlet, javax.servlet.http, org.osgi.framework;version=1.3.0, org.osgi.service.http;version=1.2.0, org.osgi.util.tracker;version=1.3.1 There is an internal class which depends on a api_mapping.xml file which is located under *WEB-INF/classes* (shown below). However, the class complains unable to find the .xml file. I wonder if I missed some manifest descriptors for resources? does anyone have an idea why this is happening? Thanks a lot!! ___ equinox-dev mailing list *equinox-dev@eclipse.org* equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit *https://dev.eclipse.org/mailman/listinfo/equinox-dev* https://dev.eclipse.org/mailman/listinfo/equinox-dev -- *Raymond Augé* http://www.liferay.com/web/raymond.auge/profile (@rotty3000) Senior Software Architect *Liferay, Inc.* http://www.liferay.com/ (@Liferay) ___ equinox-dev mailing list equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/equinox-dev ___ equinox-dev mailing list equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/equinox-dev -- *Raymond Augé* http://www.liferay.com/web/raymond.auge/profile (@rotty3000) Senior Software Architect *Liferay, Inc.* http://www.liferay.com (@Liferay) ___ equinox-dev mailing list equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/equinox-dev
Re: [equinox-dev] Resource not found inside bundle
So I see conflict answers ... [?] To Raymond, I will give a quick try from the Activator of your method. Thank!! To BJ, the code is something like this, ClassLoader loader = Thread.currentThread().getContextClassLoader(); ... EnumerationURL urls = loader.getResources(api_mapping.xml); ... Do you see a problem? What I am doing here is to convert an existing web app into OSGi framework via Servlet bridge for Tomcat 6. The classloading code is from the non-bundle web app ... thanks a lot!! On Mon, Jul 28, 2014 at 5:14 PM, BJ Hargrave hargr...@us.ibm.com wrote: That file does appear to be in the classpath. The picture shows it in WEB-INF/classes which is in the Bundle-ClassPath. What does the code look like that is trying to access the file? -- *BJ Hargrave* Senior Technical Staff Member, IBM OSGi Fellow and CTO of the *OSGi Alliance* http://www.osgi.org/ *hargr...@us.ibm.com* hargr...@us.ibm.com office: +1 386 848 1781 mobile: +1 386 848 3788 From:Raymond Auge raymond.a...@liferay.com To:Equinox development mailing list equinox-dev@eclipse.org Date:2014/07/28 16:02 Subject:Re: [equinox-dev] Resource not found inside bundle Sent by:equinox-dev-boun...@eclipse.org -- That file is not in the classpath of the bundle and so you can't use the resource API. However, you can use the entry API (which talks about the bundle rather than about the bundle's classpath). e.g. URL url = bundle.getEntry(api_mapping.xml); IF you have a class however, and you need to get to the bundle of the class, you can do Bundle bundle = FrameworkUtil.getbundle(this.getClass()); URL url = bundle.getEntry(api_mapping.xml); HTH On Mon, Jul 28, 2014 at 12:57 PM, David Cao *govel...@gmail.com* govel...@gmail.com wrote: Hello there, I have a bundle jar file basically converted from a .war file, with Bundle-ClassPath set as follow, Bundle-Localization: plugin Bundle-ClassPath: *WEB-INF/classes*, WEB-INF/lib/activation-1.1.jar, WEB-INF/lib/antlr-2.7.5.jar, ... Import-Package: javax.servlet, javax.servlet.http, org.osgi.framework;version=1.3.0, org.osgi.service.http;version=1.2.0, org.osgi.util.tracker;version=1.3.1 There is an internal class which depends on a api_mapping.xml file which is located under *WEB-INF/classes* (shown below). However, the class complains unable to find the .xml file. I wonder if I missed some manifest descriptors for resources? does anyone have an idea why this is happening? Thanks a lot!! ___ equinox-dev mailing list *equinox-dev@eclipse.org* equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit *https://dev.eclipse.org/mailman/listinfo/equinox-dev* https://dev.eclipse.org/mailman/listinfo/equinox-dev -- *Raymond Augé* http://www.liferay.com/web/raymond.auge/profile (@rotty3000) Senior Software Architect *Liferay, Inc.* http://www.liferay.com/ (@Liferay) ___ equinox-dev mailing list equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/equinox-dev ___ equinox-dev mailing list equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/equinox-dev ___ equinox-dev mailing list equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/equinox-dev
Re: [equinox-dev] Resource not found inside bundle
The problem is: What is the context class loader of the thread? Did you set one up? OSGi is generally mute on the subject of context class loaders and does not mess with them. Since you know that the resource is visible to your bundle, it would be better to use your class' class loader to call getResources. ClassLoader loader = getClass().getClassLoader(); ... EnumerationURL urls = loader.getResources(api_mapping.xml); -- BJ Hargrave Senior Technical Staff Member, IBM OSGi Fellow and CTO of the OSGi Alliance hargr...@us.ibm.com office: +1 386 848 1781 mobile: +1 386 848 3788 From: David Cao govel...@gmail.com To: Equinox development mailing list equinox-dev@eclipse.org Date: 2014/07/28 16:51 Subject:Re: [equinox-dev] Resource not found inside bundle Sent by:equinox-dev-boun...@eclipse.org So I see conflict answers ... To Raymond, I will give a quick try from the Activator of your method. Thank!! To BJ, the code is something like this, ClassLoader loader = Thread.currentThread().getContextClassLoader(); ... EnumerationURL urls = loader.getResources(api_mapping.xml); ... Do you see a problem? What I am doing here is to convert an existing web app into OSGi framework via Servlet bridge for Tomcat 6. The classloading code is from the non-bundle web app ... thanks a lot!! On Mon, Jul 28, 2014 at 5:14 PM, BJ Hargrave hargr...@us.ibm.com wrote: That file does appear to be in the classpath. The picture shows it in WEB-INF/classes which is in the Bundle-ClassPath. What does the code look like that is trying to access the file? -- BJ Hargrave Senior Technical Staff Member, IBM OSGi Fellow and CTO of the OSGi Alliance hargr...@us.ibm.com office: +1 386 848 1781 mobile: +1 386 848 3788 From:Raymond Auge raymond.a...@liferay.com To:Equinox development mailing list equinox-dev@eclipse.org Date:2014/07/28 16:02 Subject:Re: [equinox-dev] Resource not found inside bundle Sent by:equinox-dev-boun...@eclipse.org That file is not in the classpath of the bundle and so you can't use the resource API. However, you can use the entry API (which talks about the bundle rather than about the bundle's classpath). e.g. URL url = bundle.getEntry(api_mapping.xml); IF you have a class however, and you need to get to the bundle of the class, you can do Bundle bundle = FrameworkUtil.getbundle(this.getClass()); URL url = bundle.getEntry(api_mapping.xml); HTH On Mon, Jul 28, 2014 at 12:57 PM, David Cao govel...@gmail.com wrote: Hello there, I have a bundle jar file basically converted from a .war file, with Bundle-ClassPath set as follow, Bundle-Localization: plugin Bundle-ClassPath: WEB-INF/classes, WEB-INF/lib/activation-1.1.jar, WEB-INF/lib/antlr-2.7.5.jar, ... Import-Package: javax.servlet, javax.servlet.http, org.osgi.framework;version=1.3.0, org.osgi.service.http;version=1.2.0, org.osgi.util.tracker;version=1.3.1 There is an internal class which depends on a api_mapping.xml file which is located under WEB-INF/classes (shown below). However, the class complains unable to find the .xml file. I wonder if I missed some manifest descriptors for resources? does anyone have an idea why this is happening? Thanks a lot!! ___ equinox-dev mailing list equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/equinox-dev -- Raymond Augé (@rotty3000) Senior Software Architect Liferay, Inc. (@Liferay) ___ equinox-dev mailing list equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/equinox-dev ___ equinox-dev mailing list equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/equinox-dev ___ equinox-dev mailing list equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/equinox-dev ___ equinox-dev mailing list equinox-dev@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/equinox-dev