Jython 说“类没有可见的构造函数”

发布于 2024-09-06 02:11:40 字数 379 浏览 2 评论 0原文

我有一个 jython servlet 作为在 tomcat5 中运行的大型应用程序的一部分。我测试了一些 Spring Framework 类并在 Jython servlet 中创建对象。当我尝试在应用程序中创建类的对象时,我收到一条异常消息“没有类的可见构造函数”。这些 java 类确实有一个公共构造函数类,例如:

public Sc​​hoolImpl() { }

我在 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 技术交流群。

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

发布评论

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

评论(1

稀香 2024-09-13 02:11:40

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 字段和方法的访问:

# Setting this to false will allow Jython to provide access to
# non-public fields, methods, and constructors of Java objects.
python.security.respectJavaAccessibility = false

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:

# Setting this to false will allow Jython to provide access to
# non-public fields, methods, and constructors of Java objects.
python.security.respectJavaAccessibility = false
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文