クラウドエンドポイントV2、サーバーのリターンをGoogleに移行したJDOプロジェクトのNoClassDefFoundError

juanmeanwhile:

私は、エンドポイントがV1からV2にJDOを使用して、Googleのクラウドプロジェクトを移行しようとしました。私はdatanucleousプラグインが私のクラスを強化させる、とGoogleのクラウドにアップロードしようとするためにここに移行ガイドといくつかの解決策に従ってきましたが、運がありません。

私は、クライアントがNoClassFound誤りであるエンドポイントに接続しようとすると、エラーが返され、サーバーが続くbuild.gradleを投稿するつもりです。

build.gradle:

buildscript {
    repositories {
        mavenCentral()
        mavenLocal()
    }
    dependencies {
        // App Engine Gradle plugin
        classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.3'

        // Endpoints Frameworks Gradle plugin
        classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'

    }
}

repositories {
    mavenCentral();
    jcenter()
}

apply plugin: 'java'
apply plugin: 'war'

// [START apply_plugins]
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
// [END apply_plugins]

dependencies {
    compile ('com.google.endpoints:endpoints-framework:2.0.8') {
        exclude group: 'com.google.guava', module: 'guava-jdk5'
    }

    compile 'javax.servlet:servlet-api:2.5'
    compile 'com.ganyo:gcm-server:1.0.2'
    compile 'javax.jdo:jdo-api:3.0.1'
    compile 'org.datanucleus:datanucleus-core:3.1.3'
    compile 'org.datanucleus:datanucleus-api-jdo:3.1.3'
    compile 'org.datanucleus:datanucleus-accessplatform-jdo-rdbms:4.1.1'
    compile 'com.google.appengine.orm:datanucleus-appengine:2.1.2'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'org.apache.commons:commons-lang3:3.5'
}

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

appengine {  // App Engine tasks configuration
    deploy {   // deploy configuration
        version = findProperty("appengine.deploy.version")

        def promoteProp = findProperty("appengine.deploy.promote")
        if (promoteProp != null) {
            promote = new Boolean(promoteProp)
        }

    }
}

endpointsServer {
    // Endpoints Framework Plugin server-side configuration
    hostname = "komilibro.appspot.com"
}

task datanucleusEnhance {
    description "Enhance JDO model classes using DataNucleus Enhancer"
    dependsOn processResources

    doLast {
        // define the entity classes
        def entityFiles = fileTree(sourceSets.main.output.classesDir).matching {
            include 'com/meanwhile/komi/head/**/*.class'
        }

        println "Enhancing with DataNucleus the following files"
        entityFiles.getFiles().each {
            println it
        }

        // define Ant task for DataNucleus Enhancer
        ant.taskdef(
                name : 'datanucleusenhancer',
                classpath : sourceSets.main.runtimeClasspath.asPath,
                classname : 'org.datanucleus.enhancer.EnhancerTask'
                // the below is for DataNucleus Enhancer 3.1.1
                //classname : 'org.datanucleus.enhancer.tools.EnhancerTask'
        )

        // run the DataNucleus Enhancer as an Ant task
        ant.datanucleusenhancer(
                classpath: sourceSets.main.runtimeClasspath.asPath,
                verbose: true,
                api: "JDO") {
            entityFiles.addToAntBuilder(ant, 'fileset', FileCollection.AntType.FileSet)
        }
    }
}

classes.dependsOn(datanucleusEnhance)

最初:ユーザー要求の後にサーバーのログに見ると、私は2つのエラーを見ることができます:

    org.datanucleus.store.types.TypeManagerImpl loadJavaTypes: User-defined type
 mapping class "org.datanucleus.store.types.sco.simple.Collection" was not found.
 Please check the mapping file class specifications and your CLASSPATH. The class
 must be in the CLASSPATH. 

そして、これは秒です。PMFはただのPersistenceManagerの負荷およびインスタンスに使用されるクラスです。

com.google.api.server.spi.SystemService invokeServiceMethod: exception occurred while calling backend method (SystemService.java:375)
java.lang.NoClassDefFoundError: Could not initialize class com.meanwhile.komi.head.PMF

だから、必要なクラスが行われていないように思えるが、またTypeManagerImplは、(デフォルトのJavaコレクションは、エンドポイントで使用されている)コレクションクラスを見つけることができません。私はここで失わ少しだけど、そのヘルプが本当に歓迎されます。

ありがとう!

英李:

あなたのGradleビルドファイルでこれを追加します。

task datanucleusEnhance {
  description "Enhance JDO model classes using DataNucleus Enhancer"
  dependsOn compileJava

  doLast {    
      // define the entity classes
      def entityFiles = fileTree(sourceSets.main.output.classesDir).matching {
          include 'com/mycom/*.class', 'org/myorg/*.class'
      }

      println "Enhancing with DataNucleus the following files"
      entityFiles.getFiles().each {
          println it
      }

      // define Ant task for DataNucleus Enhancer
      ant.taskdef(
          name : 'datanucleusenhancer',
          classpath : sourceSets.main.runtimeClasspath.asPath,
          classname : 'org.datanucleus.enhancer.EnhancerTask'
          // the below is for DataNucleus Enhancer 3.1.1
          //classname : 'org.datanucleus.enhancer.tools.EnhancerTask'
      )

      // run the DataNucleus Enhancer as an Ant task
      ant.datanucleusenhancer(
          classpath: sourceSets.main.runtimeClasspath.asPath,
          verbose: true,
          api: "JDO") {
          entityFiles.addToAntBuilder(ant, 'fileset', FileCollection.AntType.FileSet)
      }
  }
}

classes.dependsOn(datanucleusEnhance)

あなたのJPAエンティティ注釈付きクラスを設定するところentityFilesです。

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=168669&siteId=1