1

我在 localhost 或 AWS EC2 实例中的 jar 就像一个魅力,但只是在 Elastic MapReduce 上它失败并出现“从未见过”异常:

Caused by: java.lang.IllegalArgumentException: class=class com.alvazan.orm.impl.meta.data.MetaClassSingle has two fields that have @NoSqlId annotation. One of them may be in a superclass

我试图从@NoSqlId中删除(usegenerator = true),但没有奏效。

例外:

2012-12-11 12:00:14,454 INFO com.alvazan.orm.logging.NoSqlRawLogger (main): [rawlogger] starting NoSQL Service Provider and connecting
2012-12-11 12:00:14,637 INFO com.netflix.astyanax.connectionpool.impl.ConnectionPoolMBeanManager (main): Registering mbean: com.netflix.MonitoredResources:type=ASTYANAX,name=MyConnectionPool,ServiceType=connectionpool
2012-12-11 12:00:15,261 INFO com.alvazan.orm.layer9z.spi.db.cassandra.ColumnFamilyHelper (main): On keyspace=dmpExisting column families=[stringindice, dbocolumnmeta, dbodatabasemeta, dbotablemeta]
NOTE: WE WILL CREATE new column families automatically as you save entites that have no column family
2012-12-11 12:00:15,262 INFO com.alvazan.orm.layer0.base.BaseEntityManagerFactoryImpl (main): Begin scanning for jars with nosql.Persistence.class
2012-12-11 12:00:15,289 INFO com.impetus.annovention.ClasspathDiscoverer (main): adding folder to scan=file:/mnt/var/lib/hadoop/tmp/hadoop-unjar5809470263616901335/
2012-12-11 12:00:15,289 INFO com.impetus.annovention.ClasspathDiscoverer (main): adding jar file for scanning=jar:file:/home/hadoop/project_w.jar!/
2012-12-11 12:00:16,212 INFO com.alvazan.orm.impl.meta.scan.ScannerForClass (main): scanning class=class com.s1mbi0se.dmp.da.bean.UserURL
2012-12-11 12:00:16,260 INFO com.alvazan.orm.api.z8spi.meta.DboTableMeta (main): [proxies loaded in this one]classloaders that proxies class exists in=classloader list={java.net.URLClassLoader@158f9d3,sun.misc.Launcher$AppClassLoader@1cde100,sun.misc.Launcher$ExtClassLoader@16f0472,}
2012-12-11 12:00:16,260 INFO com.alvazan.orm.api.z8spi.meta.DboTableMeta (main): [context classloader]classloaders that proxies class exists in=classloader list={java.net.URLClassLoader@158f9d3,sun.misc.Launcher$AppClassLoader@1cde100,sun.misc.Launcher$ExtClassLoader@16f0472,}
2012-12-11 12:00:16,260 INFO com.alvazan.orm.api.z8spi.meta.DboTableMeta (main): [system classloader]classloaders that proxies class exists in=classloader list={sun.misc.Launcher$AppClassLoader@1cde100,sun.misc.Launcher$ExtClassLoader@16f0472,}
2012-12-11 12:00:16,260 INFO com.alvazan.orm.api.z8spi.meta.DboTableMeta (main): [play jar in this classloader]classloaders that proxies class exists in=classloader list={java.net.URLClassLoader@158f9d3,sun.misc.Launcher$AppClassLoader@1cde100,sun.misc.Launcher$ExtClassLoader@16f0472,}
2012-12-11 12:00:16,260 INFO com.alvazan.orm.api.z8spi.meta.DboTableMeta (main): [javassist jar in this classloader]classloaders that proxies class exists in=classloader list={java.net.URLClassLoader@158f9d3,sun.misc.Launcher$AppClassLoader@1cde100,sun.misc.Launcher$ExtClassLoader@16f0472,}
2012-12-11 12:00:16,453 INFO com.alvazan.orm.impl.meta.scan.ScannerForClass (main): scanning class=class com.s1mbi0se.dmp.da.bean.Request
2012-12-11 12:00:16,473 INFO com.alvazan.orm.impl.meta.scan.ScannerForClass (main): scanning class=class com.s1mbi0se.dmp.da.bean.User
2012-12-11 12:00:17,167 INFO com.alvazan.orm.impl.meta.scan.ScannerForClass (main): scanning class=class com.alvazan.orm.api.z8spi.meta.DboColumnMeta
2012-12-11 12:00:17,246 INFO com.alvazan.orm.impl.meta.scan.ScannerForClass (main): scanning class=class com.alvazan.orm.api.z8spi.meta.DboDatabaseMeta
2012-12-11 12:00:17,248 INFO com.alvazan.orm.impl.meta.scan.ScannerForClass (main): scanning class=class com.alvazan.orm.api.z8spi.meta.DboTableMeta
2012-12-11 12:00:17,313 INFO com.alvazan.orm.impl.meta.scan.ScannerForClass (main): scanning class=class com.alvazan.play.logging.LogEvent
2012-12-11 12:00:17,318 INFO com.alvazan.orm.impl.meta.scan.ScannerForClass (main): scanning class=class com.alvazan.play.logging.ServersThatLog
2012-12-11 12:00:28,399 INFO com.alvazan.orm.impl.meta.scan.ScannerForClass (main): scanning class=class com.s1mbi0se.dmp.da.bean.UserURL

java.lang.RuntimeException: Failure scanning class(see chained exception)=class com.s1mbi0se.dmp.da.bean.UserURL
at com.alvazan.orm.layer0.base.MyClassAnnotationDiscoveryListener.scanClass(MyClassAnnotationDiscoveryListener.java:44)
at com.alvazan.orm.layer0.base.MyClassAnnotationDiscoveryListener.discovered(MyClassAnnotationDiscoveryListener.java:34)
at com.impetus.annovention.Discoverer.discoverAndIntimateForClassAnnotations(Discoverer.java:197)
at com.impetus.annovention.Discoverer.discover(Discoverer.java:155)
at com.alvazan.orm.layer0.base.BaseEntityManagerFactoryImpl.rescan(BaseEntityManagerFactoryImpl.java:80)
at com.alvazan.orm.layer0.base.BaseEntityManagerFactoryImpl.setup(BaseEntityManagerFactoryImpl.java:131)
at com.alvazan.orm.impl.bindings.BootstrapImpl.createInstanceImpl(BootstrapImpl.java:64)
at com.alvazan.orm.impl.bindings.BootstrapImpl.createInstance(BootstrapImpl.java:35)
at com.alvazan.orm.api.base.Bootstrap.create(Bootstrap.java:57)
at com.alvazan.orm.api.base.Bootstrap.create(Bootstrap.java:52)
at com.alvazan.orm.api.base.Bootstrap.create(Bootstrap.java:45)
at com.alvazan.orm.api.base.Bootstrap.create(Bootstrap.java:24)
at com.s1mbi0se.dmp.da.dao.PlayOrmConfiguration.init(PlayOrmConfiguration.java:39)
at com.s1mbi0se.dmp.da.service.DataAccessService.<init>(DataAccessService.java:28)
at com.s1mbi0se.dmp.da.service.DataAccessService.getInstance(DataAccessService.java:22)
at com.s1mbi0se.dmp.processor.main.DmpProcessorRunner.main(DmpProcessorRunner.java:80)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.hadoop.util.RunJar.main(RunJar.java:187)
Caused by: java.lang.RuntimeException: Failure scanning field=private java.lang.String com.s1mbi0se.dmp.da.bean.UserURL.id for class=UserURL
at com.alvazan.orm.impl.meta.scan.ScannerForClass.inspectField(ScannerForClass.java:196)
at com.alvazan.orm.impl.meta.scan.ScannerForClass.scanFields(ScannerForClass.java:189)
at com.alvazan.orm.impl.meta.scan.ScannerForClass.scanSingle(ScannerForClass.java:112)
at com.alvazan.orm.impl.meta.scan.ScannerForClass.addClass(ScannerForClass.java:69)
at com.alvazan.orm.layer0.base.MyClassAnnotationDiscoveryListener.scanClass(MyClassAnnotationDiscoveryListener.java:42)
... 32 more
Caused by: java.lang.IllegalArgumentException: class=class com.alvazan.orm.impl.meta.data.MetaClassSingle has two fields that have @NoSqlId annotation.  One of them may be in a superclass
at com.alvazan.orm.impl.meta.scan.ScannerForClass.processIdFieldWorks(ScannerForClass.java:233)
at com.alvazan.orm.impl.meta.scan.ScannerForClass.inspectFieldImpl(ScannerForClass.java:207)
at com.alvazan.orm.impl.meta.scan.ScannerForClass.inspectField(ScannerForClass.java:194)
... 36 more

我的用户类:

@NoSqlEntity
public class User {
    @NoSqlId
    @NoSqlIndexed
    @Field
    private String id;

    @NoSqlIndexed
    @Field
    private String nome;

    @NoSqlManyToMany
    @Field
    private List<UserURL> urls = new ArrayList<UserURL>();

    @NoSqlManyToMany
    @Field
    private List<Request> requests = new ArrayList<Request>();

    // getters and setters
}

我的 UserURL 类:

@NoSqlEntity
public class UserURL {
    @NoSqlId(usegenerator = true)
    @Field
    private String id;

    @Field
    private String url'

    @NoSqlManyToOne
    @NoSqlIndexed
    private User user;

    // getters and setters
}
4

1 回答 1

3

我们最近自己也看到了这个问题并进行了临时修复。从 master 分支获取最新的并尝试并让我知道。新代码看起来像这样,所以它应该告诉我们这两个字段(或者不扫描该字段两次)。

    if(metaClass.getIdField() != null) {
        Field existingField = metaClass.getIdField().getField();
        if(field.equals(existingField))
            return true; // we already processed it
        else
            throw new IllegalArgumentException("class="+metaClass.getClass()+" has two fields that have @NoSqlId annotation.  One of them may be in a superclass.  The two fields are="+field+" and="+existingField);
    }

注意:我们也在寻找更好的修复,因为有时这是由对类文件的双重扫描引起的,所以我们可能会在本周末之前发布另一个修复......我们目前正在通过电子邮件讨论它.

此外,此问题是由两次扫描类引起的......您的任何代码是否在 NoSqlEntityManagerFactory 中调用 rescan 方法?(我认为不是)。最新的应该现在可以解决您的问题,下周也可以回来查看。

院长

于 2012-12-11T14:59:03.050 回答