[英]Object of type [class java.util.Properties] available at JNDI location [comp/env/test] is not assignable to [javax.sql.DataSource]
[英]JNDI lookup failed for the resource Type: javax.sql.DataSource
錯誤在標題中。 這很奇怪,因為我在對xhtml代碼及其bean進行了一些修改,多次打開和關閉glassfish服務器,然后突然出現此錯誤。 在工作時,我沒有觸摸過web.xml或任何類型的文件,只是xhtml及其bean。
錯誤信息:
Severe: JNDI lookup failed for the resource: Name: JPATestPU, Lookup: java:app/jpaDB, Type: javax.sql.DataSource.
Severe: Exception while deploying the app [JPAAdvanced]
Severe: Exception during lifecycle processing
org.glassfish.deployment.common.DeploymentException: JNDI lookup failed for the resource: Name: [JPATestPU], Lookup: [java:app/jpaDB], Type: [javax.sql.DataSource]
at[...]
Caused by: javax.naming.NamingException: Lookup failed for 'java:app/jpaDB' in SerialContext[myEnv={java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Invocation exception: Got null ComponentInvocation ]
at[...]
Caused by: javax.naming.NamingException: Invocation exception: Got null ComponentInvocation
at[...]
Severe: Exception while deploying the app [JPAAdvanced] : JNDI lookup failed for the resource: Name: [JPATestPU], Lookup: [java:app/jpaDB], Type: [javax.sql.DataSource]
javax.naming.NamingException: Lookup failed for 'java:app/jpaDB' in SerialContext[myEnv={java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Invocation exception: Got null ComponentInvocation ]
at[...]
Caused by: javax.naming.NamingException: Invocation exception: Got null ComponentInvocation
at[...]
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
glasfish-resources.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="org.postgresql.ds.PGSimpleDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="post-gre-sql_jpaDB_postgresPool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<property name="serverName" value="localhost"/>
<property name="portNumber" value="5432"/>
<property name="databaseName" value="jpaDB"/>
<property name="User" value="postgres"/>
<property name="Password" value="*****"/>
<property name="URL" value="jdbc:postgresql://localhost:5432/jpaDB"/>
<property name="driverClass" value="org.postgresql.Driver"/>
</jdbc-connection-pool>
<jdbc-resource enabled="true" jndi-name="java:app/jpaDB" object-type="user" pool-name="post-gre-sql_jpaDB_postgresPool"/>
</resources>
如果還有其他要添加的內容,請這樣說,我將添加它。
就我而言,我刪除了netbeans中的Eclipse jar文件。 單擊庫下的Eclipse jar文件,然后單擊刪除。 然后,右鍵單擊“庫”,選擇“添加Jar”並提供Eclipse jar文件的位置。
嘗試部署您的項目后,它將正常工作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.