2013-05-30 7 views
4

EJB 3.1, JPA 2.0, M2E-WTP 및 JSF 2.1 기술을 사용하여 weblogic 12c 서버에서 webapp를 실행하려고 시도하고 다음 오류가 계속 발생합니다.Webapp에서 지속성 장치를 찾을 수 없습니다. 범위에 'X'라는 지속성 단위를 사용할 수 없습니다.

javax.ejb.EJBException: EJB 
Exception: : java.lang.IllegalArgumentException: No persistence unit named 'X' 
is available in scope Webapp. Available persistence units: [] at 
weblogic.persistence.ModulePersistenceUnitRegistry 
.getPersistenceUnit(ModulePersistenceUnitRegistry.java:130) at 
weblogic.persistence.BasePersistenceContextProxyImpl 
.<init>(BasePersistenceContextProxyImpl.java:40) at 
weblogic.persistence.TransactionalEntityManagerProxyImpl 
.<init>(TransactionalEntityManagerProxyImpl.java:31) at 
weblogic.persistence.EntityManagerInvocationHandlerFactory. 
createTransactionalEntityManagerInvocationHandler 
(EntityManagerInvocationHandlerFactory.java:20) at 
weblogic.persistence.PersistenceManagerObjectFactory 
.createPersistenceContextProxy(PersistenceManagerObjectFactory.java:66) at 
weblogic.persistence.PersistenceManagerObjectFactory 
.getObjectInstance(PersistenceManagerObjectFactory.java:31) at 
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304) 
at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:251) at 
weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:406) at 
weblogic.j2eeclient.java.ClientReadOnlyContextWrapper.lookup 

이 가 여기에 예외

@Stateless 
public class QuoteSessionEJB implements QuoteSessionEJBLocal { 

/** 
* Default constructor. 
*/ 
public QuoteSessionEJB() { 
    // TODO Auto-generated constructor stub 
} 

@PersistenceContext(unitName="X") 
private EntityManager em; 
/** 
* Returns a list of Quote objects in the database 
* @return List<Customer> 
*/ 
public List<Quote> getQuote() { 
Query query = em.createNamedQuery("findQuotes"); 
return query.getResultList(); 
} 

} 

을 유발 SRC/메인/자바 아래에있는 persistence.xml 파일입니다있는 EJBBean입니다 -> META-INF 내장 이클립스있다.

<?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="X" transaction-type="JTA"> 
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
    <jta-data-source>localJTA</jta-data-source> 
    <exclude-unlisted-classes>false</exclude-unlisted-classes> 
    <properties> 
     <property name="eclipselink.target-server" value="WebLogic"/> 
     <property name="eclipselink.logging.level" value="FINEST"/>   
    </properties> 
</persistence-unit> 
</persistence> 

나는 아무 소용와 답변에 대한 웹 검색 시간을 보냈다. persistence.xml의 persistence unit X를 찾을 수없는 이유를 모르겠다. ...

나는이 같은 문제에 부딪혔거나 문제를 해결하기를 바라고있다. 도움을 주시면 대단히 감사하겠습니다!

업데이트 : 아래 better_use_mkstemp 당 의견은 WEB-INF가/클래스 SRC/메인/자바에서 내의 persistence.xml을 포함하는 META-INF 폴더를 이동했다. 이클립스에서 클래스 폴더를 만들어야합니다. 이것은 효과가있다! 매우 감사!

질문을 다음과 같습니다 내가 SRC/메인/자원의 META-INF 폴더를 퍼팅도 문제를 해결할 것을 발견 좀 더 연구를하는, 그러나 그것은하지 않았다. Maven의 M2E-WTP eclipse 플러그인에 문제가 있는지 알지 못합니다. 아니면 여기에서 뭔가 잘못 이해하고 있습니다. 아래는 폴더 구조의 스크린 샷입니다. 전쟁이 받는다는 명령이 생성 설치 파일을 검색하여

enter image description here

, 나는 META-INF 폴더가 올바르게 WEB-INF/classes 폴더에 배치되는 것을 볼 수 있습니다. 그러나 Eclipse 내에서 서버에 게시하는 것만으로는 작동하지 않습니다. 수동으로 WEB-INF 아래에 클래스 폴더를 만들고 수동으로 META-INF 폴더를 삭제/이동하지 않으면 IDE 내부에서 작동하지 않습니다. 또한 META-INF 폴더의 사본을 솔루션으로 두 곳에서 사용하는 것은 이치에 맞지 않습니다.

+2

당신이 당신의 귀/전쟁의 persistence.xml에서 확인 같은 소리가 난다-INF는 WEB에서/수업한다/META-INF? –

답변

0

은 당신의 persistence.xml에서 대체하려고 :

<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 version="1.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_1_0.xsd">