RE: [equinox-dev] getservice throws class cast exception
Hi, Thanks I got the problem solved as per your suggestion. However I could make it work with two bundles as per Toni's hint I included the jar in to the bundle one which was registering the service, this bundle exported the interface A. In the second bundle I just imported the interface A and retrieved the object and cast to A successfully. Thanks for your help and time. Cheers, Santosh Akhilesh ** This email and its attachments contain confidential information from HUAWEI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it! * -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Thursday, May 29, 2008 9:02 PM To: Equinox development mailing list Subject: Re: [equinox-dev] getservice throws class cast exception Santosh, You should not include the JAR that contains the interface in the classpath of the two bundles. You should make it into a third bundle and use Import-Package to depend on the interface. When a class is defined independently by two or more classloaders, the resulting classes are considered by the JVM to be different, even if they have exactly the same name and are defined from the same bytes on disk. Therefore you cannot cast an instance of one type into a field of the other. Regards Neil On 5/29/08, Santosh Akhilesh <[EMAIL PROTECTED]> wrote: > Dear All, > > > > I am new to OSGI and Equinox. > > > > I have defined an interface say A, this is defined in a project and exported > as jar > > > > Now I create Two OSGI bundles I include this jar in both the bundles. > > > > >From one bundle I implement the interface A and register the service to the > bundle context from second bundle I try to retrieve this service from bundle > context in the activator start function. > > > > I can see that service is retrieved but when I cast it to interface A, I get > class cast exception > > > > Any pointer why this happens and how to correct it. > > > > Regards, > > Santosh Akhilesh > > Ph: 9845482201 > > > > ___ equinox-dev mailing list equinox-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/equinox-dev ___ equinox-dev mailing list equinox-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/equinox-dev
[equinox-dev] p2 contribution to RC3
The following contributions from p2 are being made for the next 3.4 RC3 build: The map file has been updated for the following Bug changes: + Bug 232105. [ui] Banner message on install dialog is way too long when many IU's involved (FIXED) + Bug 232329. [ui] TVT34:TCT270: SV: Missing dialog/wizard help IDs (FIXED) + Bug 234036. [ui] Each keystroke in filter field gives error for missing repository (FIXED) The following projects have changed: org.eclipse.equinox.p2.metadata.generator org.eclipse.equinox.p2.ui.sdk org.eclipse.equinox.p2.ui.admin.rcp org.eclipse.equinox.p2.ui org.eclipse.equinox.p2.director.app___ equinox-dev mailing list equinox-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/equinox-dev
[equinox-dev] Need help building a product with p2
I've received some help from Andrew in this Bugzilla (https://bugs.eclipse.org/bugs/show_bug.cgi?id=226614) but I'm still having problems so I thought I'd take it to the list rather than in that Bugzilla. We've been shipping an IDE product based on Eclipse for a few years now. The way we've built our product in the past is essentially this: 1) Download the platform runtime, EMF, GEF, etc.. from eclipse.org and extract them into a product layout directory. 2) Checkout and tag our features and plugins 3) Use headless feature build on all of our features, and extract the generated archives into the product layout directory. 4) Copy our modified version of config.ini, .eclipseproduct, etc. into the product layout directory. 5) Generate an update site based on the generated features/plugins. This gives us a full product layout for new installs, and allows users with older installs of our product to update to the new version using the update site. This process broke when we moved to Eclipse 3.4M6 when p2 was introduced. I've come to discover that we weren't really building it in the ideal fashion to begin with, so I'm trying to do it the proper way so we can get a properly p2-ized product layout and update site. Andrew provided several useful links in that Bugzilla. I've read about doing product builds, using the p2 meta generator and p2 director. I've also played with the examples from EclipseCon presentation. Here are some of the problems I'm having: 1) I created a .product file based on features. I included our features as well as those org.eclipse features that we bundle with. When I export it using the PDE product export from the UI, it generates a directory containing everything we need - all features and plugins (ours and org.eclipse.*), our branded launcher and ini file, .eclipseproduct file, config.ini file, jre, etc.. It of course does not contain the p2 data though. I told the exporter to generate a metadata repository which it did. I think I'm then supposed to run it through the p2 director to get the proper p2 directory. I tried this, and it generated something, but I get the error "Cannot launch the Update UI. This installation has not been configured properly for Software Updates" when I try to go to Help->Software Updates. I assume I didn't get the command line correct for the p2 director. This is what I did: eclipsec.exe -nosplash -application org.eclipse.equinox.p2.director.app.application -metadataRepository C:\testproduct\repository\ -artifactRepository C:\testproduct\repository\ -destination C:\testproduct\eclipse\ -profile PlatformProfile -profileProperties org.eclipse.update.install.features=true -bundlepool C:\testproduct\eclipse -p2.os win32 -p2.ws win32 -p2.arch x86 -roaming -vmargs -Declipse.p2.data.area=C:\testproduct2\eclipse\p2 Any idea what I'm doing wrong? I thought I should be passing -installIU but wasn't sure what to pass with it. I tried the product id but it errored out saying it couldn't find the IU. 2) What I did in 1) was really just a test because we'll need to build everything from the command line and not from the export wizard. I tried to build the product from the command line and kept getting an error that org.eclipse.rcp could not be found. I removed all org.eclipse.* features from our product file and tried again. Now it builds, and it generates the repo directory because I added the stuff to our build.properties file as instructed: generate.p2.metadata=true p2.metadata.repo = file:${buildDirectory}/repo p2.artifact.repo = file:${buildDirectory}/repo p2.metadata.repo.name = Carbide.c++ Metadata Repository p2.artifact.repo.name = Carbide.c++ Artifact Repository p2.flavor = tooling p2.publish.artifacts=true This repo directory only contains the two xml files though (artifacts.xml and content.xml), unlike the product export which generated those as well as binary, features and plugins directories. The other issue is that none of the org.eclipse.* features/plugins are included. This is presumably because they're no longer in the .product file, but I had to do that to get the build to work. I tried creating a master feature which just required all of our features and the org.eclipse features, but still got the missing rcp error. Note: in the example2 from the EclispeCon zip, it builds a product and does include the org.eclipse stuff in the output. This example is based on plugins rather than features. This is the only meaningful difference I could see in the .product files. I'm also confused about the topLevelElementType and topLevelElementId attributes in the build.properties files. I couldn't find any documentation on these. Ideally I'd put type=product and id=our product id, and then I assume the installIU would be the product id? Anyway, sorry for the long email, but I'm stuck and could really use some help. Thanks, Warren ___ equinox-dev mailing list equinox-dev@eclipse.or
[equinox-dev] p2 build contribution
The map file has been updated for the following Bug changes: + Bug 215924. [prov] Metadata for fix pack aka patches (FIXED) + Bug 226852. director application need to change install folder when operating on a roaming profile (FIXED) + Bug 233201. Some servers return a webpage instead of the requested file. (FIXED) + Bug 234479. [ui] Typing in filter field in Available Updates can lose focus (FIXED) + Bug 234518. Retry with wrong artifact descriptor (FIXED) + Bug 234671. Bootstrap.product should be included in binary build of the reconciler.dropins bundle (FIXED) The following projects have changed: org.eclipse.equinox.p2.ui.admin.rcp org.eclipse.equinox.p2.reconciler.dropins org.eclipse.equinox.p2.ui org.eclipse.equinox.p2.artifact.repository org.eclipse.equinox.p2.metadata.generator org.eclipse.equinox.p2.updatesite org.eclipse.equinox.p2.director.app___ equinox-dev mailing list equinox-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/equinox-dev
[equinox-dev] Additional Equinox Contribution to RC3
The map file has been updated for the following Bug changes: + Bug 234689. Converting org.eclipse.equinox.security to use API tools (FIXED) The following projects have changed: org.eclipse.equinox.security.ui org.eclipse.equinox.security.win32.x86 Tom ___ equinox-dev mailing list equinox-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/equinox-dev
Re: [equinox-dev] getservice throws class cast exception
Hi, Thanks for your answers. Is there anyway to make it work ? I need to include the jar in to two bundles. Just for information my situation like this; 1. One java project containing interfaces and util exported as jar - util.jar 2. One java project implementing the OSGI Activator interface , this is implemented as abstract class providing two abstract interfaces bundleStart and bundleStop , from Activator method start and stop we call bundleStart and bundleStop implemented by OSGI bundles - wrapper.jar. This is to make sure that other bundles dont need to worry about OSGI things. In this wrapper we also provide functions to register services to bundle context and retrieving it. 3. Each OSGI bundle includes these two jars in their class path. 4. I have noticed that the wrapper.jar provides some APIs which can return the objects from the bundle context , their interfaces where defined in util.jar and implemented by one of the OSGI bundle and register to bundle context. 5. The casting problem comes only when I use this in start method of wrraper if I try to retrieve the object outside the start method it works. -- Regards, Santosh Akhilesh +91-0-9845482201 ___ equinox-dev mailing list equinox-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/equinox-dev
[equinox-dev] p2 projects tagged for build
The map file has been updated for the following Bug changes: + Bug 204209. [prov] Generated repo directory names don't match what colocated repo UI assumes (FIXED) + Bug 216911. [prov] Should IU's have multiple licenses (NEW) + Bug 217001. [prov] [ui] [metadata] can IU license and copyright properties be URLs? (FIXED) + Bug 222480. Some features in platform.xml not showing up in "About" dialog (FIXED) + Bug 229069. [ui] Two of every category or repository visible in available software tab (FIXED) + Bug 230245. Failure to read unicode (FIXED) + Bug 234177. Repository references not working in p2 metadata repositories (FIXED) + Bug 234520. eclipse.ini not created when installing I20080528-1327 (FIXED) The following projects have changed: org.eclipse.equinox.p2.director.app org.eclipse.equinox.p2.metadata.repository org.eclipse.equinox.p2.touchpoint.eclipse org.eclipse.equinox.p2.metadata.generator org.eclipse.equinox.frameworkadmin.equinox org.eclipse.equinox.p2.ui org.eclipse.equinox.p2.ui.admin.rcp org.eclipse.equinox.p2.core ___ equinox-dev mailing list equinox-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/equinox-dev
[equinox-dev] Equinox intends to contribute to RC3
The map file has been updated for the following Bug changes: + Bug 234439. The -debug flag no longer produces information about plugin resolution (ASSIGNED) The following projects have changed: org.eclipse.osgi Tom ___ equinox-dev mailing list equinox-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/equinox-dev
Re: [equinox-dev] Using Jetty in OSGi
I do not know much about Equinox OSGi implementation but I may give some answers based on my experience with Pax Web (also an HttpService implementation based on Jetty): 1. In may view everything it's okay as soon as it serves you goals. So, I would not see any problem in the fact that you implement your own http server based on Jetty. Just be sure that you wanna do so, at that will mean that you have to implement it, maintain it and so on, more or less by your own, compared with an implementation that is backed up by a community. Looking at your "future" goals you may wanna take a look at Pax Web Extender Web that allows you to deploy a war like bundle, by parsing your web.xml and register found elements. To have a full support you have to use Pax Web implementation of HttpService (because it has an extended HttpService implementation supporting listeners/filters/...). Just for a simple web.xml that uses only servlets/resources you can use it with any HttpService implementation as the one available from Equinox. If you want a direct integration with Jetty you may wanna take a look at Spring DM web support. 2. The problem is that you pass the class name to Jetty, and Jetty will try to instantiate the class, fact that will fail as Jetty will not see your bundle class space. I do not know how Equinox implementation actually uses Jetty but in principle you may want to pass an instance of the Servlet to Jetty not the class name. As an example you can take a look here for how you can do that,, and look for add servlet: https://scm.ops4j.org/repos/ops4j/projects/pax/web/bundle/src/main/java/org/ops4j/pax/web/service/internal/JettyServerImpl.java I suppose that Simon can give you more details about the Equinox implementation. HTH, Alin Dreghiciu On Thu, May 29, 2008 at 12:22 PM, Srijith Kochunni <[EMAIL PROTECTED]> wrote: > Hi All, > > I am trying to deploy Jetty server in my Equinox OSGi runtime. I was > able to deploy the org.mortbay.jetty jar and the additional equinox jars and > was able to register my servlet using OSGi http service and was able to view > the same in browser. But my requirement is that I want to design so that in > future i might be able to provide a container where web applications can be > deployed as well. Therefore i want to directly use org.mortbay.jetty.Server > class to add my servlets rather than HttpService. > > Server server = new > Server(); > > SocketListener listener = new SocketListener(); > > listener.setPort(8080); > > server.addListener(listener); > > ServletHttpContext httpcontext = > (ServletHttpContext)server.getContext("/servlet"); > > httpcontext.addServlet("Hello", "/hello", "axisserver.HelloWorldServlet"); > > server.start(); > > Since I do not want the equinox http service to register and do the starting > up of the server, I load my OSGi runtime with org.mortbay.jetty jar alone > and start my bundle in which I have the above code snippet in the start > method of my activator. > > My first question is whether it is ok for me to do this within OSGi, or > should I always use only the HttpService interface provided my OSGi. ? > > The second question is > > The problem is that everytime I start my bundle, it gives me a > ClassNotFound exception and does not start. Have attached the stack trace. > The class is within my bundle, so am not able to understand why it is not > found. >From the stack trace understood that the mortbay bundle is probably > trying to load the class, therefore tried exporting my package as well, but > to no avail. Read in some of the jetty forums that these class loading > issues can be resolved by Eclipse Buddy policy. Am not sure how to use them. > Also read about how PDE can be helpful in deducting and fixing these class > loading issues. > > Any idea on how this issue can be fixed/ details on what HttpService is > doing extra while using Jetty Server, in order to put the classes in mortbay > jetty server`s space would be helpful > > Any help in this regard, would be greatly appreciated. > > P.S : Have herewith attached stack trace. > > Thanks, > > Srijith. > > ___ > equinox-dev mailing list > equinox-dev@eclipse.org > https://dev.eclipse.org/mailman/listinfo/equinox-dev > > -- Alin Dreghiciu http://www.ops4j.org - New Energy for OSS Communities - Open Participation Software. http://www.qi4j.org - New Energy for Java - Domain Driven Development. http://malaysia.jayway.net - New Energy for Projects - Great People working on Great Projects at Great Places ___ equinox-dev mailing list equinox-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/equinox-dev
Re: [equinox-dev] getservice throws class cast exception
Can you provide the manifest headers (content of META-INF/MANIFEST.MF in your jars) as well as exact contents? If its like you say, chances are that you didn't export/import the interface and this should result into ClassCast Exceptions.. Toni Original-Nachricht > Datum: Thu, 29 May 2008 20:45:52 +0530 > Von: Santosh Akhilesh <[EMAIL PROTECTED]> > An: equinox-dev@eclipse.org > Betreff: [equinox-dev] getservice throws class cast exception > Dear All, > > > > I am new to OSGI and Equinox. > > > > I have defined an interface say A, this is defined in a project and > exported > as jar > > > > Now I create Two OSGI bundles I include this jar in both the bundles. > > > > >>From one bundle I implement the interface A and register the service to > the > bundle context from second bundle I try to retrieve this service from > bundle > context in the activator start function. > > > > I can see that service is retrieved but when I cast it to interface A, I > get > class cast exception > > > > Any pointer why this happens and how to correct it. > > > > Regards, > > Santosh Akhilesh > > Ph: 9845482201 > > > ___ equinox-dev mailing list equinox-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/equinox-dev
Re: [equinox-dev] getservice throws class cast exception
Santosh, You should not include the JAR that contains the interface in the classpath of the two bundles. You should make it into a third bundle and use Import-Package to depend on the interface. When a class is defined independently by two or more classloaders, the resulting classes are considered by the JVM to be different, even if they have exactly the same name and are defined from the same bytes on disk. Therefore you cannot cast an instance of one type into a field of the other. Regards Neil On 5/29/08, Santosh Akhilesh <[EMAIL PROTECTED]> wrote: > Dear All, > > > > I am new to OSGI and Equinox. > > > > I have defined an interface say A, this is defined in a project and exported > as jar > > > > Now I create Two OSGI bundles I include this jar in both the bundles. > > > > >From one bundle I implement the interface A and register the service to the > bundle context from second bundle I try to retrieve this service from bundle > context in the activator start function. > > > > I can see that service is retrieved but when I cast it to interface A, I get > class cast exception > > > > Any pointer why this happens and how to correct it. > > > > Regards, > > Santosh Akhilesh > > Ph: 9845482201 > > > > ___ equinox-dev mailing list equinox-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/equinox-dev
[equinox-dev] getservice throws class cast exception
Dear All, I am new to OSGI and Equinox. I have defined an interface say A, this is defined in a project and exported as jar Now I create Two OSGI bundles I include this jar in both the bundles. >From one bundle I implement the interface A and register the service to the bundle context from second bundle I try to retrieve this service from bundle context in the activator start function. I can see that service is retrieved but when I cast it to interface A, I get class cast exception Any pointer why this happens and how to correct it. Regards, Santosh Akhilesh Ph: 9845482201 ___ equinox-dev mailing list equinox-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/equinox-dev
[equinox-dev] Using Jetty in OSGi
Hi All, I am trying to deploy Jetty server in my Equinox OSGi runtime. I was able to deploy the org.mortbay.jetty jar and the additional equinox jars and was able to register my servlet using OSGi http service and was able to view the same in browser. But my requirement is that I want to design so that in future i might be able to provide a container where web applications can be deployed as well. Therefore i want to directly use org.mortbay.jetty.Server class to add my servlets rather than HttpService. Server server = new Server(); SocketListener listener = new SocketListener(); listener.setPort(8080); server.addListener(listener); ServletHttpContext httpcontext = (ServletHttpContext)server.getContext("/servlet"); httpcontext.addServlet("Hello", "/hello", "axisserver.HelloWorldServlet"); server.start(); Since I do not want the equinox http service to register and do the starting up of the server, I load my OSGi runtime with org.mortbay.jetty jar alone and start my bundle in which I have the above code snippet in the start method of my activator. My first question is whether it is ok for me to do this within OSGi, or should I always use only the HttpService interface provided my OSGi. ? The second question is The problem is that everytime I start my bundle, it gives me a ClassNotFound exception and does not start. Have attached the stack trace. The class is within my bundle, so am not able to understand why it is not found. From the stack trace understood that the mortbay bundle is probably trying to load the class, therefore tried exporting my package as well, but to no avail. Read in some of the jetty forums that these class loading issues can be resolved by Eclipse Buddy policy. Am not sure how to use them. Also read about how PDE can be helpful in deducting and fixing these class loading issues. Any idea on how this issue can be fixed/ details on what HttpService is doing extra while using Jetty Server, in order to put the classes in mortbay jetty server`s space would be helpful Any help in this regard, would be greatly appreciated. P.S : Have herewith attached stack trace. Thanks, Srijith. osgi> start 24 May 29, 2008 3:14:50 PM org.mortbay.http.HttpServer doStart INFO: Version Jetty/5.1.x May 29, 2008 3:14:50 PM org.mortbay.http.SocketListener start INFO: Started SocketListener on 0.0.0.0:8080 org.mortbay.util.MultiException[java.lang.ClassNotFoundException: axisserver.HelloWorldServlet] at org.mortbay.http.HttpServer.doStart(HttpServer.java:686) at org.mortbay.util.Container.start(Container.java:72) at axisserver.Activator.start(Activator.java:44) at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:999) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:993) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:974) at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:346) at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:260) at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:252) at org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start(FrameworkCommandProvider.java:260) 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:597) at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute(FrameworkCommandInterpreter.java:145) at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(FrameworkConsole.java:291) at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(FrameworkConsole.java:276) at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(FrameworkConsole.java:218) at java.lang.Thread.run(Thread.java:619) java.lang.ClassNotFoundException: axisserver.HelloWorldServlet at java.lang.ClassLoader.findClass(ClassLoader.java:358) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at org.eclipse.core.runtime.internal.adaptor.ContextFinder.loadClass(ContextFinder.java:124) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at org.mortbay.http.HttpContext.loadClass(HttpContext.java:1227) at org.mortbay.jetty.servlet.Holder.start(Holder.java:188) at org.mortbay.jetty.servlet.ServletHolder.start(ServletHolder.java:219) at org.mortbay.jetty.s