gpt4 book ai didi

java - JDO/Datanucleus 错误 : Field "..." is declared as a reference type (interface/Object) but no implementation classes of "..." have been found?

转载 作者:行者123 更新时间:2023-12-01 15:42:10 24 4
gpt4 key购买 nike

我是 JDO 规范和 Datanucleus 实现的新手,我现在在我的项目中遇到上述错误。

哪些步骤将重现该问题:

1-定义类“DefaultDiffTask”:

`@PersistenceCapable 公共(public)类 DefaultDiffTask 实现 IDiffTask,可序列化 { @执着的 protected IDiffTaskTarget diffTaskTarget; @执着的 protected 字符串 diffTaskId;

protected IDiffTaskPhasesMgr diffTaskPhasesMgr;

@Persistent
protected IDiffTaskType diffTaskType;

@Persistent
protected String taskCreationTime;

public DefaultDiffTask() {

this.diffTaskTarget = new DefaultDiffTaskTarget(
new DefaultPageStateLocation(""), new DefaultPageStateLocation(
""));
this.diffTaskPhasesMgr = new DefaultDiffTaskPhasesMgr(this); //
DiffTaskUtility.createTaskPhasesMgr(this);
this.diffTaskType = new DefaultDiffTaskType(
DiffTaskTypeEnum.CRAWLER_BASED_DIFF);
this.taskCreationTime = (new Date()).toString();
this.diffTaskId = this.generateDiffTaskId();

}

public DefaultDiffTask(IDiffTaskTarget diffTaskArea,
IDiffTaskType diffTaskType) {
this.diffTaskTarget = diffTaskArea;
this.diffTaskPhasesMgr = new DefaultDiffTaskPhasesMgr(this); // DiffTaskUtility.createTaskPhasesMgr(this);
this.diffTaskType = diffTaskType;
this.taskCreationTime = (new Date()).toString();
this.diffTaskId = this.generateDiffTaskId();
}
...........`

2-尝试使用以下方法检索一些以前存储的对象:

PersistenceManagerFactory pmf = JDOHelper
.getPersistenceManagerFactory(.....);
// Persistence of a Product and a Book.
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
System.out.println("Retrieving Extent for Default");
Extent e = pm.getExtent(DefaultDiffTask.class, true);
Iterator iter = e.iterator();
while (iter.hasNext()) {
Object obj = iter.next();
System.out.println("> "
+ ((DefaultDiffTask) obj).getDiffTaskId());
}
tx.commit();
} catch (Exception e) {
System.out.println("Exception thrown during retrieval of Extent : "
+ e.getMessage());
} finally {
if (tx.isActive())
tx.rollback();
pm.close();
}

预期输出:

检索默认范围:这里有东西

但我发现他出现以下异常:

检索默认范围
检索范围期间抛出异常:字段“net.she.sw.diff2w3c.diff.tsk.DefaultDiffTask.diffTaskTarget”被声明为引用类型(接口(interface)/对象),但**没有“net.she.diff2w3c.diff.tsk.DefaultDiffTask.diffTaskTarget”的实现类**。 sw.diff2w3c.diff.tsk.target.IDiffTaskTarget”已找到!

我的观点是,我有一些接口(interface) net.she.sw.diff2w3c.diff.tsk.DefaultDiffTask.diffTaskTarget 的实现,其中带有注释“@PersistenceCapable”,例如:

@PersistenceCapable
public class DefaultDiffTaskTarget extends AbstractDiffTaskTarget {
public DefaultDiffTaskTarget(IDiffTaskTargetStateLocation firstLocation,
IDiffTaskTargetStateLocation secondLocation) {
super(firstLocation, secondLocation);
// TODO Auto-generated constructor stub
}

@PersistenceCapable
public class DefaultDiffTaskTarget extends AbstractDiffTaskTarget {

@PersistenceCapable
public class PageAreaTarget extends AbstractDiffTaskTarget {

当创建 DefaulfDiffTask 时,该对象被注入(inject)到构造函数中(默认和自定义)...

所以我的观点是

  • 为什么会出现这个错误?
  • 这是我遗漏的东西吗?
  • 接口(interface) IDiffTaskTarget 的实现的所有实现都存在于类路径中,并且具有 JDO/Datanucleus 工作所需的注释

我知道问题出在我的代码上,而不是在 JDO/Datanucleus 方面,我将不胜感激任何给予的帮助

最佳答案

DataNucleus 如何知道您的其他类?你希望它能猜出他们在哪里吗?为什么不按照文档 http://www.datanucleus.org/products/accessplatform/jdo/orm/interfaces.html 指定它们

关于java - JDO/Datanucleus 错误 : Field "..." is declared as a reference type (interface/Object) but no implementation classes of "..." have been found?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7878347/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com