# jpa,  exception Predeployment of PersistenceUnit failed



## coleman_ (30. Dez 2015)

hallo leute

ich sehe langsam den wald vor lauter bäumen nicht.
ich besitze  mehrere jpaklassen die halt verlinkt sind.

ich zeige euch mal die zwei Klassen, bei dem die exception  auftaucht:


```
@Entity
public class Term
{
@Id
private Integer termId;
@OneToMany(mappedBy = "owner")
private List<Modul> moduls;
public Term()
{

}

public Term(Integer termId)
{
this.termId = termId;
moduls = new ArrayList<Modul>();

}
public Integer getTermId()

{
returntermId;

}
public List<Modul> getModuls()

{
returnmoduls;

}

public void setModul(Modul modul)
{
moduls.add(modul);
}






@Entity
publi cclass Modul
{
@Id
private Integer modulNr;
private String modulDescription;
// @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "termId")
private Term term;
@OneToMany(mappedBy = "owner")
private List<SchoolGrade> schoolGrades;
private Double schoolGradeAverage;



public Modul()
{
}


public Modul(Integer modulNr, String modulDescription)
{
this.modulNr = modulNr;
this.modulDescription = modulDescription;
schoolGrades = new ArrayList<SchoolGrade>();
}


public Integer getModulNr()
{
returnmodulNr;
}



public String getModulDescription()
{
returnmodulDescription;
}
public void setModulDescription(String modulDescription)
{
this.modulDescription = modulDescription;

}




public Term getTerm()
{
returnterm;
}

}
```

folgend die exception:


```
Exception in thread "main" Local Exception Stack:
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@c387f44
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [school] failed.
Internal Exception: Exception [EclipseLink-7154] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The attribute [moduls] in entity class [class entity.Term] has a mappedBy value of [owner] which does not exist in its owning entity class [class entity.Modul]. If the owning entity class is a @MappedSuperclass, this is invalid, and your attribute should reference the correct subclass.
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
```


----------



## stg (4. Jan 2016)

Der _Term_ in _Modul_ heißt _term_ und nicht _owner. _
Außerdem fehlt die @ManytoOne annotation, die du dort auskommentiert hast, aber der Fehler, den du gepostet hast, beschreibt das zuerst genannte Problem.

Deine Methode _setModul _solltst du außerdem umbennen, zum Beispiel in _addModul _Das ist ja schließlich keine setter-Methode.


----------

