Hey Jan,
I tried as per your suggestion, but I still
face java.lang.IllegalStateException: Nothing to bind for name
javax.sql.DataSource/default issue.
InitialContext ic = new InitialContext();
ic.lookup("jdbc/testDS");
On Mon, Jul 29, 2013 at 5:16 PM, Jan Bartel <[email protected]> wrote:
> The namespace java:comp/env is reserved to be local to a webapp. That
> is, it is designed to be called from code executing from the
> associated WebAppContext. You cannot reference it from outside of the
> webapp. The specification calls for names defined within the
> container's namespace (via Resource declarations in jetty-env.xml or
> jetty.xml) to be hooked up into webapps via <resource-ref> entries in
> web.xml - this populates the java:comp/env namespace for a webapp.
>
> Given the way you have defined your datasource Resource, if you want
> to access it outside a webapp, you need to access it within the global
> namespace as:
>
> InitialContext ic = new InitialContext();
> ic.lookup("jdbc/testDS");
>
> Jan
>
> On 30 July 2013 06:58, Ranjith Koduri <[email protected]> wrote:
> > This is the error I get :
> >
> > java.lang.reflect.InvocationTargetException
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> > at
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> > at java.lang.reflect.Method.invoke(Method.java:601)
> > at
> >
> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:85)
> > at
> >
> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:72)
> > at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:367)
> > at
> >
> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1319)
> > at
> >
> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:724)
> > at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:490)
> > at
> >
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
> > at
> >
> org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:108)
> > at org.eclipse.jetty.server.Server.start(Server.java:342)
> > at
> >
> org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:90)
> > at
> >
> org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58)
> > at org.eclipse.jetty.server.Server.doStart(Server.java:290)
> > at
> >
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
> > at com.WebServer.main(WebServer.java:37)
> >
> > Caused by:
> > java.lang.IllegalStateException: Nothing to bind for name
> > javax.sql.DataSource/default
> > at
> >
> org.eclipse.jetty.plus.webapp.PlusDescriptorProcessor.bindEntry(PlusDescriptorProcessor.java:895)
> > at
> >
> org.eclipse.jetty.plus.webapp.PlusDescriptorProcessor.bindResourceRef(PlusDescriptorProcessor.java:812)
> > at
> >
> org.eclipse.jetty.plus.webapp.PlusDescriptorProcessor.visitResourceRef(PlusDescriptorProcessor.java:252)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> > at
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> > at java.lang.reflect.Method.invoke(Method.java:601)
> > at
> >
> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:85)
> > at
> >
> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:72)
> > at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:367)
> > at
> >
> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1319)
> > at
> >
> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:724)
> > at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:490)
> > at
> >
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
> > at
> >
> org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:108)
> > at org.eclipse.jetty.server.Server.start(Server.java:342)
> > at
> >
> org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:90)
> > at
> >
> org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58)
> > at org.eclipse.jetty.server.Server.doStart(Server.java:290)
> > at
> >
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
> > at com.WebServer.main(WebServer.java:37)
> > 2013-07-29 15:55:56.359:INFO:oejs.ServerConnector:main: Started
> > ServerConnector@fe5577{HTTP/1.1}{0.0.0.0:8080}
> >
> > javax.naming.NameNotFoundException; remaining name 'env/jdbc/testDS'
> > at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:505)
> > at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:536)
> > at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:551)
> > at
> >
> org.eclipse.jetty.jndi.java.javaRootURLContext.lookup(javaRootURLContext.java:117)
> > at javax.naming.InitialContext.lookup(InitialContext.java:411)
> > at com.WebServer.main(WebServer.java:41)
> >
> >
> >
> > _______________________________________________
> > jetty-users mailing list
> > [email protected]
> > https://dev.eclipse.org/mailman/listinfo/jetty-users
> >
>
>
>
> --
> Jan Bartel <[email protected]>
> www.webtide.com – Developer advice, services and support
> from the Jetty & CometD experts.
> _______________________________________________
> jetty-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users