ceugster (4) [Avatar] Offline
#1
<SOLVED> Chapter 2.4: SayHelloJNDI: java.lang.NoClassDefFoundError: javax/naming/NamingException
<SOLVED> I had to add package javax.naming to the business bundle.

Hi I am trying to build the fancyfood web app. I have all done as written in the book and checked all files over and over but could not find a cause nor a solution to my problem. When I deploy fancyfoods.web bundle (throwing in the deploy folder of karaf 4.2.0) I get the following stack trace:

2018-06-10T15:36:39,494 | ERROR | paxweb-extender-2-thread-1 | WebAppPublisher | 164 - org.ops4j.pax.web.pax-web-extender-war - 7.0.0 | Error deploying web application
java.lang.NoClassDefFoundError: javax/naming/NamingException
at java.lang.Class.getDeclaredConstructors0(Native Method) ~[?smilie]
at java.lang.Class.privateGetDeclaredConstructors(Class.java:3110) ~[?smilie]
at java.lang.Class.getConstructor0(Class.java:3315) ~[?smilie]
at java.lang.Class.newInstance(Class.java:530) ~[?smilie]
at org.eclipse.jetty.server.handler.ContextHandler$Context.createInstance(ContextHandler.java:2535) ~[?smilie]
at org.eclipse.jetty.servlet.ServletContextHandler$Context.createServlet(ServletContextHandler.java:1326) ~[?smilie]
at org.eclipse.jetty.servlet.ServletHolder.newInstance(ServletHolder.java:1273) ~[?smilie]
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:614) ~[?smilie]
at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:421) ~[?smilie]
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:760) ~[?smilie]
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:34smilie ~[?smilie]
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.startContext(HttpServiceContext.java:414) ~[?smilie]
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785) ~[?smilie]
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261) ~[?smilie]
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doStart(HttpServiceContext.java:267) ~[?smilie]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:6smilie ~[?smilie]
at org.ops4j.pax.web.service.jetty.internal.JettyServerImpl$1.start(JettyServerImpl.java:329) ~[?smilie]
at org.ops4j.pax.web.service.internal.HttpServiceStarted.end(HttpServiceStarted.java:1222) ~[?smilie]
at org.ops4j.pax.web.service.internal.HttpServiceProxy.end(HttpServiceProxy.java:456) ~[?smilie]
at org.ops4j.pax.web.extender.war.internal.RegisterWebAppVisitorWC.end(RegisterWebAppVisitorWC.java:404) ~[?smilie]
at org.ops4j.pax.web.extender.war.internal.model.WebApp.accept(WebApp.java:65smilie ~[?smilie]
at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.register(WebAppPublisher.java:22smilie ~[?smilie]
at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.addingService(WebAppPublisher.java:173) ~[?smilie]
at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.addingService(WebAppPublisher.java:129) ~[?smilie]
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941) ~[?smilie]
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:870) ~[?smilie]
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) ~[?smilie]
at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183) ~[?smilie]
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:31smilie ~[?smilie]
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261) ~[?smilie]
at org.ops4j.pax.web.extender.war.internal.WebAppPublisher.publish(WebAppPublisher.java:9smilie ~[?smilie]
at org.ops4j.pax.web.extender.war.internal.WebObserver.deploy(WebObserver.java:217) ~[?smilie]
at org.ops4j.pax.web.extender.war.internal.WebObserver$1.doStart(WebObserver.java:172) ~[?smilie]
at org.ops4j.pax.web.extender.war.internal.extender.SimpleExtension.start(SimpleExtension.java:59) ~[?smilie]
at org.ops4j.pax.web.extender.war.internal.extender.AbstractExtender.lambda$createExtension$0(AbstractExtender.java:277) ~[?smilie]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514) [?smilie]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?smilie]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:299) [?smilie]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) [?smilie]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) [?smilie]
at java.lang.Thread.run(Thread.java:844) [?smilie]
Caused by: java.lang.ClassNotFoundException: javax.naming.NamingException not found by fancyfoods.web [212]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1639) ~[?smilie]
at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80) ~[?smilie]
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053) ~[?smilie]
at java.lang.ClassLoader.loadClass(ClassLoader.java:496) ~[?smilie]
... 41 more

What am I doing wrong here?