XSLT 未调用属于 Java 父类的方法:ClassNotFoundException &没有发现类定义错误

发布于 2024-11-14 00:16:43 字数 418 浏览 2 评论 0原文

我正在尝试调用一个方法,比如说 XSL 样式表中的 getFullName()。该方法属于 Person 类,它是 Student 的超类。我在 XSL 样式表命名空间中定义了 Student 类,如下所示:xmlns:std="java:example.code.Student"。但是,在运行时,我收到以下两个错误:example.code.abstract.PersonClassNotFoundExceptionNoClassDefFoundError。似乎 Person 的类定义在运行时不可用? Student 对象不应该有权访问其父对象的方法吗?

I am trying to make a call to a method, let's say getFullName() within an XSL stylesheet. The method belongs to a class Person, which is a superclass of Student. I have defined the Student class in the XSL stylesheet namespace as follows: xmlns:std="java:example.code.Student". However, during runtime, I get the following two errors: ClassNotFoundException and NoClassDefFoundError for example.code.abstract.Person. Seems like the class definitions for Person isn't available during runtime? Shouldn't the Student object have access to its parent's methods?

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

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

发布评论

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

评论(1

挽清梦 2024-11-21 00:16:43

似乎 Person 的类定义在运行时不可用?

是的,这将是对错误的正确解释。

Student 对象不应该访问其父对象的方法吗?

是的,Student 对象将可以访问父级的非私有方法。也就是说,前提是父类的类在运行时可用。换句话说,子类不嵌入父类的方法,因此需要父类可供访问。

子类加载期间父类不可用,导致NoClassDefFoundError。您需要确保父类和子类在运行时都可用,以防止发生错误。

Seems like the class definitions for Person isn't available during runtime?

Yes, that would be the correct interpretation of the error.

Shouldn't the Student object have access to its parent's methods?

Yes, the Student object will have access to the parent's non-private methods. That is, provided the parent's class is available at runtime. In other words, the child class does not embed the parent's methods, so it will need the parent class to be made available for access.

The parent class is unavailable during the load of the child class, resulting in the NoClassDefFoundError. You'll need to ensure that the both the parent and child classes are available at runtime to prevent the error from occuring.

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