내가 물었다 관련 쿼리 JPA를 사용하려고 할 때 : How to configure & package a simple Java app to use JPA의 ClassNotFoundException : org.apache.derby.jdbc.EmbeddedDriver 더비
내가 EJB와 웹 로직에서 호스팅을 통해 연결할 수있는 간단한 Derby 데이터베이스를 가지고있다. 이제 JPA를 사용하는 명령 줄 Java 응용 프로그램에서이 응용 프로그램에 연결하고 싶습니다.
지금까지이 Java 코드 + persistence.xml 파일은 아래 오류를 던지고 있습니다. 내가 도대체 뭘 잘못하고있는 겁니까?
내 디렉토리 레이아웃 :C:.
│ Registrar.class
│ Registrar.java
│ TxnClient.class
│ TxnClient.java
│
└───META-INF
persistence.xml
독립 클라이언트 :
import javax.persistence.*;
public class TxnClient {
public static void main(String[] args) throws Exception {
EntityManagerFactory factory = Persistence.createEntityManagerFactory("SRS-EM");
EntityManager manager = factory.createEntityManager();
try {
} finally {
manager.close();
factory.close();
}
}
}
의 persistence.xml
<?xml version="1.0" encoding="windows-1252" ?>
<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_1_0.xsd" xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit name="SRS-EM" transaction-type="JTA">
<class>Registrar</class>
<properties>
<property name="openjpa.ConnectionDriverName"
value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="openjpa.ConnectionURL"
value="jdbc:derby:C:\derby-db-files\MyDB" />
</properties>
</persistence-unit>
</persistence>
C : \ 임시 \ JPA> 자바 TxnClient
80 SRS-EM INFO [main] openjpa.Runtime - Starting BEA Kodo 4.2.0load03
221 SRS-EM INFO [main] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.DerbyDictionary".
Exception in thread "main" <openjpa-1.1.0-r422266:657916 nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: There were errors initializing your configuration: <openjpa-1.1.0-r422266:657916 fatal store error> org.apache.openjpa.util.StoreException: org.apache.derby.jdbc.EmbeddedDriver
at org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:123)
at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:776)
at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getConnectionFactory(JDBCConfigurationImpl.java:683)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.openjpa.lib.conf.ConfigurationImpl.instantiateAll(ConfigurationImpl.java:288)
at org.apache.openjpa.conf.OpenJPAConfigurationImpl.instantiateAll(OpenJPAConfigurationImpl.java:1409)
at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:646)
at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:183)
at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
at TxnClient.main(TxnClient.java:7)
Caused by: java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:85)
... 15 more