'Recreation of entity classes
I try to run a web application with hibernate, spring and jpa on netbeans 8.0.1, but now I'm stuck on this exception when compiling app...Here's the error below:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default- compile) on project SMSXxxxx: Compilation failure: Compilation failure:
error: Problem with Filer: Attempt to recreate a file for type com.equitel.smsmanager.entities.TextMessageContent_
error: Problem with Filer: Attempt to recreate a file for type com.smsmanager.entities.SmsUser_
Here is the persistence unit, I have only one in my project
<?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="SMSManagerPU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/jboss/datasources/SMSManagerDS</jta-data-source>
<class>com.smsmanager.entities.Approval</class>
<class>com.smsmanager.entities.Changelog</class>
<class>com.smsmanager.entities.Contacts</class>
<class>com.smsmanager.entities.Dispatches</class>
<class>com.smsmanager.entities.MessageSchedule</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>
</persistence-unit>
</persistence>
I have not managed to fix this error , could you help me fix this?
Solution 1:[1]
For some reasons, there is a dependency in pom.xml that in my case caused the problem. Look for it and delete it:
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>hibernate-jpamodelgen-4.3.1.Final</artifactId>
<version>SNAPSHOT</version>
<scope>provided</scope>
</dependency>
This could be a bug in Netbeans. https://netbeans.org/bugzilla/show_bug.cgi?id=183779
Solution 2:[2]
Check your pom.xml file maven-compiler-plugin is added or not. If it is not there add plugin as shown in below.
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
You can find root cause by using mvn clean install -X in cmd prompt.
Check in your pom.xml file the version of java mentioned there and check which version of java is mentioned in the $JAVA_HOME
environment variable . Both should be the same.
Check this also
- May be its Java Compiler issue.
- May be issue with downloading the jar
Solution 3:[3]
The solution that worked for me: Try to remove the :
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>hibernate-jpamodelgen-4.3.1.Final</artifactId>
<version>SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Then add a maven profile with activation and dependency
<profiles> <profile> <id>profile-JPA-Gen</id> <activation> <property> <name>activate_gen</name> <value>true</value> </property> </activation> <dependency> <groupId>unknown.binary</groupId> <artifactId>hibernate-jpamodelgen</artifactId> <version>SNAPSHOT</version> </dependency> </profile> </profiles>
Run once mvn install -P profile-JPA-Gen only to generate the relevant classes, and then use mvn clean install.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ACV |
| Solution 2 | |
| Solution 3 | Paz |
