JDO/Datanucleus 错误:字段“...”被声明为引用类型(接口/对象),但没有“...”的实现类被发现了吗?

发布于 2024-12-12 02:14:16 字数 3322 浏览 0 评论 0原文

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

哪些步骤将重现该问题:

1-定义类“DefaultDiffTask”:

`@PersistenceCapable 公共类 DefaultDiffTask 实现 IDiffTask,可序列化 { @执着的 受保护的 IDiffTaskTarget diffTaskTarget; @执着的 受保护的字符串 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();
}

预期输出:

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

但我得到以下异常:

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

我的观点是,我有一些接口 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 时...

所以我的观点是

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

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

I'm new to JDO specification and Datanucleus implementations and i'm struggling right now in my Project with the error described above.

What steps will reproduce the Problem:

1- Defining a Class "DefaultDiffTask":

`@PersistenceCapable
public class DefaultDiffTask implements IDiffTask, Serializable {
@Persistent
protected IDiffTaskTarget diffTaskTarget;
@Persistent
protected String 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- try to retrieve some previously stored object with :

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();
}

the expected output:

Retrieving Extent for Default:
something here

But i get he following exception:

Retrieving Extent for Default
Exception thrown during retrieval of Extent : Field "net.she.sw.diff2w3c.diff.tsk.DefaultDiffTask.diffTaskTarget" is declared as a reference type (interface/Object) but **no implementation classes** of "net.she.sw.diff2w3c.diff.tsk.target.IDiffTaskTarget" have been found!

my point is, i have some implementation of the interface net.she.sw.diff2w3c.diff.tsk.DefaultDiffTask.diffTaskTarget which have the annotation "@PersistenceCapable" like:

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

or

@PersistenceCapable
public class DefaultDiffTaskTarget extends AbstractDiffTaskTarget {

or

@PersistenceCapable
public class PageAreaTarget extends AbstractDiffTaskTarget {

this object are injected in the constructors (default and custom) when a DefaulfDiffTask get created...

so my point is

  • Why this error ?
  • is it something i am missing ?
  • all the implementation of the implementations of the interface IDiffTaskTargetare present in the classpath AND have the Annotations for the JDO/Datanucleus to work

i know the problem is on my code and not on the side of JDO/Datanucleus,
and i will be greatful for any given help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

謌踐踏愛綪 2024-12-19 02:14:16

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

How does DataNucleus know of your other classes ? you expect it to guess where they are ? Why not just specify them as per the docs http://www.datanucleus.org/products/accessplatform/jdo/orm/interfaces.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文