/ / Object org.tts.maqraa.data.Daralquran@1e20120 nie jest znanym typem jednostki - wiosna, jsf, jsf-2, eclipselink, tomcat7

Obiekt org.tts.maqraa.data.Daralquran@1e20120 nie jest znanym typem jednostki - wiosna, jsf, jsf-2, eclipselink, tomcat7

Mam do czynienia z następującym problemem, gdy utrzymuję podmiot korzystający z podmiotu zarządzającego, który nabył w Spring.

java.lang.IllegalArgumentException: Object: org.tts.maqraa.data.Daralquran@183eae7 is not a known entity type.
javax.faces.FacesException: #{configurationChecker.check}: java.lang.IllegalArgumentException: Object: org.tts.maqraa.data.Daralquran@183eae7 is not a known entity type.
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: javax.faces.el.EvaluationException: java.lang.IllegalArgumentException: Object: org.tts.maqraa.data.Daralquran@183eae7 is not a known entity type.
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
... 23 more
Caused by: java.lang.IllegalArgumentException: Object: org.tts.maqraa.data.Daralquran@183eae7 is not a known entity type.
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.mergeCloneWithReferences(UnitOfWorkImpl.java:3484)
at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.mergeCloneWithReferences(RepeatableWriteUnitOfWork.java:378)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.mergeCloneWithReferences(UnitOfWorkImpl.java:3455)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.mergeInternal(EntityManagerImpl.java:486)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.merge(EntityManagerImpl.java:463)
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.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
at $Proxy8.merge(Unknown Source)
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.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
at $Proxy8.merge(Unknown Source)
at org.tts.maqraa.service.AbstractMaqraaService.store(AbstractMaqraaService.java:60)
at org.tts.maqraa.service.DarAlQuranService.createNewDarAlQuran(DarAlQuranService.java:47)
at org.tts.maqraa.service.test.ConfigurationChecker.check(ConfigurationChecker.java:63)
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.el.parser.AstValue.invoke(AstValue.java:264)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
... 24 more.

Gdzie używam następujących technologii

  • Apache Tomcat 7.
  • Eclipse Link 2.3.2.
  • Wiosna 3.0.
  • JSF 2.0 Mojarra.

Możesz również znaleźć jednostkę Daralquran, aby upewnić się, że obiekt jest poprawnie odwzorowany.

@Entity
public class Daralquran implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int id;

@Temporal( TemporalType.DATE)
@Column(name="Established_Date")
private Date establishedDate;

@Column(name="Full_Name")
private String fullName;

@Column(name="Mobile_Number")
private String mobileNumber;

private String note;

@Column(name="Phone_no")
private String phoneNo;

//bi-directional many-to-one association to City
@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name="city_Id")
private City city;

//bi-directional many-to-one association to Country
@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name="country_Id")
private Country country;

//bi-directional many-to-one association to User
@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name="supervisor_id")
private User user;

//bi-directional many-to-many association to User
@ManyToMany(mappedBy="daralqurans2", fetch=FetchType.EAGER)
private List<User> users;

public Daralquran() {
}

public int getId() {
return this.id;
}

public void setId(int id) {
this.id = id;
}

public Date getEstablishedDate() {
return this.establishedDate;
}

public void setEstablishedDate(Date establishedDate) {
this.establishedDate = establishedDate;
}

public String getFullName() {
return this.fullName;
}

public void setFullName(String fullName) {
this.fullName = fullName;
}

public String getMobileNumber() {
return this.mobileNumber;
}

public void setMobileNumber(String mobileNumber) {
this.mobileNumber = mobileNumber;
}

public String getNote() {
return this.note;
}

public void setNote(String note) {
this.note = note;
}

public String getPhoneNo() {
return this.phoneNo;
}

public void setPhoneNo(String phoneNo) {
this.phoneNo = phoneNo;
}

public City getCity() {
return this.city;
}

public void setCity(City city) {
this.city = city;
}

public Country getCountry() {
return this.country;
}

public void setCountry(Country country) {
this.country = country;
}

public User getUser() {
return this.user;
}

public void setUser(User user) {
this.user = user;
}

public List<User> getUsers() {
return this.users;
}

public void setUsers(List<User> users) {
this.users = users;
}
}

Można również znaleźć zawartość pliku persistence.xml

<?xml version="1.0" encoding="utf-8" ?>
<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"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="Maqraa">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.tts.maqraa.data.DarAlquranManager</class>
<class>org.tts.maqraa.data.DoorAlquranGM</class>
<class>org.tts.maqraa.data.QuranTeacher</class>
<class>org.tts.maqraa.data.ScientificOfficer</class>
<class>org.tts.maqraa.data.SystemAdmin</class>
<class>org.tts.maqraa.data.City</class>
<class>org.tts.maqraa.data.Country</class>
<class>org.tts.maqraa.data.Daralquran</class>
<class>org.tts.maqraa.data.HalaqaAchievement</class>
<class>org.tts.maqraa.data.HalaqaAssociation</class>
<class>org.tts.maqraa.data.Halaqa</class>
<class>org.tts.maqraa.data.MemorizationProgram</class>
<class>org.tts.maqraa.data.Permission</class>
<class>org.tts.maqraa.data.Phase</class>
<class>org.tts.maqraa.data.PhasesAttendance</class>
<class>org.tts.maqraa.data.Recitation</class>
<class>org.tts.maqraa.data.Role</class>
<class>org.tts.maqraa.data.Student</class>
<class>org.tts.maqraa.data.User</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/maqraa" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="root" />
<property name="eclipselink.ddl-generation" value="none" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
</properties>
</persistence-unit>
</persistence>

Możesz również znaleźć wiosenną konfigurację meta-danych maqraa-module-context.xml

<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:annotation-config />

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/maqraa" />
<property name="username" value="root" />
<property name="password" value="root" />
</bean>

<bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />

<bean id="jpaVendorAdapter"
class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
<property name="showSql" value="true" />
</bean>

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="Maqraa" />
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
<property name="jpaDialect" ref="jpaDialect" />
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver" />
</property>
</bean>

<bean id="darAlquranService" class="org.tts.maqraa.service.DarAlQuranService"></bean>

<bean id="configurationChecker" class="org.tts.maqraa.service.test.ConfigurationChecker"></bean>

</beans>

Czy ktoś może mi pomóc sprawić, że em działa poprawnie.

Dzięki Mohammed Amr.

Odpowiedzi:

1 dla odpowiedzi № 1

To jest problem z ładowaniem klas, w jakiś sposób załadowano dwie różne wersje tej samej klasy.

Upewnij się, że nie wdrożyłeś tej klasy w dwóch różnych miejscach i poprawnie skonfigurowałeś Spring. Być może wypróbuj niektóre przykłady z Wiosen.

Czy przenosisz się ponownie? Jeśli nie zamknąłeś starego EntityManagerFactory, możesz uzyskać ten błąd. Spróbuj ponownie uruchomić serwer.

Czy wszystkie klasy mają ten sam błąd lub wykonują jakąś pracę?


1 dla odpowiedzi nr 2

Rozumiem :),

Ponieważ używam tomcat 7 do uruchamiania aplikacji, i nie jest to contener EE, dlatego musi używać "LocalEntityManagerFactory" zamiast "LocalContainerEntityManagerFactory".

Dzięki temu będziesz mógł wywoływać metody zarządcy jednostki i podejmować transakcję pod rozwagę.

Zupełnie, jest to ostatni plik maqraa-module-context.xml

<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

<context:annotation-config />
<!-- <context:component-scan base-package="org.tts.maqraa.data" annotation-config="true"/> -->
<bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/maqraa" />
<property name="username" value="maqraa" />
<property name="password" value="maqraa" />
</bean>

<bean id="jpaDialect"
class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />

<bean id="jpaVendorAdapter"
class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
<property name="database" value="MYSQL" />
<property name="showSql" value="true" />
</bean>

<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="Maqraa" />
</bean>

<bean id="configurationChecker" class="org.tts.maqraa.service.test.ConfigurationChecker"></bean>

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory" />

<!-- Activates various annotations to be detected in bean classes for eg
@Autowired -->
<!-- <context:annotation-config/> -->
<!-- enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="transactionManager" />

</beans>

Dziękuje wszystkim, Mohammed Amr.


0 dla odpowiedzi № 3

Być może potrzebujesz specyficznie GenerationType, nie używaj GenerationType.Auto.Spróbuj tego. Nie jestem pewien.Ten sam przypadek jest tutaj