2017-06-13 22 views
0

我我的web應用程序中使用Wildfly 9.0.2的Eclipse下[CourseWebApplication.war]部署。拋出java.lang.ClassNotFoundException:org.hibernate.criterion.Criterion

在該文件夾中:...\wildfly-9.0.2.Final\standalone\deployments\CourseWebProject.war\WEB-INF\lib有一個jar [CourseProject.jar],其中包括映射到db中的各種表的Dao和幾個servlet(映射到CourseWebProject的web.xml中)。 jar和war都是用Maven構建的,並且在它們的pom.xml中有hibernate依賴關係:hibernate-core,hibernate-commons-annotations和hibernate-jpa-2.0-api。

Exception handling request to /CourseWebProject/home: java.lang.NoClassDefFoundError: org/hibernate/criterion/Criterion每次運行我的HomeServlet servlet時都會拋出。我檢查(在調試),當它試圖istance新DaoImpl對象上面拋出異常,但我不明白爲什麼:

CourseProject/HomeServlet.java

public class HomeServlet extends HttpServlet 
{ 
    private static final long serialVersionUID = 1L; 

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
    { 
     doPost(request,response); 
    } 

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
    { 
     String username = request.getParameter("userName"); 
     String password = request.getParameter("password"); 
     if(username!=null && !username.isEmpty() && password!=null && !password.isEmpty()) 
     { 
      Users user = new Users(); 
      user.setUsername(username); 
      user.setPassword(password); 
      **DaoInterface dao = new DaoImpl();** 

登錄服務器

2017-06-12 10:45:15,358 INFO [org.jboss.modules] (main) JBoss Modules version 1.4.3.Final 
2017-06-12 10:45:15,629 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final 
2017-06-12 10:45:15,705 INFO [org.jboss.as] (MSC service thread 1-6) WFLYSRV0049: WildFly Full 9.0.2.Final (WildFly Core 1.0.2.Final) starting 
2017-06-12 10:45:15,707 DEBUG [org.jboss.as.config] (MSC service thread 1-6) Configured system properties: 
    awt.toolkit = sun.awt.windows.WToolkit 
    file.encoding = Cp1252 
    file.encoding.pkg = sun.io 
    file.separator = \ 
    java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment 
    java.awt.headless = true 
    java.awt.printerjob = sun.awt.windows.WPrinterJob 
    java.class.path = C:\Users\Riccardo\Downloads\wildfly-9.0.2.Final\jboss-modules.jar 
    java.class.version = 52.0 
    java.endorsed.dirs = C:\Program Files\Java\jdk1.8.0_131\jre\lib\endorsed 
    java.ext.dirs = C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext;C:\windows\Sun\Java\lib\ext 
    java.home = C:\Program Files\Java\jdk1.8.0_131\jre 
    java.io.tmpdir = C:\Users\Riccardo\AppData\Local\Temp\ 
    java.library.path = C:\Program Files\Java\jdk1.8.0_131\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;native;C:/Program Files/Java/jdk1.8.0_131/bin/../jre/bin/server;C:/Program Files/Java/jdk1.8.0_131/bin/../jre/bin;C:/Program Files/Java/jdk1.8.0_131/bin/../jre/lib/amd64;C:\Program Files\PostgreSQL\9.4\bin;C:\Program Files\Java\jdk1.8.0_131\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Lenovo\FusionEngine;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Lenovo\Bluetooth Software\;C:\Program Files\Lenovo\Bluetooth Software\syswow64;C:\Program Files (x86)\Common Files\lenovo\easyplussdk\bin;C:\Program Files\PuTTY\;C:\Program Files (x86)\Skype\Phone\;C:\Users\Riccardo\Downloads\eclipse;;. 
    java.net.preferIPv4Stack = true 
    java.runtime.name = Java(TM) SE Runtime Environment 
    java.runtime.version = 1.8.0_131-b11 
    java.specification.name = Java Platform API Specification 
    java.specification.vendor = Oracle Corporation 
    java.specification.version = 1.8 
    java.util.logging.manager = org.jboss.logmanager.LogManager 
    java.vendor = Oracle Corporation 
    java.vendor.url = http://java.oracle.com/ 
    java.vendor.url.bug = http://bugreport.sun.com/bugreport/ 
    java.version = 1.8.0_131 
    java.vm.info = mixed mode 
    java.vm.name = Java HotSpot(TM) 64-Bit Server VM 
    java.vm.specification.name = Java Virtual Machine Specification 
    java.vm.specification.vendor = Oracle Corporation 
    java.vm.specification.version = 1.8 
    java.vm.vendor = Oracle Corporation 
    java.vm.version = 25.131-b11 
    javax.management.builder.initial = org.jboss.as.jmx.PluggableMBeanServerBuilder 
    javax.xml.datatype.DatatypeFactory = __redirected.__DatatypeFactory 
    javax.xml.parsers.DocumentBuilderFactory = __redirected.__DocumentBuilderFactory 
    javax.xml.parsers.SAXParserFactory = __redirected.__SAXParserFactory 
    javax.xml.stream.XMLEventFactory = __redirected.__XMLEventFactory 
    javax.xml.stream.XMLInputFactory = __redirected.__XMLInputFactory 
    javax.xml.stream.XMLOutputFactory = __redirected.__XMLOutputFactory 
    javax.xml.transform.TransformerFactory = __redirected.__TransformerFactory 
    javax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema = __redirected.__SchemaFactory 
    javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom = __redirected.__XPathFactory 
    jboss.bind.address = localhost 
    jboss.bind.address.management = localhost 
    jboss.home.dir = C:\Users\Riccardo\Downloads\wildfly-9.0.2.Final 
    jboss.host.name = arm-pc 
    jboss.modules.dir = C:\Users\Riccardo\Downloads\wildfly-9.0.2.Final\modules 
    jboss.modules.system.pkgs = org.jboss.byteman 
    jboss.node.name = arm-pc 
    jboss.qualified.host.name = arm-pc 
    jboss.server.base.dir = C:\Users\Riccardo\Downloads\wildfly-9.0.2.Final\standalone 
    jboss.server.config.dir = C:\Users\Riccardo\Downloads\wildfly-9.0.2.Final\standalone\configuration 
    jboss.server.data.dir = C:\Users\Riccardo\Downloads\wildfly-9.0.2.Final\standalone\data 
    jboss.server.deploy.dir = C:\Users\Riccardo\Downloads\wildfly-9.0.2.Final\standalone\data\content 
    jboss.server.log.dir = C:\Users\Riccardo\Downloads\wildfly-9.0.2.Final\standalone\log 
    jboss.server.name = arm-pc 
    jboss.server.persist.config = true 
    jboss.server.temp.dir = C:\Users\Riccardo\Downloads\wildfly-9.0.2.Final\standalone\tmp 
    line.separator = 

    logging.configuration = file:/C:/Users/Riccardo/Downloads/wildfly-9.0.2.Final/standalone/configuration/logging.properties 
    module.path = C:/Users/Riccardo/Downloads/wildfly-9.0.2.Final/modules 
    org.jboss.boot.log.file = C:/Users/Riccardo/Downloads/wildfly-9.0.2.Final/standalone/log/boot.log 
    org.jboss.logmanager.nocolor = true 
    org.jboss.resolver.warning = true 
    org.xml.sax.driver = __redirected.__XMLReaderFactory 
    os.arch = amd64 
    os.name = Windows 8.1 
    os.version = 6.3 
    path.separator = ; 
    program.name = JBossTools: WildFly 9.x 
    sun.arch.data.model = 64 
    sun.boot.class.path = C:\Program Files\Java\jdk1.8.0_131\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\rt.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_131\jre\classes 
    sun.boot.library.path = C:\Program Files\Java\jdk1.8.0_131\jre\bin 
    sun.cpu.endian = little 
    sun.cpu.isalist = amd64 
    sun.desktop = windows 
    sun.io.unicode.encoding = UnicodeLittle 
    sun.java.command = org.jboss.modules.Main -mp C:/Users/Riccardo/Downloads/wildfly-9.0.2.Final/modules -jaxpmodule javax.xml.jaxp-provider -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -b localhost --server-config=standalone.xml -Djboss.server.base.dir=C:\Users\Riccardo\Downloads\wildfly-9.0.2.Final\standalone 
    sun.java.launcher = SUN_STANDARD 
    sun.jnu.encoding = Cp1252 
    sun.management.compiler = HotSpot 64-Bit Tiered Compilers 
    sun.os.patch.level = 
    sun.rmi.dgc.client.gcInterval = 3600000 
    sun.rmi.dgc.server.gcInterval = 3600000 
    user.country = US 
    user.country.format = IT 
    user.dir = C:\Users\Riccardo\Downloads\wildfly-9.0.2.Final\bin 
    user.home = C:\Users\Riccardo 
    user.language = en 
    user.language.format = it 
    user.name = Riccardo 
    user.script = 
    user.timezone = Europe/Berlin 
    user.variant = 
2017-06-12 10:45:15,710 DEBUG [org.jboss.as.config] (MSC service thread 1-6) VM Arguments: -Dprogram.name=JBossTools: WildFly 9.x -Xms64m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Djava.net.preferIPv4Stack=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Dorg.jboss.boot.log.file=C:/Users/Riccardo/Downloads/wildfly-9.0.2.Final/standalone/log/boot.log -Dlogging.configuration=file:/C:/Users/Riccardo/Downloads/wildfly-9.0.2.Final/standalone/configuration/logging.properties -Djboss.home.dir=C:/Users/Riccardo/Downloads/wildfly-9.0.2.Final -Dorg.jboss.logmanager.nocolor=true -Djboss.bind.address.management=localhost -Dfile.encoding=Cp1252 
2017-06-12 10:45:17,535 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 21) WFLYCTL0028: Attribute 'job-repository-type' in the resource at address '/subsystem=batch' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation. 
2017-06-12 10:45:17,540 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 10) WFLYCTL0028: Attribute 'enabled' in the resource at address '/subsystem=datasources/data-source=ExampleDS' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation. 
2017-06-12 10:45:17,634 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Found CourseWebProject.war in deployment directory. To trigger deployment create a file called CourseWebProject.war.dodeploy 
2017-06-12 10:45:17,635 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Found HelloWeb.war in deployment directory. To trigger deployment create a file called HelloWeb.war.dodeploy 
2017-06-12 10:45:17,677 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http) 
2017-06-12 10:45:17,706 INFO [org.xnio] (MSC service thread 1-6) XNIO version 3.3.1.Final 
2017-06-12 10:45:17,720 INFO [org.xnio.nio] (MSC service thread 1-6) XNIO NIO Implementation Version 3.3.1.Final 
2017-06-12 10:45:17,796 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 37) WFLYIO001: Worker 'default' has auto-configured to 8 core threads with 64 task threads based on your 4 available processors 
2017-06-12 10:45:17,850 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 44) WFLYJSF0007: Activated the following JSF Implementations: [main] 
2017-06-12 10:45:17,891 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 46) WFLYNAM0001: Activating Naming Subsystem 
2017-06-12 10:45:17,914 INFO [org.jboss.as.naming] (MSC service thread 1-3) WFLYNAM0003: Starting Naming Service 
2017-06-12 10:45:17,923 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3) 
2017-06-12 10:45:17,936 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 38) WFLYCLINF0001: Activating Infinispan subsystem. 
2017-06-12 10:45:17,949 INFO [org.jboss.as.security] (ServerService Thread Pool -- 53) WFLYSEC0002: Activating Security Subsystem 
2017-06-12 10:45:17,954 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 56) WFLYWS0002: Activating WebServices Extension 
2017-06-12 10:45:17,962 INFO [org.jboss.as.security] (MSC service thread 1-1) WFLYSEC0001: Current PicketBox version=4.9.2.Final 
2017-06-12 10:45:17,963 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 54) WFLYTX0013: Node identifier property is set to the default value. Please make sure it is unique. 
2017-06-12 10:45:17,975 INFO [org.jboss.as.connector] (MSC service thread 1-7) WFLYJCA0009: Starting JCA Subsystem (IronJacamar 1.2.5.Final) 
2017-06-12 10:45:17,993 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) WFLYJCA0018: Started Driver service with driver-name = h2 
2017-06-12 10:45:18,188 INFO [org.jboss.as.mail.extension] (MSC service thread 1-1) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default] 
2017-06-12 10:45:18,278 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0003: Undertow 1.2.9.Final starting 
2017-06-12 10:45:18,289 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0003: Undertow 1.2.9.Final starting 
2017-06-12 10:45:18,573 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0014: Creating file handler for path C:\Users\Riccardo\Downloads\wildfly-9.0.2.Final/welcome-content 
2017-06-12 10:45:19,589 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "CourseWebProject.war" (runtime-name: "CourseWebProject.war") 
2017-06-12 10:45:19,594 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-4) WFLYDS0013: Started FileSystemDeploymentService for directory C:\Users\Riccardo\Downloads\wildfly-9.0.2.Final\standalone\deployments 
2017-06-12 10:45:19,595 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) WFLYSRV0027: Starting deployment of "HelloWeb.war" (runtime-name: "HelloWeb.war") 
2017-06-12 10:45:19,618 INFO [org.jboss.remoting] (MSC service thread 1-6) JBoss Remoting version 4.0.9.Final 
2017-06-12 10:45:19,658 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0012: Started server default-server. 
2017-06-12 10:45:19,678 INFO [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0018: Host default-host starting 
2017-06-12 10:45:19,949 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTP listener default listening on localhost/127.0.0.1:8080 
2017-06-12 10:45:20,139 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS] 
2017-06-12 10:45:20,482 INFO [org.jboss.ws.common.management] (MSC service thread 1-1) JBWS022052: Starting JBoss Web Services - Stack CXF Server 5.0.0.Final 
2017-06-12 10:45:24,837 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 59) WFLYUT0021: Registered web context: /CourseWebProject 
2017-06-12 10:45:24,837 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 68) WFLYUT0021: Registered web context: /HelloWeb 
2017-06-12 10:45:24,883 INFO [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "HelloWeb.war" (runtime-name : "HelloWeb.war") 
2017-06-12 10:45:24,884 INFO [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "CourseWebProject.war" (runtime-name : "CourseWebProject.war") 
2017-06-12 10:45:25,257 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management 
2017-06-12 10:45:25,258 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990 
2017-06-12 10:45:25,259 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 9.0.2.Final (WildFly Core 1.0.2.Final) started in 10260ms - Started 352 of 539 services (232 services are lazy, passive or on-demand) 
2017-06-12 10:48:05,056 ERROR [io.undertow.request] (default task-3) UT005023: Exception handling request to /CourseWebProject/home: java.lang.NoClassDefFoundError: org/hibernate/criterion/Criterion 
    at com.arm.course.ui.HomeServlet.doPost(HomeServlet.java:32) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) 
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:86) 
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) 
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) 
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) 
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) 
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) 
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) 
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:72) 
    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50) 
    at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:282) 
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:261) 
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:80) 
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:172) 
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199) 
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:774) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:748) 
Caused by: java.lang.ClassNotFoundException: org.hibernate.criterion.Criterion from [Module "deployment.CourseWebProject.war:main" from Service Module Loader] 
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205) 
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455) 
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404) 
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385) 
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:130) 
    ... 30 more 

CourseWebProject/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>org.arm.coursewebapp</groupId> 
    <artifactId>CourseWebProject</artifactId> 
    <packaging>war</packaging> 
    <version>0.0.1-SNAPSHOT</version> 
    <name>CourseWebProject Maven Webapp</name> 
    <url>http://maven.apache.org</url> 

    <repositories> 
    <repository> 
    <id>java.net2</id> 
    <name>Repository hosting the jee6 artifacts</name> 
    <url>http://download.java.net/maven/2</url> 
    </repository> 
</repositories> 

    <dependencies> 

    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 

    <dependency> 
    <groupId>javax</groupId> 
    <artifactId>javaee-web-api</artifactId> 
    <version>6.0</version> 
    <scope>provided</scope> 
    </dependency> 

    <!-- HIBERNATE FRAMEWORK AND DEPENDENCY --> 
    <dependency> 
    <groupId>org.hibernate</groupId> 
    <artifactId>hibernate-core</artifactId> 
    <version>5.2.10.Final</version> 
    </dependency> 

    <dependency> 
    <groupId>org.antlr</groupId> 
    <artifactId>antlr-runtime</artifactId> 
    <version>3.5.2</version> 
    </dependency> 

    <dependency> 
    <groupId>dom4j</groupId> 
    <artifactId>dom4j</artifactId> 
    <version>1.6.1</version> 
    </dependency> 

    <dependency> 
    <groupId>org.apache.geronimo.specs</groupId> 
    <artifactId>geronimo-jta_1.1_spec</artifactId> 
    <version>1.1.1</version> 
    </dependency> 

    <dependency> 
    <groupId>org.hibernate.common</groupId> 
    <artifactId>hibernate-commons-annotations</artifactId> 
    <version>5.0.0.Final</version> 
    </dependency> 

    <dependency> 
    <groupId>org.hibernate.javax.persistence</groupId> 
    <artifactId>hibernate-jpa-2.0-api</artifactId> 
    <version>1.0.1.Final</version> 
    </dependency> 

    <dependency> 
    <groupId>org.jboss</groupId> 
    <artifactId>jandex</artifactId> 
    <version>2.0.3.Final</version> 
    </dependency> 

    <dependency> 
    <groupId>javassist</groupId> 
    <artifactId>javassist</artifactId> 
    <version>3.12.1.GA</version> 
    </dependency> 

    <dependency> 
    <groupId>org.jboss.logging</groupId> 
    <artifactId>jboss-logging</artifactId> 
    <version>3.3.1.Final</version> 
    </dependency> 

    <dependency> 
    <groupId>xml-apis</groupId> 
    <artifactId>xml-apis</artifactId> 
    <version>2.0.2</version> 
    </dependency> 


    </dependencies> 
    <build> 
    <finalName>CourseWebProject</finalName> 
    </build> 
</project> 

CourseProject/DaoImp.java

[public class DaoImpl implements DaoInterface 
{ 
    private Session session = null; 

    private void buildSessionFactory() 
    { 
     Configuration configuration = new Configuration(); 
     configuration.configure("/com/arm/course/model/hbm/hibernate.cfg.xml"); 
     SessionFactory sessionFactory = configuration.buildSessionFactory();  
     session = sessionFactory.openSession(); 
    } 

    public DaoImpl() 
    { 
     buildSessionFactory(); 
    } 
我的CourseWebProject.war

Tree文件夾部署

wildfly-9.0.2.Final\standalone\deployments\CourseWebProject.war 
Folder PATH listing for volume Windows8_OS 
Volume serial number is BAAC-FBDE 
C:. 
³ Homepage.html 
³ tree.txt 
³ 
ÃÄÄÄcss 
ÃÄÄÄhtml 
³  Login.html 
³  loginError.html 
³  loginOk.html 
³  
ÃÄÄÄjs 
ÃÄÄÄMETA-INF 
³ ³ MANIFEST.MF 
³ ³ 
³ ÀÄÄÄmaven 
³  ÀÄÄÄorg.arm.coursewebapp 
³   ÀÄÄÄCourseWebProject 
³     pom.properties 
³     pom.xml 
³     
ÀÄÄÄWEB-INF 
    ³ web.xml 
    ³ 
    ÀÄÄÄlib 
     ÀÄÄÄCourseProject.jar 
      ÃÄÄÄcom 
      ³ ÀÄÄÄarm 
      ³  ÀÄÄÄcourse 
      ³   ÃÄÄÄdao 
      ³   ³  DaoImpl.class 
      ³   ³  DaoInterface.class 
      ³   ³  TestDao.class 
      ³   ³  
      ³   ÃÄÄÄmodel 
      ³   ³ ³ Classroom.class 
      ³   ³ ³ ClassroomId.class 
      ³   ³ ³ Course.class 
      ³   ³ ³ Location.class 
      ³   ³ ³ Person.class 
      ³   ³ ³ Subject.class 
      ³   ³ ³ SubjectId.class 
      ³   ³ ³ Users.class 
      ³   ³ ³ UsersId.class 
      ³   ³ ³ 
      ³   ³ ÀÄÄÄhbm 
      ³   ³   Classroom.hbm.xml 
      ³   ³   Course.hbm.xml 
      ³   ³   hibernate.cfg.xml 
      ³   ³   Location.hbm.xml 
      ³   ³   Person.hbm.xml 
      ³   ³   Subject.hbm.xml 
      ³   ³   Users.hbm.xml 
      ³   ³   
      ³   ÀÄÄÄui 
      ³     HomeServlet.class 
      ³     LoginFilter.class 
      ³     LoginHomepageServlet.class 
      ³     
      ÀÄÄÄMETA-INF 
       ³ MANIFEST.MF 
       ³ 
       ÀÄÄÄmaven 
        ÀÄÄÄcom.arm.course 
         ÀÄÄÄCourseProject 
           pom.properties 
           pom.xml 

回答

0

我不是很成Wildfly/JBoss的(我更到Tomcat /春季啓動),所以我不是很確定有關此JEE應用程序服務器的WAR的預期形狀。

看來,JBoss的類加載器嘗試加載Criterion類,但在classpath中沒有找到它。對於一個'經典'WAR,外部庫應該在WEB-INF/lib,除了你的CourseProject.jar之外,還有其他的Hibernate JAR嗎? 它也可能在服務器的lib目錄下,但我不確定這是一個很好的做法。

如果這樣做能在你的IDE,檢查該JAR的Criterion類的位置,並檢查該JAR是在你部署軟件包。如果你從Eclipse進行部署,請檢查綁定是否正確完成,或者不要這樣做,因爲你使用了不同的東西,最終會使用:使用Maven構建WAR,以確保最終結果正確構建,然後部署它。

希望這會有所幫助!

+0

嗨sjahan! 沒有進入'WEB-INF/lib'我只找到了我的'CourseProject.jar'。 外部休眠的JAR我想由Maven的加載到儘快我檢查其中JAR判據類被定位和檢查該JAR是在包運行時(我錯???) 我部署.. 真的謝謝你的時刻 –

+0

Maven執行編譯,測試和打包,但它不應該在運行時做任何事情。 'Criterion'類應該是在一個hibernate JAR中。如果你的類路徑中沒有Hibernate JAR,那麼這是絕對正常的。無論如何,JVM很少存在:最後,你錯過了Hibernate JAR。 – sjahan

+0

對於CourseWebProject,我在'eclipse_workspace \ CourseWebProject \ target \ CourseWebProject \ WEB-INF \ lib'下看到了JAR(包括那些關於Hibernate的)JAR文件, 但我在CourseProject 下看不到(項目的類路徑中的JAR) 'eclipse_workspace \ CourseProject \ target' .. 這是一個問題嗎? –

相關問題