简体   繁体   English

NetBeans中调试期间的异常

[英]Exception during debug in NetBeans

I have a gradle project with following dependencies: 我有一个gradle项目,具有以下依赖项:

    compile "commons-codec:commons-codec:+"
    compile "commons-io:commons-io:+"
    compile "org.apache.poi:poi:+"
    compile "commons-logging:commons-logging:+"
    compile "net.sourceforge.cssparser:cssparser:+"
    compile "net.sourceforge.htmlunit:htmlunit:+"
    compile "net.sourceforge.htmlunit:htmlunit-core-js:+"
    compile "net.sourceforge.htmlunit:neko-htmlunit:+"
    compile "org.apache.commons:commons-lang3:+"
    compile "org.apache.httpcomponents:httpclient:+"
    compile "org.apache.httpcomponents:httpmime:+"
    compile "org.eclipse.jetty.websocket:websocket-client:+"
    compile "xalan:xalan:+"
    compile "org.apache.poi:poi:+"
    compile "org.apache.poi:poi-ooxml:+"
    compile "org.apache.cassandra:cassandra-all:+"
    compile "org.apache.cassandra:cassandra-thrift:+"
   compile "com.whalin:Memcached-Java-Client:+"
   compile "org.hibernate:hibernate-gradle-plugin:+"
   compile "org.hibernate:hibernate-core:+"
   compile "org.hibernate:hibernate-tools:+"
   compile "org.hibernate:hibernate-entitymanager:+"
   compile "org.hibernate:hibernate:+"
   compile "org.hibernate:hibernate-annotations:+"
   compile "mysql:mysql-connector-java:+"
   compile "org.hibernate:ejb3-persistence:+"
   compile "javax:javaee-api:+"
   compile "javax.persistence:persistence-api:+"
   compile "javassist:javassist:+"

I can't run it in debug mode using NetBeans IDE, when I try, I got following exception: 我无法使用NetBeans IDE在调试模式下运行它,当我尝试时,我遇到以下异常:

18:54:28.174 [main] DEBUG o.h.cfg.annotations.PropertyBinder - Building property year_end
Exception in thread "main" java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
    at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:1106)

Why? 为什么?

My question is unique because it is not about compilation. 我的问题很独特,因为它不是关于编译的。 My program compiles well with following (gradle) code : 我的程序编译好以下(gradle)代码:

task compileJar(type: Jar) {
    manifest {
        attributes 'Implementation-Title': 'Applic version 0.9',
            'Implementation-Version': version,
            'Main-Class': 'com.company.runfile'
    }
    baseName = project.name + '-all'
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
    exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA' 
}

This creates jar file which run properly, but I can not debug the same application in NetBeans (also in Intellij IDEA) . 这会创建正确运行的jar文件,但我无法在NetBeans中调试相同的应用程序(也在Intellij IDEA中)。

There are many answers in stackoverflow to solve this problem. stackoverflow中有很多答案可以解决这个问题。

JB Nizet has already dig this issue and told the root cause and solution procedure as below: JB Nizet已经挖掘了这个问题并告诉了根本原因和解决方案程序如下:

Hibernate 4.3 is the first version to implement the JPA 2.1 spec (part of Java EE 7). Hibernate 4.3是第一个实现JPA 2.1规范的版本(Java EE 7的一部分)。 And it's thus expecting the JPA 2.1 library in the classpath, not the JPA 2.0 library. 因此,它期望类路径中的JPA 2.1库,而不是JPA 2.0库。 That's why you get this exception: Table.indexes() is a new attribute of Table, introduced in JPA 2.1 这就是你得到这个异常的原因:Table.indexes()是JPA 2.1中引入的Table的新属性

For more you can check the related answer: 您可以查看相关答案:

  1. NoSuchMethodError in javax.persistence.Table.indexes()[Ljavax/persistence/Index javax.persistence.Table.indexes()中的NoSuchMethodError [Ljavax / persistence / Index
  2. java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index; java.lang.NoSuchMethodError:javax.persistence.Table.indexes()[Ljavax / persistence / Index;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM