我正在关注来自derby的教程:
http://db.apache.org/derby/papers/DerbyTut/
我已在系统上成功安装了derby:
hduser@libafd:/usr/local/derby$ java org.apache.derby.tools.sysinfo
------------------ Java Information ------------------
Java Version: 1.7.0_79
Java Vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Java classpath: /usr/local/derby/lib/derby.jar:/usr/local/derby/lib/derbytools.jar::/usr/local/hive/lib/hive-cli-1.2.0.jar:/usr/local/hive/lib/velocity-1.5.jar:/usr/local/hive/lib/xz-1.0.jar:/usr/local/hive/lib/calcite-core-1.2.0-incubating.jar:/usr/local/hive/lib/geronimo-annotation_1.0_spec-1.1.1.jar:/usr/local/hive/lib/guava-14.0.1.jar:/usr/local/hive/lib/calcite-avatica-1.2.0-incubating.jar:/usr/local/hive/lib/jdo-api-3.0.1.jar:/usr/local/hive/lib/maven-scm-provider-svn-commons-1.4.jar:/usr/local/hive/lib/stax-api-1.0.1.jar:/usr/local/hive/lib/asm-tree-3.1.jar:/usr/local/hive/lib/curator-recipes-2.6.0.jar:/usr/local/hive/lib/libfb303-0.9.2.jar:/usr/local/hive/lib/janino-2.7.6.jar:/usr/local/hive/lib/commons-cli-1.2.jar:/usr/local/hive/lib/commons-vfs2-2.0.jar:/usr/local/hive/lib/commons-pool-1.5.4.jar:/usr/local/hive/lib/libthrift-0.9.2.jar:/usr/local/hive/lib/super-csv-2.2.0.jar:/usr/local/hive/lib/hive-jdbc-1.2.0-standalone.jar:/usr/local/hive/lib/accumulo-core-1.6.0.jar:/usr/local/hive/lib/hive-common-1.2.0.jar:/usr/local/hive/lib/pentaho-aggdesigner-algorithm-5.1.5-jhyde.jar:/usr/local/hive/lib/accumulo-trace-1.6.0.jar:/usr/local/hive/lib/junit-4.11.jar:/usr/local/hive/lib/hive-serde-1.2.0.jar:/usr/local/hive/lib/curator-client-2.6.0.jar:/usr/local/hive/lib/jcommander-1.32.jar:/usr/local/hive/lib/geronimo-jaspic_1.0_spec-1.0.jar:/usr/local/hive/lib/hive-shims-0.20S-1.2.0.jar:/usr/local/hive/lib/bonecp-0.8.0.RELEASE.jar:/usr/local/hive/lib/mail-1.4.1.jar:/usr/local/hive/lib/hive-beeline-1.2.0.jar:/usr/local/hive/lib/datanucleus-rdbms-3.2.9.jar:/usr/local/hive/lib/datanucleus-api-jdo-3.2.6.jar:/usr/local/hive/lib/netty-3.7.0.Final.jar:/usr/local/hive/lib/commons-dbcp-1.4.jar:/usr/local/hive/lib/jpam-1.1.jar:/usr/local/hive/lib/httpcore-4.4.jar:/usr/local/hive/lib/hive-metastore-1.2.0.jar:/usr/local/hive/lib/commons-httpclient-3.0.1.jar:/usr/local/hive/lib/ant-1.9.1.jar:/usr/local/hive/lib/hive-shims-scheduler-1.2.0.jar:/usr/local/hive/lib/commons-compiler-2.7.6.jar:/usr/local/hive/lib/hive-exec-1.2.0.jar:/usr/local/hive/lib/commons-digester-1.8.jar:/usr/local/hive/lib/jsr305-3.0.0.jar:/usr/local/hive/lib/json-20090211.jar:/usr/local/hive/lib/accumulo-start-1.6.0.jar:/usr/local/hive/lib/activation-1.1.jar:/usr/local/hive/lib/commons-logging-1.1.3.jar:/usr/local/hive/lib/oro-2.0.8.jar:/usr/local/hive/lib/commons-io-2.4.jar:/usr/local/hive/lib/commons-compress-1.4.1.jar:/usr/local/hive/lib/hive-ant-1.2.0.jar:/usr/local/hive/lib/hive-testutils-1.2.0.jar:/usr/local/hive/lib/calcite-linq4j-1.2.0-incubating.jar:/usr/local/hive/lib/jetty-all-server-7.6.0.v20120127.jar:/usr/local/hive/lib/commons-configuration-1.6.jar:/usr/local/hive/lib/ST4-4.0.4.jar:/usr/local/hive/lib/servlet-api-2.5.jar:/usr/local/hive/lib/commons-math-2.1.jar:/usr/local/hive/lib/ivy-2.4.0.jar:/usr/local/hive/lib/ant-launcher-1.9.1.jar:/usr/local/hive/lib/paranamer-2.3.jar:/usr/local/hive/lib/hive-service-1.2.0.jar:/usr/local/hive/lib/datanucleus-core-3.2.10.jar:/usr/local/hive/lib/log4j-1.2.16.jar:/usr/local/hive/lib/maven-scm-api-1.4.jar:/usr/local/hive/lib/opencsv-2.3.jar:/usr/local/hive/lib/jetty-all-7.6.0.v20120127.jar:/usr/local/hive/lib/eigenbase-properties-1.1.5.jar:/usr/local/hive/lib/snappy-java-1.0.5.jar:/usr/local/hive/lib/commons-beanutils-core-1.8.0.jar:/usr/local/hive/lib/curator-framework-2.6.0.jar:/usr/local/hive/lib/zookeeper-3.4.6.jar:/usr/local/hive/lib/maven-scm-provider-svnexe-1.4.jar:/usr/local/hive/lib/geronimo-jta_1.1_spec-1.1.1.jar:/usr/local/hive/lib/apache-log4j-extras-1.2.17.jar:/usr/local/hive/lib/stringtemplate-3.2.1.jar:/usr/local/hive/lib/plexus-utils-1.5.6.jar:/usr/local/hive/lib/commons-beanutils-1.7.0.jar:/usr/local/hive/lib/accumulo-fate-1.6.0.jar:/usr/local/hive/lib/commons-collections-3.2.1.jar:/usr/local/hive/lib/groovy-all-2.1.6.jar:/usr/local/hive/lib/tempus-fugit-1.1.jar:/usr/local/hive/lib/hive-hwi-1.2.0.jar:/usr/local/hive/lib/derby-10.11.1.1.jar:/usr/local/hive/lib/hive-jdbc-1.2.0.jar:/usr/local/hive/lib/antlr-2.7.7.jar:/usr/local/hive/lib/commons-lang-2.6.jar:/usr/local/hive/lib/commons-codec-1.4.jar:/usr/local/hive/lib/httpclient-4.4.jar:/usr/local/hive/lib/jta-1.1.jar:/usr/local/hive/lib/jline-2.12.jar:/usr/local/hive/lib/parquet-hadoop-bundle-1.6.0.jar:/usr/local/hive/lib/hive-shims-0.23-1.2.0.jar:/usr/local/hive/lib/hive-contrib-1.2.0.jar:/usr/local/hive/lib/hive-accumulo-handler-1.2.0.jar:/usr/local/hive/lib/regexp-1.3.jar:/usr/local/hive/lib/joda-time-2.5.jar:/usr/local/hive/lib/antlr-runtime-3.4.jar:/usr/local/hive/lib/hive-shims-1.2.0.jar:/usr/local/hive/lib/avro-1.7.5.jar:/usr/local/hive/lib/asm-commons-3.1.jar:/usr/local/hive/lib/hive-shims-common-1.2.0.jar:/usr/local/hive/lib/hamcrest-core-1.1.jar:/usr/local/hive/lib/hive-hbase-handler-1.2.0.jar:.:/usr/local/derby/lib/derby.jar:/usr/local/derby/lib/derbytools.jar
OS name: Linux
OS architecture: amd64
OS version: 3.5.0-52-generic
Java user name: hduser
Java user home: /home/hduser
Java user dir: /usr/local/db-derby-10.4.2.0-bin
java.specification.name: Java Platform API Specification
java.specification.version: 1.7
--------- Derby Information --------
JRE - JDBC: Java SE 6 - JDBC 4.0
[/usr/local/db-derby-10.4.2.0-bin/lib/derby.jar] 10.4.2.0 - (689064)
[/usr/local/db-derby-10.4.2.0-bin/lib/derbytools.jar] 10.4.2.0 - (689064)
[/usr/local/apache-hive-1.2.0-bin/lib/hive-jdbc-1.2.0-standalone.jar] 10.11.1.1 - (1616546)
[/usr/local/apache-hive-1.2.0-bin/lib/derby-10.11.1.1.jar] 10.11.1.1 - (1616546)
------------------------------------------------------
----------------- Locale Information -----------------
Current Locale : [English/United States [en_US]]
Found support for locale: [cs]
version: 10.4.2.0 - (689064)
Found support for locale: [de_DE]
version: 10.4.2.0 - (689064)
Found support for locale: [es]
version: 10.4.2.0 - (689064)
Found support for locale: [fr]
version: 10.4.2.0 - (689064)
Found support for locale: [hu]
version: 10.4.2.0 - (689064)
Found support for locale: [it]
version: 10.4.2.0 - (689064)
Found support for locale: [ja_JP]
version: 10.4.2.0 - (689064)
Found support for locale: [ko_KR]
version: 10.4.2.0 - (689064)
Found support for locale: [pl]
version: 10.4.2.0 - (689064)
Found support for locale: [pt_BR]
version: 10.4.2.0 - (689064)
Found support for locale: [ru]
version: 10.4.2.0 - (689064)
Found support for locale: [zh_CN]
version: 10.4.2.0 - (689064)
Found support for locale: [zh_TW]
version: 10.4.2.0 - (689064)
------------------------------------------------------
hduser@libafd:/usr/local/derby$
当我继续阅读本教程的ij基础知识一章时,出现以下错误:
hduser@libafd:/usr/local/derby$ java org.apache.derby.tools.ij
ij version 10.4
ij> connect 'jdbc:derby:MyDbTest;create=true';
JAVA ERROR: java.lang.ExceptionInInitializerError
ij>
要么
hduser@libafd:/usr/local/derby/lib$ java -Djdbc.drivers=org.apache.derby.jdbc.EmbeddedDriver org.apache.derby.tools.ij
ij version 10.4
ij> connect 'jdbc:derby:MyDbTest;create=true';
JAVA ERROR: java.lang.ExceptionInInitializerError
ij>
我该如何解决(即创建数据库并继续学习本教程:))
最佳答案
我想问题是您的类路径中有多个Derby JAR副本。一共有三份derby.jar
和两份derbytools.jar
。
This page显示与您类似的错误,最终是由java.lang.SecurityException: sealing violation: package org.apache.derby.impl.store.raw.data is sealed
异常引起的。将一个程序包密封在一个JAR中可以防止该程序包中的类被另一个JAR加载,并且如果您在类路径上有Derby JAR的多个副本(尤其是如果Derby版本不同),则很有可能会碰到一个这样的密封问题。
我可以在类路径上仅使用ij
和derby.jar
来愉快地运行Derby derby-tools.jar
工具。
关于java - 试用derby并按照说明进行操作会产生java.lang.ExceptionInInitializerError错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30397927/