Jython 说“类没有可见的构造函数”
我有一个 jython servlet 作为在 tomcat5 中运行的大型应用程序的一部分。我测试了一些 Spring Framework 类并在 Jython servlet 中创建对象。当我尝试在应用程序中创建类的对象时,我收到一条异常消息“没有类的可见构造函数”。这些 java 类确实有一个公共构造函数类,例如:
public SchoolImpl() { }
我在 python 中创建对象:
从 com.dc.sports.entity 导入 SchoolImpl
...
school = SchoolImpl()
我做错了什么?
I have a jython servlet as part of a large application running in tomcat5. I tested a few Spring Framework classes and create the objects in the Jython servlet. When I try to create objects of classes in the application I catch an Exception message "No visible constructors for class". These java classes do have a public constructor class, such as:
public SchoolImpl() {
}
I create the object in python:
from com.dc.sports.entity import SchoolImpl
...
school = SchoolImpl()
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
doublep / cluch 回答了问题:-) 在评论中
添加了一些信息:
来自 Jython FAQ :
3.3 Why can't Iexecute a 'protected' or 'private' Java instance method or access a 'protected'或 Java 包中的“私有”属性?
默认情况下,与 Java 中一样,这些方法受到保护,免受外部访问。可以使用 python.security.respectJavaAccessibility 注册表设置启用对所有 Java 字段和方法的访问:
doublep / cluch answered the question :-) in the comment
adding just a little info:
From the Jython FAQ :
3.3 Why can't I execute a 'protected' or 'private' Java instance method or access a 'protected' or 'private' attribute in a Java package?
By default, as in Java, these methods are protected from external access. Access to all Java fields and methods can be enabled with the python.security.respectJavaAccessibility registry setting: