标题中有错误。这很奇怪,因为我在对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>
如果还有其他要添加的内容,请说出来,我会添加它。
答案 0 :(得分:0)
就我而言,我删除了netbeans中的Eclipse jar文件。单击库下的Eclipse jar文件,然后单击删除。 然后右键单击“库”,选择“添加Jar”并提供Eclipse jar文件的位置。
在尝试部署您的项目后,它将正常工作