Netbeans 7.4에서 Derby 데이터베이스를 시작할 수 없습니다.
Netbeans 7.4 및 Java 7 Update 51을 다운로드했습니다. Netbeans에서 Java DB 또는 더비 연결을 시작하려고하면 아래 오류가 발생합니다. 이것은 Windows 8 PC에 있습니다. 직장에서 Windows xp 32 비트 버전을 다운로드했습니다. 잘 작동합니다. 무엇이 빠졌는지 잘 모르겠습니다.
Thu Jan 16 00:48:23 EST 2014 : Security manager installed using the Basic server security policy.
Thu Jan 16 00:48:24 EST 2014 : access denied ("java.net.SocketPermission" "localhost:1527" "listen,resolve")
java.security.AccessControlException: access denied ("java.net.SocketPermission" "localhost:1527" "listen,resolve")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
at java.security.AccessController.checkPermission(AccessController.java:559)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkListen(SecurityManager.java:1134)
at java.net.ServerSocket.bind(ServerSocket.java:375)
at java.net.ServerSocket.<init>(ServerSocket.java:237)
at javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:231)
at org.apache.derby.impl.drda.NetworkServerControlImpl.createServerSocket(Unknown Source)
at org.apache.derby.impl.drda.NetworkServerControlImpl.access$000(Unknown Source)
at org.apache.derby.impl.drda.NetworkServerControlImpl$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.derby.impl.drda.NetworkServerControlImpl.blockingStart(Unknown Source)
at org.apache.derby.impl.drda.NetworkServerControlImpl.executeWork(Unknown Source)
at org.apache.derby.drda.NetworkServerControl.main(Unknown Source)
이것이 내가 한 일입니다.
NetBeans 7.4에서 다음 명령을 실행하여 Java 홈이 정확히 어디에 있는지 확인하십시오.
System.out.println (System.getProperty ( "java.home"));
이것은 내 경우의 출력입니다.
C : \ Program Files \ Java \ jdk1.7.0_51 \ jre
그것은 나에게 매우 중요했습니다. 나는 다른 것을 수정
java.policy
하고 있었고 아무런 효과가 없었고 몇 시간을 낭비했습니다.이유
java.policy
는 유닉스 스타일 파일이며 읽기 전용이므로 메모장 ++로 열고 편집하고 관리자로 실행했습니다 (동일한 Java 홈에서).C : \ Program Files \ Java \ jdk1.7.0_51 \ jre \ lib \ security \ java.policy
첫 번째 권한 부여 후 다음 행만 파일에 추가하십시오.
grant { 권한 java.net.SocketPermission "localhost : 1527", "listen"; };
- 권한 때문에 조금 까다로운 파일을 저장하십시오. 하지만 메모장 ++이나 다른 편집 프로그램을 관리자 권한으로 실행하면 문제를 해결할 수 있습니다.
그런 다음 NetBeans에서 데이터베이스를 연결하십시오.
행운을 빕니다.
에 따르면 자바 ™ SE 개발 키트 7 업데이트 51 릴리스 노트
기본 소켓 권한 변경
The default socket permissions assigned to all code including untrusted code have been changed in this release. Previously, all code was able to bind any socket type to any port number greater than or equal to 1024. It is still possible to bind sockets to the ephemeral port range on each system. The exact range of ephemeral ports varies from one operating system to another, but it is typically in the high range (such as from 49152 to 65535). The new restriction is that binding sockets outside of the ephemeral range now requires an explicit permission in the system security policy.
Most applications using client tcp sockets and a security manager will not see any problem, as these typically bind to ephemeral ports anyway. Applications using datagram sockets or server tcp sockets (and a security manager) may encounter security exceptions where none were seen before. If this occurs, users should review whether the port number being requested is expected, and if this is the case, a socket permission grant can be added to the local security policy, to resolve the issue.
This means that you have to explicity set the permissions for your application to be able to access the ports range between 1025 and 49151. You can therefore grant this permission by appending this line in the list of permissions granted:
Visit your Java Home Directory and access your policy file at $JAVA_HOME/jre/lib/security/java.policy
and make the following changes.
grant{
//List of granted permissions
permission java.net.SocketPermission "localhost:1527", "listen";
}
See http://www.oracle.com/technetwork/java/javase/7u51-relnotes-2085002.html for the description of the "problem". Search other-libs/javadb
Depending on your requirement, what I did was go and modify the default security policy
cd $JAVA_HOME/jre/lib/security
Edit java.policy
(make a backup first!)
Add the following
grant codeBase "file:${java.home}}/../db/lib/*" {
permission java.security.AllPermission;
};
Note that this is my requirement.
I'm granting every app who uses the u51 JRE the permission to start Derby.
EDIT
The alternative would be to use a less permissive set of permissions like:
grant codeBase "file:${java.home}}/../db/lib/*" {
permission java.net.SocketPermission "localhost:1527", "listen,resolve";
};
NetBeans, by default, uses the derby version installed with GlassFish. So my permissions look like this on the Mac. It will be similar on Windows, but the path will need to change.
grant codeBase "file:/Applications/NetBeans/glassfish-4.0/javadb/lib/*" {
permission java.net.SocketPermission "localhost:1527", "listen,resolve";
};
Because the upper measures didn't work I added the following permission to the end of the main permission section:
permission java.net.SocketPermission "localhost:1527", "listen,resolve";
You can also solve the problem on a per-user basis by granting the needed permission in a file called .java.policy
in your home directory.
Works on both Unix and Windows systems as documented here: http://docs.oracle.com/javase/7/docs/technotes/guides/security/PolicyFiles.html
This might be useful if the system-wide policy file gets overwritten, for example when updating your JDK, or if you don't have permission to edit the system file.
This is what I have in my $HOME/.java.policy
:
grant {
permission java.net.SocketPermission "localhost:1527", "listen";
};
I got a bit fed up with Oracle's approach to security lately. They seem to be trying to protect us from ourselves in ways that would be more appropriate to naive users than programmers. My view is that the code I put on my own machine should be able to do whatever it needs to. It's my fault if I put code there that does bad things. Clearly not a universally reliable perspective, but it's worked for me for about 35 years. On that basis, I add this to my /lib/security/java.policy file:
grant codeBase "file:/-" {
permission java.security.AllPermission;
};
note that the file:/- matches any file on the system, and the grant block says, in essence, "if the class is loaded from this file system, then trust it".
This was doing my head in for a bit until I stumbled across the following in the NetBeans wiki
JavaDB grant permissions
How to grant permissions for Java DB / How to start Java DB
Related to issue #239962
JDK 7u51 comes with some security improvements which are causing problems with starting Java DB on this Java version.
When you try to start DB from NetBeans you will probably get the Exception:
java.security.AccessControlException: access denied ("java.net.SocketPermission" "localhost:1527" "listen,resolve")
The same exception you will get while starting using script /db/bin/startNetworkServer
Because there is no suitable way to fix it on the NetBeans side and this should be fixed on the side of the Java DB.
There are several ways how to deal with this problem. I will mention only the easiest way. You have to start DB manually from command line.
• Start Java DB with -noSecurityManager argument.
(JDK 7u51 location)/db/bin/startNetworkServer -noSecurityManager
Although it’s not exactly a solution it is usable as a quick workaround.
My solution to this was to reinstall jdk 1.7.45, uninstall netbeans and reinstall it selecting the outdated jdk. Don't know if there is a way to change sdk in NB without reinstalling it but it worked this way.
Well, one alternative is to change the port JavaDB listens to, to be now in the high range (such as from 49152 to 65535). Go to Window->Services, then right click Java DB and in "Java DB Properties Dialog" goto to "Database Location", which in my system is "C:\Users\ahernandeza.netbeans-derby" In that directory edit or create the file derby.properties, and add/edit the line: derby.drda.portNumber=XXXX Where XXXX is the new port, in my case i put 51527 and worked just fine.
편집 처음에는 작동했지만 서비스는 정상적으로 시작되었지만 NB에서 데이터베이스를 만들거나 시작할 때 연결할 수 없다는 오류가 발생했습니다. jdbc : derby : // localhost : 1527 / sample에 대한 연결을 설정할 수 없습니다. pprt를 51527로 변경했지만 1527에 연결하려고합니다.
리눅스라면
file=`find $(dirname $(readlink -f $(which java)))/.. -iname 'java.policy'`; grep 1527 $file || sudo sed -i '0,/"listen"/{s/"listen".*/\0\n\tpermission java.net.SocketPermission "localhost:1527", "listen";/}' $file
cat $file
자동으로 Java를 찾고 권한을 변경합니다.
이 문제에 대한 빠른 해결책을 찾았습니다. 다음과 같이 명령 줄 \ 터미널에서 JavaDB를 시작하십시오.
<base folder>/db/bin/startNetworkServer -noSecurityManager
그런 다음 새 권한을 추가하지 않고 정상적으로 실행됩니다.
문제는 Java 7u51이며 Derby 및 기타 프로그램 및 라이브러리에 영향을 미치는 버그가 있습니다. Java 7u45를 설치하는 것이 좋습니다.
참조 URL : https://stackoverflow.com/questions/21154400/unable-to-start-derby-database-from-netbeans-7-4
'IT Share you' 카테고리의 다른 글
awk에서 배열의 길이를 어떻게 얻을 수 있습니까? (0) | 2021.01.09 |
---|---|
Python, OpenCV에서 슬라이싱을 사용하여 이미지에서 영역 추출 (0) | 2021.01.09 |
시작시 배치 파일 실행 (0) | 2021.01.09 |
Java OutOfMemoryError 이상한 동작 (0) | 2021.01.08 |
Spring에서 ModelAndView 대 Model을 언제 사용합니까? (0) | 2021.01.08 |