Hi denghui, I'm not a Gemini web expert, but I doubt someone could tell you the exact reason for your problem without providing more information about your setup. I think that if you provide a simple example that demonstrates the issue you will get more support. Can you do that? Stack trace you provided shows two errors:
Cannot cast com.testorg.sdnc.northbound.customservletcontainerinit.BundleServletContainerInitializer to javax.servlet.ServletContainerInitializer Cannot cast com.huawei.sdnc.northbound.customservletcontainerinit.BundleServletContainerInitializer to javax.servlet.ServletContainerInitializer Does this mean that you have one BundleServletContainerInitializer that extends from another? Are both in the same jar? Detelin On Wed, Jul 16, 2014 at 5:23 PM, huangdenghui <[email protected]> wrote: > Hi > Any comment on this error? > > --denghui > ------------------------------ > From: [email protected] > To: [email protected] > Date: Mon, 14 Jul 2014 15:09:03 +0000 > > Subject: Re: [gemini-dev] Need help for gemini web. > > Hi > > I refer this blog > <http://piotrnowicki.com/2011/03/using-servlets-3-0-servletcontainerinitializer/http://> > <http://piotrnowicki.com/2011/03/using-servlets-3-0-servletcontainerinitializer/http://> > http://piotrnowicki.com/2011/03/using-servlets-3-0-servletcontainerinitializer > to write a new java file named BundleServletContainerInitializer which > implement interface ServletContainerInitializer, it override function > onStartup(Set<Class<?>> c, ServletContext ctx) , i don't do any complicate > implementation but print some logs, and build it into a separated Jar, then > put it into WEB-INF/lib/ directory of web application bundle. at last, i > run felix again, i got the following error: > > > D:\work\felix-framework-4.2.1>java -Dlogback.configurationFile=logback.xml > -Dlog > 4j.configuration=file:log4j.properties -jar bin/felix.jar > Auto-properties start: > file:thirdpart/dep/org.apache.catalina.ha-7.0.53.v2014060 > 70630.jar (org.osgi.framework.BundleException: Fragment bundles can not be > start > ed.) > Auto-properties start: > file:thirdpart/dep/org.apache.catalina.tribes-7.0.53.v201 > 406070630.jar (org.osgi.framework.BundleException: Fragment bundles can not > be s > tarted.) > Auto-properties start: > file:thirdpart/dep/org.apache.coyote-7.0.53.v201406070630 > .jar (org.osgi.framework.BundleException: Fragment bundles can not be > started.) > Auto-properties start: > file:thirdpart/dep/org.apache.jasper-7.0.53.v201406070630 > .jar (org.osgi.framework.BundleException: Fragment bundles can not be > started.) > Auto-properties start: > file:thirdpart/dep/org.apache.tomcat.util-7.0.53.v2014060 > 70630.jar (org.osgi.framework.BundleException: Fragment bundles can not be > start > ed.) > Auto-properties start: > file:thirdpart/dep/org.apache.tomcat.websocket-7.0.53.v20 > 1406070630.jar (org.osgi.framework.BundleException: Fragment bundles can not > be > started.) > ____________________________ > Welcome to Apache Felix Gogo > > g! 七月 14, 2014 5:24:48 下午 org.apache.catalina.core.AprLifecycleListener init > > INFO: The APR based Apache Tomcat Native library which allows optimal > performanc > e in production environments was not found on the java.library.path: > C:\Windows\ > system32;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\syste > m32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1 > .0\;C:\Program Files\SinoVoice\jTTS 5.0 Desktop\Bin;C:\Program > Files\Citrix\Syst > em32\;C:\Program Files\Citrix\ICAService\;C:\PROGRA~1\ULTRAE~1;C:\Program > Files\ > TortoiseGit\bin;C:\Python27;C:\Program > Files\TortoiseSVN\bin;D:\soft\apache-mave > n-3.1.0\bin;D:\soft\apache-maven-3.1.0\bin;. > 七月 14, 2014 5:24:48 下午 org.apache.coyote.AbstractProtocol init > INFO: Initializing ProtocolHandler ["http-bio-8080"] > 七月 14, 2014 5:24:48 下午 org.apache.catalina.mbeans.GlobalResourcesLifecycleLi > stener createMBeans > SEVERE: No global naming context defined for server > 七月 14, 2014 5:24:48 下午 org.apache.catalina.core.StandardService startInterna > l > INFO: Starting service Catalina > 七月 14, 2014 5:24:48 下午 org.apache.catalina.core.StandardEngine startInternal > > INFO: Starting Servlet Engine: Apache Tomcat/7.0.53 > 七月 14, 2014 5:24:48 下午 org.apache.coyote.AbstractProtocol start > INFO: Starting ProtocolHandler ["http-bio-8080"] > GossipRouter started at Mon Jul 14 17:24:51 GMT+08:00 2014 > Listening on port 12001 bound on address 0.0.0.0/0.0.0.0 > Backlog is 1000, linger timeout is 2000, and read timeout is 0 > 七月 14, 2014 5:25:04 下午 org.glassfish.jersey.server.ApplicationHandler initia > lize > INFO: Initiating Jersey application, version Jersey: 2.4 2013-10-24 > 18:25:49... > 七月 14, 2014 5:25:04 下午 org.apache.catalina.startup.ContextConfig processServ > letContainerInitializers > SEVERE: Failed to process JAR found at URL [/controller/nb/cluster] for > ServletC > ontainerInitializers for context with name [{1}] > java.io.IOException: java.lang.ClassCastException: Cannot cast > com.testorg.sdnc.n > orthbound.customservletcontainerinit.BundleServletContainerInitializer to > javax. > servlet.ServletContainerInitializer > at > org.apache.catalina.startup.WebappServiceLoader.loadServices(WebappSe > rviceLoader.java:196) > at > org.apache.catalina.startup.WebappServiceLoader.load(WebappServiceLoa > der.java:152) > at > org.apache.catalina.startup.ContextConfig.processServletContainerInit > ializers(ContextConfig.java:1543) > at > org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.jav > a:1265) > at > org.apache.catalina.startup.ContextConfig.configureStart(ContextConfi > g.java:873) > at > org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi > g.java:371) > at > org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl > eSupport.java:117) > at > org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBa > se.java:90) > at > org.apache.catalina.core.StandardContext.startInternal(StandardContex > t.java:5355) > at > org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) > at > org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase > .java:901) > at > org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:87 > 7) > at > org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632) > > at > org.eclipse.gemini.web.tomcat.internal.TomcatServletContainer.startWe > bApplication(TomcatServletContainer.java:125) > at > org.eclipse.gemini.web.internal.StandardWebApplication.start(Standard > WebApplication.java:109) > at > org.eclipse.gemini.web.extender.WebContainerBundleCustomizer.addingBu > ndle(WebContainerBundleCustomizer.java:49) > at > org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTr > acker.java:467) > at > org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTr > acker.java:414) > at > org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.jav > a:256) > at > org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) > > at > org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTrack > er.java:443) > at > org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerC > allback(EventDispatcher.java:868) > at > org.apache.felix.framework.util.EventDispatcher.fireEventImmediately( > EventDispatcher.java:789) > at > org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(Event > Dispatcher.java:514) > at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4403) > at org.apache.felix.framework.Felix.startBundle(Felix.java:2092) > at > org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1291) > > at > org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStart > LevelImpl.java:304) > at java.lang.Thread.run(Unknown Source) > Caused by: java.lang.ClassCastException: Cannot cast > com.huawei.sdnc.northbound. > customservletcontainerinit.BundleServletContainerInitializer to > javax.servlet.Se > rvletContainerInitializer > at java.lang.Class.cast(Unknown Source) > at > org.apache.catalina.startup.WebappServiceLoader.loadServices(WebappSe > rviceLoader.java:188) > ... 28 more > > 七月 14, 2014 5:25:04 下午 org.apache.catalina.startup.ContextConfig configureSt > art > SEVERE: Marking this application unavailable due to previous error(s) > 七月 14, 2014 5:25:04 下午 org.apache.catalina.core.StandardContext startInterna > l > SEVERE: Error getConfigured > 七月 14, 2014 5:25:04 下午 org.apache.catalina.core.StandardContext startInterna > l > SEVERE: Context [/controller/nb/cluster] startup failed due to previous errors > > seems that i use the wrong jar for interface ServletContainerInitializer, I > use > servlet-api.jar, could you please tell me which jar package is right one? > > > --denghui > > > > > ------------------------------ > Date: Thu, 10 Jul 2014 18:13:44 +0300 > From: [email protected] > To: [email protected] > Subject: Re: [gemini-dev] Need help for gemini web. > > Hi, > > Gemini Web will initialize ServletContainerInitializer placed in > WEB-INF/lib/*.jar or placed in a bundle that is required by web app bundle > i.e import-packages or require-bundle. > > Or you can use JarScannerCustomizer - here [1] you can find an example. > > You can use one of these three methods depending on the scenario. > > Regards, > Violeta > > [1] > http://git.eclipse.org/c/gemini.web/org.eclipse.gemini.web.gemini-web-container.git/tree/test-bundles/customizer-bundle > > http://git.eclipse.org/c/gemini.web/org.eclipse.gemini.web.gemini-web-container.git/tree/org.eclipse.gemini.web.test/src/test/java/org/eclipse/gemini/web/test/tomcat/TomcatServletContainerTests.java > -> testCustomizers() > > > 2014-07-10 17:41 GMT+03:00 huangdenghui <[email protected]>: > > Hi Violeta > Thanks for your quickly reply. Yes, i already download felix and > Gemini web bundles, then start felix with > "java -jar bin/felix.jar", all Gemini web bundles start successfully. > > Let's firstly describe what i am done, then describe what problem i > met, I have several bundles to provide web service, just like hosttracker > module from opendaylight, please refer > https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=tree;f=opendaylight/northbound/hosttracker;hb=eee61ea351b6179d2862dce6875bdc25dd0fb272, > it has a web.xml to describe this web application's attribute, such as > servlet class, please refer hosttracker's web.xml > https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=tree;f=opendaylight/northbound/hosttracker/src/main/resources/WEB-INF;h=b42ae8116d116e38e6cf44eaffda6daeeba3b97c;hb=eee61ea351b6179d2862dce6875bdc25dd0fb272 > > Now, coming to my problem, > > after start gemini web, when web application bundled get start, gemini web > will found it is web application, it will try to allocate one context > container for it, this is my understanding, if it is wrong, please correct > me, > > my error log is > > can't find JAR for some web application URL ServletContainerInitializer > > so because this error, gemini web mark that web application unavailable. > > Then i follow this article > <http://stackoverflow.com/questions/10776599/servletcontainerinitializer-vs-servletcontextlistener> > http://stackoverflow.com/questions/10776599/servletcontainerinitializer-vs-servletcontextlistener > > to custom my servletcontainerinitializer, but still it doesn't work, > > also i read tomcat source code, there is some code section to check > whether the servletcontainerinitializer existed? > > > but technically, the ServletContainerInitializer > <http://download.oracle.com/javaee/6/api/javax/servlet/ServletContainerInitializer.html> > is not a listener – it is an initializer and it’s executed *before* any > servlet context will even be ready. You can use this initializer to do some > programatic servlet/filters/listeners addition, > > So, is there any configuration option to make gemini web not to check it. > > > ------------------------------ > Date: Wed, 9 Jul 2014 21:31:08 +0300 > From: [email protected] > To: [email protected] > Subject: Re: [gemini-dev] Need help for gemini web. > > > Hi, > > Just download felix [1], then extract its archive and put all 34 Gemini > Web bundles in the "bundle" directory. > Then start felix with "java -jar bin/felix.jar". > That's all. > > Regards > Violeta > > [1] http://felix.apache.org/downloads.cgi -> Felix Framework Distribution > > > > > 2014-07-09 19:01 GMT+03:00 huangdenghui <[email protected]>: > > > > Hi team, > > > > > > I want to use gemini web to implement web application in OSGI > environment to support northbound API in one SDN controller, just like > opendaylight project does, but i use different OSGI container from > opendaylight, my project is based on felix, opendaylight is based on > equinox. So is there any docs about how to configure gemini web in felix > OSGI environment? Yes, i check user guide, but it don't provide very > detailed information for how to configure it. > > > > --denghui > > > > > > _______________________________________________ > > gemini-dev mailing list > > [email protected] > > To change your delivery options, retrieve your password, or unsubscribe > from this list, visit > > https://dev.eclipse.org/mailman/listinfo/gemini-dev > > _______________________________________________ gemini-dev mailing list > [email protected] To change your delivery options, retrieve your > password, or unsubscribe from this list, visit > https://dev.eclipse.org/mailman/listinfo/gemini-dev > > _______________________________________________ > gemini-dev mailing list > [email protected] > To change your delivery options, retrieve your password, or unsubscribe > from this list, visit > https://dev.eclipse.org/mailman/listinfo/gemini-dev > > > > _______________________________________________ gemini-dev mailing list > [email protected] To change your delivery options, retrieve your > password, or unsubscribe from this list, visit > https://dev.eclipse.org/mailman/listinfo/gemini-dev > > _______________________________________________ gemini-dev mailing list > [email protected] To change your delivery options, retrieve your > password, or unsubscribe from this list, visit > https://dev.eclipse.org/mailman/listinfo/gemini-dev > > _______________________________________________ > gemini-dev mailing list > [email protected] > To change your delivery options, retrieve your password, or unsubscribe > from this list, visit > https://dev.eclipse.org/mailman/listinfo/gemini-dev >
_______________________________________________ gemini-dev mailing list [email protected] To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/gemini-dev
