我已经运行了基本的演示应用程序,它显示以下错误:
嵌套异常是 javax.naming.NameNotFoundException:名称[jdbc / web]未绑定在此Context中。无法找到[jdbc]。
我的context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context sessionCookieName="JSESSIONIDADMIN">
<!-- disable session persistence -->
<Manager pathname="" />
<ResourceLink name="jdbc/web"
global="jdbc/web"
type="javax.sql.DataSource" />
</Context>
我的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mycompany-community</groupId>
<artifactId>ecommerce-website</artifactId>
<version>5.0</version>
</parent>
<artifactId>core</artifactId>
<name>core</name>
<description>Customizations And Extensions For Broadleaf Commerce Services And Entities</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.zeroturnaround</groupId>
<artifactId>jrebel-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-rebel-xml</id>
<phase>process-resources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<rootPath>${basedir}</rootPath>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.broadleafcommerce</groupId>
<artifactId>broadleaf-framework</artifactId>
</dependency>
<dependency>
<groupId>org.broadleafcommerce</groupId>
<artifactId>broadleaf-profile</artifactId>
</dependency>
<dependency>
<groupId>org.broadleafcommerce</groupId>
<artifactId>broadleaf-menu</artifactId>
</dependency>
<dependency>
<groupId>org.broadleafcommerce</groupId>
<artifactId>broadleaf-sample-payment-gateway</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
</dependencies>
</project>
答案 0 :(得分:0)
您是否在server.xml中添加了GlobalNamingResources的资源设置?如果没有,您应该添加设置。
例如:
<GlobalNamingResources>
...
<Resource name="jdbc/web"
auth="Container"
type="javax.sql.DataSource"
username="test"
password="test"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@***.***.***.***:1521:orcl" />
</GlobalNamingResources>
或者更改context.xml的内容,例如:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="jdbc/web"
auth="Container"
type="javax.sql.DataSource"
username="test"
password="test"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@***.***.***.***:1521:orcl" />
</Context>
如果应用程序不需要访问数据库,则从context.xml中删除Resource标记。