0

I'm working on a Java Web-App which was working perfectly fine and I wanted to try to deploy it on Heroku (which I've never done before). I read into it, and followed the steps on Atlassian for creating a Pipeline (shich I've also never done before), as I'm using Bitbucket as version-control system. Whilst reading I thought I would need Maven to make it work, so I copied the project files into a newly created Maven Project and it was working fine as far as I remember. As I said I'm completely new to the subject so I tried a few things, but I always had problems with different Java versions and errors executing the pipeline. The real problem is that when I tried to run it locally again it suddenly threw an Exception that my PU couldn't predeploy, everytime I tried to connect to the database and now I'm stuck here since nearly a week and I don't have any more ideas how to solve it.

Exception Description: Predeployment of PersistenceUnit [TestPU] failed. Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException Exception Description: [class pojo.Track] uses a non-entity [class pojo.Playlist] as target entity in the relationship attribute [field playlist]. at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:107) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54) at database.DB_Access.connect(DB_Access.java:29) at servlets.SpotifyController.doPost(SpotifyController.java:136) at javax.servlet.http.HttpServlet.service(HttpServlet.java:660) at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.base/java.lang.Thread.run(Thread.java:835) 

I saved the version without maven and reverted back to it so I could try if it still works and it does without any exceptions. The funny part is that the files pojo.Track & pojo.Playlist (which apparently cause the error) are exactly the same in the two projects.

/* ************************************ * Document : Playlist.java * ************************************/ package pojo; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.UUID; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; /** * * @author michi */ @Entity @NamedQueries({ @NamedQuery(name = "Playlist.getById", query = "SELECT p FROM Playlist p WHERE UPPER(p.id) = UPPER(:id)") }) public class Playlist implements Serializable { @Id @Column(name = "playlist_id") private String id; // private String name; // private String imageURL; private String link; private String spotifyID; private String refreshToken; @OneToMany(mappedBy = "playlist", cascade = CascadeType.PERSIST) private List<Track> tracks = new ArrayList(); @ManyToMany(cascade = CascadeType.MERGE) @JoinTable(name = "playlist_user", joinColumns = {@JoinColumn(name = "playlist_id")}, inverseJoinColumns = {@JoinColumn(name = "user_id")}) private List<SpotifyUser> users = new ArrayList(); public Playlist() { id = UUID.randomUUID().toString(); } public Playlist(String id, String refreshToken) { this.id = id; this.refreshToken = refreshToken; } public Playlist(String id, String refreshToken, List<Track> tracks) { this.id = id; this.refreshToken = refreshToken; this.tracks = tracks; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getLink() { return link; } public void setLink(String link) { this.link = link; } public String getSpotifyID() { return spotifyID; } public void setSpotifyID(String spotifyID) { this.spotifyID = spotifyID; } public String getRefreshToken() { return refreshToken; } public void setRefreshToken(String refreshToken) { this.refreshToken = refreshToken; } public List<Track> getTracks() { return tracks; } public void setTracks(List<Track> tracks) { this.tracks = tracks; } public void addTrack(Track track) { if(!tracks.contains(track)) tracks.add(track); } public List<SpotifyUser> getUsers() { return users; } public void setUsers(List<SpotifyUser> users) { this.users = users; } public void addUser(SpotifyUser user) { if(!users.contains(user)) users.add(user); } @Override public String toString() { return "Playlist\n" + "id=" + id + "\nrefreshToken=" + refreshToken + '\n' + tracks; } } 
<!--************************************ * Document : persistence.xml * ************************************--> <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.1" 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"> <persistence-unit name="TestPU" transaction-type="RESOURCE_LOCAL"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <class>pojo.Track</class> <class>pojo.Playlist</class> <class>pojo.SpotifyUser</class> <exclude-unlisted-classes>false</exclude-unlisted-classes> <properties> <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/testdb"/> <property name="javax.persistence.jdbc.user" value="postgres"/> <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/> <property name="javax.persistence.jdbc.password" value="***"/> <property name="javax.persistence.schema-generation.database.action" value="create"/> </properties> </persistence-unit> </persistence> 
<!--************************************ * Document : pom.xml * ************************************--> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.michaelulz</groupId> <artifactId>SpotifyAPI_Test</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <name>SpotifyAPI_Test</name> <properties> <maven.compiler.release>12</maven.compiler.release> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>org.eclipse.persistence.core</artifactId> <version>2.5.2</version> </dependency> <dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>org.eclipse.persistence.asm</artifactId> <version>2.5.2</version> </dependency> <dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>org.eclipse.persistence.antlr</artifactId> <version>2.5.2</version> </dependency> <dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>org.eclipse.persistence.jpa</artifactId> <version>2.5.2</version> </dependency> <dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>org.eclipse.persistence.jpa.jpql</artifactId> <version>2.5.2</version> </dependency> <dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>javax.persistence</artifactId> <version>2.1.0</version> </dependency> <dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId> <version>2.5.2</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>7.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>42.2.5</version> </dependency> <dependency> <groupId>javax.annotation</groupId> <artifactId>javax.annotation-api</artifactId> <version>1.3.2</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.10.3</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.10.3</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.10.3</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <configuration> <fork>true</fork> <executable>${JAVA_12_HOME}/bin/javac</executable> <source>12</source> <target>12</target> </configuration> <dependencies> <dependency> <groupId>org.ow2.asm</groupId> <artifactId>asm</artifactId> <version>6.2</version> </dependency> </dependencies> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.3</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.6</version> <executions> <execution> <phase>validate</phase> <goals> <goal>copy</goal> </goals> <configuration> <outputDirectory>${endorsed.dir}</outputDirectory> <silent>true</silent> <artifactItems> <artifactItem> <groupId>javax</groupId> <artifactId>javaee-endorsed-api</artifactId> <version>7.0</version> <type>jar</type> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> </plugins> </build> </project> 

I've already tried everything i found on Stackoverflow, messed around with different java versions, added all kinds of stuff to my pom.xml and tweaked several settings but I'm still tapping in the dark what even causes the error.

I'm using Java 12 and Maven 3.3.9 on NetBeans 11.1, EclipseLink 2.5.2, Tomcat 9.0.2 and Postgresql 42.2.5

Edit: I found out that the Java version is the problem for some reason. I don't know why it doesn't compile correctly with Java 12 but I heard that Web-Apps sometimes have issues with newer verions than 1.8. I need 1.11 or later for my project though as I'm using java.net.http. Does someone know a reason for why JDK 12 wouldn't work?

2
  • Not an expert, but the error suggests you might have more than one pojo.Playlist.class file on your class path that is being built from maven, or possibly an older pojo.Playlist getting picked up that doesn't have the Entity annotation on it. Taking a look at what is getting deployed might give more information, as would turning up the log levels (EclipseLInk can log each class it processes and where it comes from if the log level is at all) Commented Sep 8, 2020 at 14:55
  • @Chris thank you, turning up the log levels was definitely helpful (found a few other minor mistakes) although what eventually did the trick was turning back the Java version to 1.8. I don't know why yet but Java 12 seems to make problems Commented Sep 10, 2020 at 6:23

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.