I am using gwt with jetty but want use jndi for datasource so followed the documentation for eclipse gwt jetty jndi and did below to run my gwt app
Run my gwt app with following options in eclipse
-noserver
-remoteUI "${gwt_remote_ui_server_port}:${unique_id}"
-startupUrl myapp.html
-logLevel INFO
-codeServerPort 9997
-war war\location
-server com.myproject.MyCustomJettyLauncher
com.my.apps.app
My jetty-env.xml under WEB-INF configuration
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "
http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<New id="MSSQLDS" class="org.mortbay.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/MSSQLDS</Arg>
<Arg>
<New class="net.sourceforge.jtds.jdbcx.JtdsDataSource">
<Set name="User">dbuser</Set>
<Set name="Password">pwd</Set>
<Set name="DatabaseName">mydatabase</Set>
<Set name="ServerName">localhost</Set>
<Set name="PortNumber">1433</Set>
</New>
</Arg>
</New>
</Configure>
When I run my app i get below error
Starting Jetty on port 8888
[WARN] Failed startup of context com.healthfortis.MyCustomJettyLauncher$WebAppContextWithReload@2ed7c530{/,C:\workspace\hf-src\src\main\webapp}
javax.naming.NameNotFoundException;
remaining name 'java:comp'
at org.mortbay.naming.NamingContext.lookup(NamingContext.java:578)
at org.mortbay.naming.NamingContext.lookup(NamingContext.java:680)
at org.mortbay.naming.local.localContextRoot.lookup(localContextRoot.java:164)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at org.mortbay.jetty.plus.webapp.EnvConfiguration.createEnvContext(EnvConfiguration.java:51)
at org.mortbay.jetty.plus.webapp.EnvConfiguration.configureWebApp(EnvConfiguration.java:103)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1217)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
at com.healthfortis.MyCustomJettyLauncher$WebAppContextWithReload.doStart(MyCustomJettyLauncher.java:459)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:222)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at com.healthfortis.MyCustomJettyLauncher.start(MyCustomJettyLauncher.java:660)
at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:494)
at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1058)
at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:800)
at com.google.gwt.dev.DevMode.main(DevMode.java:304)
looks like eclipsse/jetty is not able to find jndi datasource..any suggestions??
There are two issues in the above configuration
Steps to set up a JNDI datasource to run on embedded Jetty server in GWT Development mode is as follows. (I have used mysql datasource as example but steps are same for other datasources)
Add jetty-web.xml with following content to WEB-INF directory
Run the GWT project as Web Application. You will get javax.naming.NoInitialContextException
To rectify this go to Run Configurations and open the application's run configuration. Select Arguments tab and add following line to VM Arguments
-Djava.naming.factory.initial=org.mortbay.naming.InitialContextFactory
Screen shot of Run Configuration
Save the settings and launch the webapp in development mode.