Я пытаюсь реализовать RMI с Kotlin, но получаю следующую ошибку. Кажется, он не подчиняется моему серверу. Policy
Server exception: java.security.AccessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:1099" "connect,resolve")
java.security.AccessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:1099" "connect,resolve")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
at java.security.AccessController.checkPermission(AccessController.java:884)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1051)
at java.net.Socket.connect(Socket.java:584)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:211)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:342)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:177)
at Task2Server$Companion.main(Task2Server.kt:24)
at Task2Server.main(Task2Server.kt)
Это код сервера
class Task2Server {
companion object {
val name = "task2server"
val url = "//localhost/$name"
@JvmStatic
fun main(args: Array<String>) {
if (System.getSecurityManager() == null) {
System.setSecurityManager(SecurityManager())
}
try {
val graphSearcher: GraphSearcher = SearcherImpl()
LocateRegistry.getRegistry(Registry.REGISTRY_PORT)
Naming.rebind(url, graphSearcher)
println("Server is ready")
} catch (ex: Exception) {
System.err.println("Server exception: " + ex.toString());
ex.printStackTrace()
System.exit(0)
}
}
}
}
Это мои vmoptions в IntelliJ
-Djava.rmi.server.codebase=file:.\graphSearcher.jar
-Djava.rmi.server.hostname=localhost -Djava.security.manager
-Djava.security.policy=server.policy
Наконец-то это моя политика
grant codeBase "file:*" {
permission java.security.AllPermission;
};
Моя структура проекта, если она используется