I have a Spring project which works fine. I have now the requirement to split the project into two pieces - mainly due to use parts of the existing project in another one. While splitting up I'm facing a problem I do not understand and have no real clue what's the source of the issue. E.g.
+ -- myTestProject
| -- PersonEntity
| -- persistence.xml
| -- pom.xml
+ -- myBaseProject
|
| -- PhoneEntity
| -- pom.xml
When I keep the PhoneEntity in myTestProject I can launch Tomcat without problems. When I separate the entities like above I get from EclipseLink the error message:
The type [class com.smith.PhoneEntity] for the attribute [phoneEntity] on the entity class [class com.smith.Company] is not a valid type for a serialized mapping. The attribute type must implement the Serializable interface.
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="eclipselink" transaction-type="RESOURCE_LOCAL">
<description>Application managed persistence unit</description>
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<non-jta-data-source>java:comp/env/jdbc/ecoiDS</non-jta-data-source>
<class>com.smith.PersonEntity</class>
<class>com.smith.PhoneEntity</class>
<class>com.smith.Company</class>
<properties>
<property name="eclipselink.logging.level" value="WARNING" />
<property name="eclipselink.logging.timestamp" value="true" />
<property name="eclipselink.logging.session" value="false" />
<property name="eclipselink.logging.thread" value="false" />
<property name="eclipselink.logging.exceptions" value="true" />
<property name="eclipselink.weaving" value="static"/>
<property name=""/>
</properties>
</persistence-unit>
</persistence>
The persistence.xml has included the PhoneEntity as well. The whole project compiles well. But somehow I cannot launch the project. Any hints available how to solve the issue?
You are trying to Create a Multi Module Project;
I would recommend that: you create a third module in which you add all entities as well as the persistence.xml file, then you add a dependency of that module in your Base and Test modules.
You could find a practical example here -> Spring Boot Multimodule project example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With