尝试使用 Hibernate、JPA 和嵌入式 Derby 组装一个非常小的 JPA 测试应用程序。从 Derby 获取 IllegalAccessError,我无法在 Internet 上解决或找到可用信息:
Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.apache.derby.jdbc.EmbeddedDriver.boot()V from class org.apache.derby.jdbc.AutoloadedDriver
derby.jar 10.9.1.0 在类路径中。
我已经成功地为我的 Oracle XE 实例设置了一个类似的 persistence.xml,它运行良好。
我没有运行任何 derby 网络服务器。我已遵循 derby 安装说明并验证了安装。我使用 derby "ij" 命令行工具来创建我的数据库(名为 "swift")。
我无法理解这个例外,并且肯定会欣赏一些新的眼睛。
缩写堆栈跟踪:
INFO: HHH000401: using driver [org.apache.derby.jdbc.EmbeddedDriver] at URL [jdbc:derby:localhost:1527/swift:create-true]
Sep 14, 2012 11:12:00 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000046: Connection properties: {user=swift, password=****, autocommit=true, release_mode=auto}
Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.apache.derby.jdbc.EmbeddedDriver.boot()V from class org.apache.derby.jdbc.AutoloadedDriver
at org.apache.derby.jdbc.AutoloadedDriver.getDriverModule(Unknown Source)
at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
持久性.XML:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns /persistence/persistence_2_0.xsd">
<persistence-unit name="persistenceUnit">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.gdeb.swift.NIIN</class>
<class>com.gdeb.swift.RIC</class>
<properties>
<property name="hibernate.connection.driver_class" value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="hibernate.connection.url" value="jdbc:derby:/swift:create-true" />
<property name="hibernate.connection.username" value="swift" />
<property name="hibernate.connection.password" value="swift" />
</properties>
</persistence-unit>
</persistence>