我用码头创建了 GWT 项目,并使用 JNDI 作为数据源。当我运行 GWT 应用程序时,一切正常,但是当我将 .war 文件复制到 JBoss 并运行它时,出现错误。JBoss 版本 - 4.2.3.GA
javax.naming.NamingException: Could not dereference object [Root exception is
javax.naming.NameNotFoundException: jdbc not bound] at
org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1215) at
org.jnp.interfaces.NamingContext.lookup(NamingContext.java:758) at
org.jnp.interfaces.NamingContext.lookup(NamingContext.java:774) at
org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627) at
javax.naming.InitialContext.lookup(InitialContext.java:392) at
jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<resource-ref>
<res-ref-name>jdbc/base</res-ref-name>
<jndi-name>jdbc/base</jndi-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</jboss-web>
码头-env.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<New id="base" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/base</Arg>
<Arg>
<New class="org.apache.tomcat.jdbc.pool.DataSource">
<Set name="driverClassName">org.postgresql.Driver</Set>
<Set name="url">jdbc:postgresql://database/test</Set>
<Set name="username">user</Set>
<Set name="password">password</Set>
<Set name="maxActive">10</Set>
<Set name="maxIdle">4</Set>
</New>
</Arg>
</New>
</Configure>
web.xml
<resource-ref>
<description>My DataSource Reference</description>
<res-ref-name>jdbc/base</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
GreetingServiceImpl.java
InitialContext ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup("java:comp/env/jdbc/base");
Connection con = ds.getConnection();
怎么了?感谢帮助