从 java7 tomcat7 迁移到 java8 tomcat8 时启动 tomcat 时出错
Error launching tomcat while migrating from java7 tomcat7 to java8 tomcat8
我在一个使用 tomcat 7 java 7 的项目上切换到 Java 8 tomcat 8。
我重新编译了源代码,没有错误。
我的问题来了运行tomcat.
我无法使用此配置连接到资源:
<GlobalNamingResources>
<Resource
name="shared/jdbc/toto"
auth="Container"
type="javax.sql.DataSource"
username="toto"
password="toto"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://syt-db:5432/toto"
maxActive="4"
maxIdle="2"/>
</GlobalNamingResources>
我收到这个错误:
Cannot load JDBC driver class 'org.postgresql.Driver'
java.lang.ClassNotFoundException: org.postgresql.Driver
我添加了在 Internet 某处看到的工厂。
<GlobalNamingResources>
<Resource
name="shared/jdbc/toto"
auth="Container"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
type="javax.sql.DataSourceFactory"
username="toto"
password="toto"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://syt-db:5432/toto"
maxActive="4"
maxIdle="2"/>
</GlobalNamingResources>
并得到这样的错误:
AVERTISSEMENT [localhost-startStop-1] org.apache.naming.NamingContext.lookup Une erreur s est produite durant la résolution de la référence
java.lang.IllegalArgumentException: The local resource link [toto] that refers to global resource [shared/jdbc/toto] does not specify the required attribute type
感觉现在可以用驱动了,但是还是配置不对
我的问题真的来自资源配置还是我应该关注其他问题?
谢谢
我认为您需要将带有 postgres 驱动程序的 jar 文件从旧的 tomcat7 复制到新的 tomcat8。
在 TOMCAT_HOME/lib - 目录中查找文件。
我必须在我的应用程序上下文中添加 type="javax.sql.DataSource"
<ResourceLink
name="jdbc/toto"
global="shared/jdbc/toto"
type="javax.sql.DataSource"
/>
您需要在资源定义和 server.xml
的上下文中写入类型
我在一个使用 tomcat 7 java 7 的项目上切换到 Java 8 tomcat 8。
我重新编译了源代码,没有错误。
我的问题来了运行tomcat.
我无法使用此配置连接到资源:
<GlobalNamingResources>
<Resource
name="shared/jdbc/toto"
auth="Container"
type="javax.sql.DataSource"
username="toto"
password="toto"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://syt-db:5432/toto"
maxActive="4"
maxIdle="2"/>
</GlobalNamingResources>
我收到这个错误:
Cannot load JDBC driver class 'org.postgresql.Driver'
java.lang.ClassNotFoundException: org.postgresql.Driver
我添加了在 Internet 某处看到的工厂。
<GlobalNamingResources>
<Resource
name="shared/jdbc/toto"
auth="Container"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
type="javax.sql.DataSourceFactory"
username="toto"
password="toto"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://syt-db:5432/toto"
maxActive="4"
maxIdle="2"/>
</GlobalNamingResources>
并得到这样的错误:
AVERTISSEMENT [localhost-startStop-1] org.apache.naming.NamingContext.lookup Une erreur s est produite durant la résolution de la référence
java.lang.IllegalArgumentException: The local resource link [toto] that refers to global resource [shared/jdbc/toto] does not specify the required attribute type
感觉现在可以用驱动了,但是还是配置不对
我的问题真的来自资源配置还是我应该关注其他问题?
谢谢
我认为您需要将带有 postgres 驱动程序的 jar 文件从旧的 tomcat7 复制到新的 tomcat8。
在 TOMCAT_HOME/lib - 目录中查找文件。
我必须在我的应用程序上下文中添加 type="javax.sql.DataSource"
<ResourceLink
name="jdbc/toto"
global="shared/jdbc/toto"
type="javax.sql.DataSource"
/>
您需要在资源定义和 server.xml
的上下文中写入类型