2010-07-12 2 views
6

Java Persistence를 사용할 수있는 번들을 하나 만들고 싶습니다. 이를 위해 Eclipse 내에서 플러그인 프로젝트를 만들었습니다. 우리 프로젝트에서는 META-INF에 persistence.xml 파일을 만들었습니다.EclipseLink : EntityManager에 대한 지속성 공급자가 없음

  1. javax.persistence.jar
  2. org.eclipse.persistence.jar
  3. org.eclipse.persistence.jar : 나는 끄트머리 그 3 개 패키지합니다 (depencies에) 내 MANIFEST.MF에 추가 한

그런 다음, 내 활성제에 내가 EntityManager를 만들려면이 라인을 사용 :

factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME); 
EntityManager em = factory.createEntityManager(); 

내 번들을 실행하기를, 나는의 produ를했습니다 ct 구성.

javax.persistence.PersistenceException : 내가 성공하지 않고 내 persistence.xml의 위치를 ​​이동하려고했습니다 EntityManager의 이름이 사람들

없음 지속성 제공자 내 제품 구성을 실행하면,이 오류가 발생했습니다 . 모든 패키지가 persistence.xml 파일을로드하는 것 같습니다. 어쩌면 올바른 패키지를 가져올 수 없습니까?

당신은 여기 내 간단한 번들을 다운로드 할 수 있습니다 download

당신이 나에게 솔루션이나 단서를 찾는 데 도움이 될 수 있을까요? persistence.xml이 태그를 추가

답변

4

봅니다 : 헤더 :

<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
+1

감사합니다.하지만이 라인은 계속 사용하고 있습니다.XML 파일. 다른 해결책? – user376112

2

당신이 JPA-PersistenceUnits와 MANIFEST.MF에 퍼시스턴스 유닛을 설명하지 않은 것으로 보인다. EclipseLink에 대한 자세한 내용은 여기 (1)에서 확인할 수 있습니다.

(1) : http://wiki.eclipse.org/Gemini/JPA/Documentation/CreatingAnApplication

+0

나는 내 문제를 해결했다. 난 단지 매니페스트의 클래스 경로에 넣어했다이 패키지 : - eclipselink.jar - - persistence.jar mysql을 - connector.jar 감사 – user376112

6

나는 내 문제를 해결했습니다. 난 단지 매니페스트의 클래스 경로에 넣어했다이 패키지 : - eclipselink.jar - - persistence.jar mysql을 - connector.jar

감사

+0

나는 당신이 그 항아리에 매니페스트를 추가했다 팔로우 확실하지 않다 파일? 조금 더 자세히 설명 할 수 있습니까? – simgineer

1

사용 이클립스 내에서 응용 프로그램을 실행하는 경우 Maven에서 JPA 프로젝트를 마우스 오른쪽 버튼으로 클릭하고 Properties를 선택한 다음 "Deployment Assembly"메뉴 항목이 있는지 확인하십시오. 그렇다면 배치 어셈블리를 클릭하고 추가 ... 단추를 클릭하고 Java 빌드 경로 항목을 클릭 한 다음 Maven 종속성을 선택하십시오. eclipselink.jar이 Maven 종속성에 속하는지 확인하십시오.

1

Eclipse에서 실행되는 간단한 프로젝트에서 동일한 오류가 발생했습니다.

내 클래스 경로에 META-INF 디렉토리 (persistence.xml 포함)를 추가하는 것이 잘못된 것이라고 밝혀졌습니다.

클래스 경로에 포함 된 dir (또는 jar)이 있어야합니다. EclipseLink 2.5.1 출처 :

/** 
    * Search the classpath for persistence archives. A persistence archive is 
    * defined as any part of the class path that contains a META-INF directory 
    * with a persistence.xml file in it. Return a list of {@link Archive} 
    * representing the root of those files. It is the caller's responsibility 
    * to close all the archives. 
    * 
    * @param loader the class loader to get the class path from 
    */ 
    public static Set<Archive> findPersistenceArchives(ClassLoader loader){ 
     // allow alternate persistence location to be specified via system property. This will allow persistence units 
     // with alternate persistence xml locations to be weaved 
     String descriptorLocation = System.getProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML_DEFAULT); 
     return findPersistenceArchives(loader, descriptorLocation); 
    } 
관련 문제