I am new to GWT (1.7) and tried to establish a connection to my MySQL database from a servlet. Since I got some errors, I parsed them and found out that I needed to configure the DataSource in Jetty so that it would work in Hosted mode. I followed this guide:
Tutorial
I created my own JettyLauncher class as described, and added the appropriate parameter to the Run configuration. After that, I added this entry to my WEB-INF / web.xml:
<resource-ref>
<description>MySQl Connection</description>
<res-ref-name>jdbc/skyline</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
After that, I created a jetty-env.xml file with the following contents:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<New id="skyline" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/skyline</Arg>
<Arg>
<New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
<Set name="Url">jdbc:mysql://localhost:3306/skyline</Set>
<Set name="User">root</Set>
<Set name="Password">admin</Set>
</New>
</Arg>
</New>
</Configure>
And when I now try to run the application in eclipse (Galileo, with the GWT plugin), I get the following error:
[WARN] Configuration problem at <resource-ref><description>MySQl Connection</description><res-ref-name>jdbc/skyline</res-ref-name><res-type>javax.sql.DataSource</res-type><res-auth>Container</res-auth></resource-ref>
java.lang.ClassCastException: org.mortbay.jetty.plus.naming.Resource cannot be cast to org.mortbay.jetty.plus.naming.NamingEntry
at org.mortbay.jetty.plus.naming.NamingEntry.lookupNamingEntry(NamingEntry.java:211)
at org.mortbay.jetty.plus.naming.NamingEntry.bindToENC(NamingEntry.java:104)
at org.mortbay.jetty.plus.webapp.Configuration.bindResourceRef(Configuration.java:73)
at org.mortbay.jetty.plus.webapp.AbstractConfiguration.initResourceRef(AbstractConfiguration.java:262)
at org.mortbay.jetty.plus.webapp.AbstractConfiguration.initWebXmlElement(AbstractConfiguration.java:161)
at org.mortbay.jetty.webapp.WebXmlConfiguration.initialize(WebXmlConfiguration.java:289)
at org.mortbay.jetty.plus.webapp.AbstractConfiguration.initialize(AbstractConfiguration.java:133)
at org.mortbay.jetty.webapp.WebXmlConfiguration.configure(WebXmlConfiguration.java:222)
at org.mortbay.jetty.plus.webapp.AbstractConfiguration.configure(AbstractConfiguration.java:113)
at org.mortbay.jetty.webapp.WebXmlConfiguration.configureWebApp(WebXmlConfiguration.java:180)
at org.mortbay.jetty.plus.webapp.AbstractConfiguration.configureWebApp(AbstractConfiguration.java:96)
at org.mortbay.jetty.plus.webapp.Configuration.configureWebApp(Configuration.java:124)
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 skyline.frontend.server.helper.CustomJettyLauncher$WebAppContextWithReload.doStart(CustomJettyLauncher.java:412)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115)
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 skyline.frontend.server.helper.CustomJettyLauncher.start(CustomJettyLauncher.java:464)
at com.google.gwt.dev.HostedMode.doStartUpServer(HostedMode.java:365)
at com.google.gwt.dev.HostedModeBase.startUp(HostedModeBase.java:590)
at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:397)
at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)
jetty-naming-6.1.11.jar jetty-plus-6.1.11.jar. WEB-INF/lib. .
anybode , ?