XSLT 未调用属于 Java 父类的方法:ClassNotFoundException &没有发现类定义错误
我正在尝试调用一个方法,比如说 XSL 样式表中的 getFullName()
。该方法属于 Person
类,它是 Student
的超类。我在 XSL 样式表命名空间中定义了 Student
类,如下所示:xmlns:std="java:example.code.Student"
。但是,在运行时,我收到以下两个错误:example.code.abstract.Person
的 ClassNotFoundException 和 NoClassDefFoundError。似乎 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这将是对错误的正确解释。
是的,Student 对象将可以访问父级的非私有方法。也就是说,前提是父类的类在运行时可用。换句话说,子类不嵌入父类的方法,因此需要父类可供访问。
子类加载期间父类不可用,导致NoClassDefFoundError。您需要确保父类和子类在运行时都可用,以防止发生错误。
Yes, that would be the correct interpretation of the error.
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.