为解决org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [com.microsoft.sqlserver.jdbc.SQLServerDriver]
错误,我将此依赖项添加到了pom:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre7</version>
</dependency>
这是SQLServer连接驱动程序的开放代码依赖性,但是当我放它时,出现错误我的pom.xml出现:
Missing artifact org.codehaus.jackson:jackson-mapper-asl:jar:2.8.1
已更新:
如果我仍然运行该应用程序,则日志控制台将显示以下跟踪信息:
15:42:28,432 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 50) MSC000001: Failed to start service jboss.persistenceunit."vp301b-ear.ear/vp301b.war#unidadPersistencia": org.jboss.msc.service.StartException in service jboss.persistenceunit."vp301b-ear.ear/vp301b.war#unidadPersistencia": java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ClassLoadingException
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_80]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_80]
at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.2.Final-redhat-1.jar:2.1.2.Final-redhat-1]
Caused by: java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ClassLoadingException
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1404)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:152)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99)
... 4 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.ClassLoadingException from [Module "deployment.vp301b-ear.ear.vp301b.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.6.Final-redhat-1]
... 14 more
当我尝试使用mvn comile
进行编译时,结果如下:
Failed to execute goal on project vp301b-war: Could not resolve dependencies for project es.xunta.amtega.vp301b:vp301b-war:war:1.0-SNAPSHOT: Failure to find org.codehaus.jackson:jackson-mapper-asl:jar:2.8.1 in http://nexus.xunta.local/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of amtega has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :vp301b-war
答案 0 :(得分:0)
正如khmarbaise所指出的那样,问题在于jackson-mapper-asl-2.8.1.jar
在您的存储库中不可用。但是我看到mssql-jdbc-6.1.0.jre7.jar
对jackson-mapper-asl的1.9.2版本(而不是2.8.1版本)具有传递性依赖,因此我想您所说的内容是错误的(也许您已经进行了很多尝试)。我建议尝试使用JDBC驱动程序的 6.4.0.jre7 版本,因为它完全不依赖于jackson-mapper-asl,并且是最新的基于jre7的版本。
还要注意,JDBC驱动程序不应包含在战争的类路径中,而应包含在应用程序服务器的类路径中(我假设您的Web应用程序以正确的方式(即通过服务器)访问数据库-提供的连接池,而不是通过DriverManager
);这意味着驱动程序不应在您的POM中成为编译范围的依赖。