Jython saying “No visible constructors for class”

匿名 (未验证) 提交于 2019-12-03 03:10:03

问题:

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?

回答1:

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 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!