gpt4 book ai didi

java - 将 Web 项目部署到 Glassfish 3.1 时出现错误

转载 作者:行者123 更新时间:2023-12-01 15:00:14 25 4
gpt4 key购买 nike

我在将 Web 项目 war 文件部署到 Glassfish 3.1 时遇到以下错误

[#|2012-12-07T11:38:25.695+0200|SEVERE|glassfish3.1.1|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=26;_ThreadName=Thread-2;|Exception while preparing the app : org/slf4j/impl/StaticLoggerBinder
java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1519)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1369)
at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:223)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:120)

这是war文件结构:

WEB-INF
lib
classes
META-INF
persistance.xml
com (compiled class files)
web.xml
META-INF
MANIFEST.MF
index.xhtml
login.xhtml

这是persistence.xml文件

<persistence 
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">

<persistence-unit name="firsthibernate" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/firsthibernate</jta-data-source>

<class>com.mkyong.dataaccess.entity.User</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.current_session_context_class" value="jta" />
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.SunONETransactionManagerLookup" />
</properties>
</persistence-unit>

这里是pom.xml

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mkyong.common</groupId>
<artifactId>JavaServerFaces</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>JavaServerFaces Maven Webapp</name>
<url>http://maven.apache.org</url>


<repositories>

<!-- Primefaces Repository -->
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>

<repository>
<id>repository.jboss.org-public</id>
<name>JBoss repository</name>
<url>https://repository.jboss.org/nexus/content/groups/public</url>
</repository>

</repositories>

<dependencies>

<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.4.2</version>
</dependency>


<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.7</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>

<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>

<dependency>
<groupId>com.sun.el</groupId>
<artifactId>el-ri</artifactId>
<version>1.0</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.5.6-Final</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.2</version>
</dependency>




</dependencies>

<build>
<finalName>JavaServerFaces</finalName>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

enter code here

最佳答案

确保您的类路径上有 jcl-over-slf4j-1.5.8.jar。

通过 Maven

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.2</version>
</dependency>

<强> Download

jcl-over-slf4j 依赖于 slf4j-ap.jar,可以下载 here 。这也应该包含在您的类路径中。

关于java - 将 Web 项目部署到 Glassfish 3.1 时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13762486/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com