Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Add JNDI DataSource to WebAppContext

I'm getting following error on using 

H2 DataSource:
<New id="myds" class="org.mortbay.jetty.webapp.WebAppContext">
<Arg>jdbc/MyH2DS</Arg>
<Arg>
<New class="org.h2.jdbcx.JdbcConnectionPool">
<Set name="Url">jdbc:h2:/data/test</Set>
<Set name="User">sa</Set>
<Set name="Password"></Set>
</New>
</Arg>
</New>
Can some one help me with writing a H2 datasource for Jetty?
Error : 

java.lang.IllegalStateException: No suitable constructor: <New id="myds" class="org.eclipse.jetty.webapp.WebAppContext"><Arg>java:comp/env/jdbc/MyH2DS</Arg><Arg>|???<New class="org.h2.jdbcx.JdbcDataSource"><Set name="URL">jdbc:h2:/test</Set><Set name="user">sa</Set><Set name="password"/></New>|??</Arg></New> on o.e.j.w.WebAppContext@28c5d6{/,[file:/C:/Users/XCB638.DS/workspace/MyJSFProject/WebContent/, file:/C:/Users/XCB638.DS/workspace/MyJSFProject/build/classes/, jar:file:/C:/Users/XCB638.DS/workspace/MyJSFProject/WebContent/WEB-INF/lib/jsf-impl-2.1.2.jar!/META-INF/resources/, jar:file:/C:/Users/XCB638.DS/workspace/MyJSFProject/WebContent/WEB-INF/lib/primefaces-3.5.jar!/META-INF/resources/],STARTING}{C:\Users\XCB638.DS\workspace\MyJSFProject\WebContent\WEB-INF}
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.newObj(XmlConfiguration.java:799)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:413)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:289)
at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:248)
at org.eclipse.jetty.webapp.JettyWebXmlConfiguration.configure(JettyWebXmlConfiguration.java:102)
at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:464)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1316)
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.tutorial.WebServer.main(WebServer.java:22)







On Wed, Jun 5, 2013 at 11:13 AM, Ranjith Koduri <nanikpranjith9@xxxxxxxxx> wrote:
This is the code that I'm using to run the jetty server and how do I add a JNDI Data source MyH2DS to WebAppContext wac.

JNDI DataSource:
<New id="myds" class="org.mortbay.jetty.webapp.WebAppContext">
<Arg>jdbc/MyH2DS</Arg>
<Arg>
<New class="org.h2.jdbcx.JdbcConnectionPool">
<Set name="Url">jdbc:h2:/data/test</Set>
<Set name="User">sa</Set>
<Set name="Password"></Set>
</New>
</Arg>
</New>

Jetty Server (Embedded) Code:

Server server = new Server(8080);
WebAppContext wac = new WebAppContext();
File warPath = new File("C:/Users/XCB638.DS/workspace/MyJSFProject/WebContent/WEB-INF");
wac.setWar(warPath.getAbsolutePath());
wac.setContextPath("/");
wac.setBaseResource(new ResourceCollection(new String[] { "./WebContent", "build/classes" }));
server.setHandler(wac);
try
{
server.start();
server.join();
}
catch (Exception e)
{
e.printStackTrace();
}


Thanks & Regards,
Ranjith
MS-MIS, Univ Of Illinois at Chicago.





On Wed, Jun 5, 2013 at 10:48 AM, Ranjith Koduri <nanikpranjith9@xxxxxxxxx> wrote:
Hello,
Is there a way to add JNDI DataSource to WebAppContext using Jetty API; without needing to create any context XML file?


Thanks & Regards,
Ranjith
MS-MIS, Univ Of Illinois at Chicago.






Back to the top