I'm currently embedding Jetty in the felix framework, using the examples
provided on the felix website:
http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html
and
http://felix.apache.org/documentation/subprojects/apache-felix-http-service.html
Basically, I create my own application that embeds Felix (using the code
provided by the first example), then I launch the Jetty bundle and I try
to access to that web server (using the code provided by the second
example).
The Jetty bundle starts correctly, then I get this very strange error at
runtime (java.lang.ClassCastException: ...cannot be cast to) when I try
to use the context to get the HttpService:
===============================================================
BundleContext context= m_fwk.getBundleContext();
ServiceReference sRef = context.getServiceReference(
HttpService.class.getName());
if (sRef != null)
{
HttpService service = (HttpService) context.getService(sRef);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
HttpContext myHttpContext = new MyHttpContext());
service.registerResources("/static", "/etc/www", myHttpContext);
}
================================================================
When this line is executed, I get this exception:
----------------------------------------------------------------
java.lang.ClassCastException:
org.apache.felix.http.base.internal.service.HttpServiceImpl
cannot be cast to org.osgi.service.http.HttpService
at main.HostApplication.main(HostApplication.java:197)
----------------------------------------------------------------
What I am doing wrong?
fulvio
PS I use javac to compile, and java to execute (no Eclipse, no maven, etc).
Libraries (both to compile and to exec):
- org.apache.felix.main-4.2.1
- org.apache.felix.http.jetty-2.2.0
OSGI bundles:
- org.apache.felix.http.jetty-2.2.0
- org.apache.felix.gogo.shell-0.10.0
- org.apache.felix.gogo.runtime-0.10.0
- org.apache.felix.gogo.command-0.12.0
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]