Community
Participate
Working Groups
Build Identifier: I20120127-1145 !ENTRY org.eclipse.equinox.cm 4 0 2012-02-01 15:28:07.818 !MESSAGE java.lang.String cannot be cast to java.lang.Integer !STACK 0 java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer at org.eclipse.equinox.http.jetty.internal.HttpServerManager.createHttpConnector(HttpServerManager.java:134) at org.eclipse.equinox.http.jetty.internal.HttpServerManager.updated(HttpServerManager.java:72) at org.eclipse.equinox.internal.cm.ManagedServiceFactoryTracker$2.run(ManagedServiceFactoryTracker.java:190) at org.eclipse.equinox.internal.cm.SerializedTaskQueue$1.run(SerializedTaskQueue.java:36) 15:28:07.824 [com.c4biz.osgiutils.logging.reader.OsgiLogListener@831fb31] ERROR org.eclipse.equinox.cm - java.lang.String cannot be cast to java.lang.Integer java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer at org.eclipse.equinox.http.jetty.internal.HttpServerManager.createHttpConnector(HttpServerManager.java:134) ~[na:na] at org.eclipse.equinox.http.jetty.internal.HttpServerManager.updated(HttpServerManager.java:72) ~[na:na] at org.eclipse.equinox.internal.cm.ManagedServiceFactoryTracker$2.run(ManagedServiceFactoryTracker.java:190) ~[na:na] at org.eclipse.equinox.internal.cm.SerializedTaskQueue$1.run(SerializedTaskQueue.java:36) ~[na:na] Reproducible: Always Steps to Reproduce: 1. create a bundle with a Configuration Manager update properties = getJettyProperties(); configuration = configurationAdmin.createFactoryConfiguration( "org.eclipse.equinox.http.jetty.config", null); configuration.update(properties); 2. start the org.eclipse.equinox.http.jetty bundle using automatic activation 3. start the bundle with the new configuration
Created attachment 210399 [details] Fixed class I've used the "import plugin as source" to be able to fix it in a proper time to my job. So I'm sending it instead a patch.
please, forget the attached class.. I can't remove it. :( It doesn't resolve the problem since values of Dictionary could be others than Strings.
Hi Cristiano, than ks fr the report and the fix. It looks like a change in org.eclipse.equinox.http.jetty.internal.HttpServerManager: not specific to OSGi. If could post a diff it would really help to figure what you had to change.
Read the message on the mailing list: The change is here: Integer httpsPort = (Integer) dictionary.get(JettyConstants.HTTPS_PORT); if (httpsPort == null) return null; Unfortunately this code lives at equinox: org.eclipse.equinox.http.jetty.internal.HttpServerManager Have you tried setting up the system property as an integer instead of a string: System.setProperty("org.eclipse.equinox.http.jetty." + JettyConstants.HTTP_PORT, "8080"); set as: System.setProperty("org.eclipse.equinox.http.jetty." + JettyConstants.HTTP_PORT, 8080);
The system settings is not the problem because this code (@ Activator.java) treat the casting properly: // HTTP Port String httpPortProperty = context.getProperty(PROPERTY_PREFIX + JettyConstants.HTTP_PORT); if (httpPortProperty == null) httpPortProperty = context.getProperty(ORG_OSGI_SERVICE_HTTP_PORT); int httpPort = 80; if (httpPortProperty != null) { try { httpPort = Integer.parseInt(httpPortProperty); } catch (NumberFormatException e) { //(log this) ignore and use default } } The problem occurs if you try to modify the configuration using CM and do not use the right type, as you state. Unfortunately, my configuration data is coming from a properties file, so everything is a string...
Created attachment 210486 [details] HttpServerManager New class that added type tests to avoid casting errors.
(In reply to comment #3) > Hi Cristiano, than ks fr the report and the fix. > It looks like a change in > org.eclipse.equinox.http.jetty.internal.HttpServerManager: not specific to > OSGi. > If could post a diff it would really help to figure what you had to change. Please, could you tell me where is the repository containing the source? there are so many that i have no idea where could be this project... thanks
(In reply to comment #7) > (In reply to comment #3) > > Hi Cristiano, than ks fr the report and the fix. > > It looks like a change in > > org.eclipse.equinox.http.jetty.internal.HttpServerManager: not specific to > > OSGi. > > If could post a diff it would really help to figure what you had to change. > > > Please, could you tell me where is the repository containing the source? there > are so many that i have no idea where could be this project... > > thanks It is here: http://git.eclipse.org/c/equinox/rt.equinox.bundles.git/tree/bundles mirrored on github if you prefer that: https://github.com/eclipse/rt.equinox.bundles
Created attachment 210571 [details] this is the patch from git I couldn't find the org.eclipse.equinox.http.jetty folder, so I've supposed that could be this one: org.eclipse.equinox.http.jetty8
Hi Cristiano, I have moved this bug to the equinox project because this code is not part of the jetty code.
I don't think this is a bug. Configuration types are not restricted to be of type String only. The org.eclipse.equinox.http.jetty (8) bundle specifies the types expected with metatype xml (which can be inspected with the MetaTypeService). http://git.eclipse.org/c/equinox/rt.equinox.bundles.git/tree/bundles/org.eclipse.equinox.http.jetty8/OSGI-INF/metatype/config.xml I am not dead set against making this easier to use, but I also don't want to give you the impression that all configuration types are restricted to type string. Simon, what do you think about this change?
Thomas, I'm not inferring that all configuration are/should be String, but if you can't use metatype (as is the case where the configuration comes from System Properties) it should be properly treated. This is what was used in the Activator class to do that: // HTTP Port String httpPortProperty = context.getProperty(PROPERTY_PREFIX + JettyConstants.HTTP_PORT); if (httpPortProperty == null) httpPortProperty = context.getProperty(ORG_OSGI_SERVICE_HTTP_PORT); int httpPort = 80; if (httpPortProperty != null) { try { httpPort = Integer.parseInt(httpPortProperty); } catch (NumberFormatException e) { //(log this) ignore and use default } } So, the same should be applied to HttpServerManager, because are cases where you can't use metatype, mainly when you are getting configuration from a properties file. Treat each property from the property file doesn't make sense. It is much easier to treat the string.
I chatted with Simon briefly about this. We agreed that this is an enhancement request since you are not configuring the system in the original way it was designed. But the good news is that we don't see the harm in supporting your patch and will release it for Juno. Thanks for the contribution.
Released in commit: http://git.eclipse.org/c/equinox/rt.equinox.bundles.git/commit/?id=eb1acae0736de5106cfef9295fc81b2d865ed909
Hi Thomas, could you tell me if there are any p2 repository that contains the latest changes in equinox/rt bundles that I could point my project to ? cheers
(In reply to comment #15) > Hi Thomas, could you tell me if there are any p2 repository that contains the > latest changes in equinox/rt bundles that I could point my project to ? > > cheers you can download the p2 repo from our latest I-Build at http://download.eclipse.org/equinox/drops/I20120221-1514/index.php We used to include this content in the eclipse 3.8 I-Build repos (http://wiki.eclipse.org/Eclipse_Project_Update_Sites) but the equinox content does not seem to be included anymore. Kim, I think you still had an open issue on this?