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?
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
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
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.
Related
I installed the latest IntelliJ idea, latest maven 3.6.3, Java 1.8, set the JAVA_HOME / JRE_HOME env variables. Then generated a Gatling project using mvn archetype:generate -Dfilter=gatling. In summary, I followed the instruction here. I have installed the Scala plugin for IntelliJ idea as well. When I try to run the Gatling engine by right-clicking on the Engine class,
I am getting below error. can someone tell me what's going on here? I tried all the suggestions online, but no luck so far. Thanks
"C:\Program Files (x86)\Java\jdk1.8.0_221\bin\java.exe".....
Error: Could not find or load main class Engine
Process finished with exit code 1
Here is my POM file
<?xml version="1.0" encoding="UTF-8"?>
<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.mycompany.gatling</groupId>
<artifactId>pert-tests</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<encoding>UTF-8</encoding>
<gatling.version>3.2.1</gatling.version>
<gatling-maven-plugin.version>3.0.3</gatling-maven-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>io.gatling.highcharts</groupId>
<artifactId>gatling-charts-highcharts</artifactId>
<version>${gatling.version}</version>
</dependency>
<dependency>
<groupId>io.gatling</groupId>
<artifactId>gatling-app</artifactId>
<version>${gatling.version}</version>
</dependency>
<dependency>
<groupId>io.gatling</groupId>
<artifactId>gatling-recorder</artifactId>
<version>${gatling.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>${gatling-maven-plugin.version}</version>
</plugin>
</plugins>
</build>
</project>
David MontaƱo... after manually marking src/test/scala as Test Sources Root, I got "Error:(11, 18) illegal cyclic inheritance" as mentioned by Rasika
I just found that scala 2.13.1 is not compatible with gatling. I removed scala 2.13.1 from global libraries list and added scala 2.12.10. Tests working fine now. Here are the steps
Right click project folder in IntelliJ and choose 'Open Module Settings'
Under 'Platform Settings' select 'Global Libraries'
Here, remove scala-sdk-2.13.1 and add scala-sdk-2.12.10
Rebuild the module
It worked for me when I manually marked the src/test/scala as Test Sources Root and rebuild the project.
Mark as Test Sources Root
It should be picked up automatically by IntelliJ but it wasn't the case.
Tied both :
marked the src/test/scala as Test Sources Root and rebuild the project.
Mark as Test Sources Root
And
Under 'Platform Settings' select 'Global Libraries'
Here, remove scala-sdk-2.13.1 and add scala-sdk-2.12.10
then works.
Can anyone tell me how I can get a profile to be picked up when running a web project from inside eclipse. This is my latest attempt, which does not work (file-dev.xml not parsed). I have a war project which has a dependency on a jar project. Th jar project contains the spring beans.
in pom.xml of jar project:
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<env>dev</env>
</properties>
</profile>
<profile>
<id>uat</id>
<properties>
<env>uat</env>
</properties>
</profile>
</profiles>
Also in the pom, I have added this to the maven-jar-plugin
<configuration>
<argLine>-Dspring.profiles.active=dev</argLine>
</configuration>
in spring config xml file:
<import resource="file.xml" />
in file.xml
<import resource="file-dev.xml" />
in file-dev.xml
<beans profile="dev">
<bean id="myBean"> etc etc </myBean>
</beans>
running mvn help:active-profiles returns " - dev"
Any idea what I cma missing? I have not tried any maven build or install yet, I just want it working in the dev environment, so we can deploy to tomcat from within eclipse first.
Thanks in advance
I got following local setting:
Eclipse Kepler
Maven 3
Glassfish 4
I want to run JSF with MySql.JSF 2.0 works fine on the server.The problem I got is the connection to the database.
I did all settings at the admin of glassfish and here is the persistence.xml I got so far:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/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_1_0.xsd">
<persistence-unit name="actors" transaction-type="JTA">
<jta-data-source>jdbc/example</jta-data-source>
<properties>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
</properties>
Maven dependency for MySQL:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
Get a jdbc not found exception...
The question is how can I setup Glassfish to use the maven dependency so that I don't need to integrate the jdbc.jar manually ?
I am afraid according to the official documentation you have to do it this way
Eclipse version: Indigo
Target Application server: Weblogic 10.3.5 (11gR1)
I am having trouble building and deploying a multi-module POM project (packaged as an EAR) to my WebLogic server, within Eclipse.
Despite the parent POM building an EAR file successfully outside of the IDE, I am receiving the following error when trying to deploy the UI WAR to the Application Server:
java.lang.Exception: Exception received from deployment driver. See Error Log view for more detail.
at oracle.eclipse.tools.weblogic.server.internal.DeploymentProgressListener.watch(DeploymentProgressListener.java:190)
at oracle.eclipse.tools.weblogic.server.internal.WlsJ2EEDeploymentHelper.deploy(WlsJ2EEDeploymentHelper.java:486)
at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishWeblogicModules(WeblogicServerBehaviour.java:1466)
at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishToServer(WeblogicServerBehaviour.java:898)
at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishOnce(WeblogicServerBehaviour.java:686)
at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publish(WeblogicServerBehaviour.java:539)
at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:774)
at org.eclipse.wst.server.core.internal.Server.publishImpl(Server.java:3027)
at org.eclipse.wst.server.core.internal.Server$PublishJob.run(Server.java:341)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: weblogic.application.ModuleException: Failed to load webapp: 'lerp-ui'
at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:393)
at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:176)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:517)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:159)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:45)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:613)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:184)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:58)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:154)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:98)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Caused by: java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:297)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:270)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:64)
at java.lang.ClassLoader.loadClass(ClassLoader.java:305)
at java.lang.ClassLoader.loadClass(ClassLoader.java:246)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:179)
at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:43)
at weblogic.servlet.internal.WebAnnotationProcessorImpl.processServlets(WebAnnotationProcessorImpl.java:225)
at weblogic.servlet.internal.WebAnnotationProcessorImpl.processJ2eeAnnotations(WebAnnotationProcessorImpl.java:209)
at weblogic.servlet.internal.WebAnnotationProcessorImpl.processAnnotations(WebAnnotationProcessorImpl.java:105)
at weblogic.servlet.internal.WebAppServletContext.processAnnotations(WebAppServletContext.java:1368)
at weblogic.servlet.internal.WebAppServletContext.<init>(WebAppServletContext.java:449)
at weblogic.servlet.internal.WebAppServletContext.<init>(WebAppServletContext.java:493)
at weblogic.servlet.internal.HttpServer.loadWebApp(HttpServer.java:418)
at weblogic.servlet.internal.WebAppModule.registerWebApp(WebAppModule.java:972)
at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:382)
This is despite having the jsf-api dependency in both the Maven POM and referenced in the .classpath file for the UI WAR project:
Snippet of the POM for the UI WAR project:
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.3</version>
</dependency>
.classpath for UI WAR Project:
<classpathentry kind="var" path="M2_REPO/javax/faces/jsf-api/2.0.3/jsf-api-2.0.3.jar"/>
<classpathentry kind="var" path="M2_REPO/com/sun/faces/jsf-impl/2.0.3/jsf-impl-2.0.3.jar"/>
Below follows the entire parent POM of the multi-module project:
<?xml version="1.0" encoding="UTF-8"?>
<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>uk.co.acme</groupId>
<artifactId>multiModulePOMProject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>acme troublesome project</name>
<modules>
<module>../../Business/common</module>
<module>../../Business/svccom</module>
<module>../../Business/busctl</module>
<module>../../Client/ui</module>
<module>../../Business/ear</module>
<module>../../Business/talend/java/businessrules</module>
</modules>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<project.ui.version>1.0-SNAPSHOT</project.ui.version>
<project.common.version>1.0-SNAPSHOT</project.common.version>
<project.svccom.version>1.0-SNAPSHOT</project.svccom.version>
<project.busctl.version>1.0-SNAPSHOT</project.busctl.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<webapp.filter>development</webapp.filter>
<spring.version>3.0.5.RELEASE</spring.version>
<eclipselink.version>2.1.3</eclipselink.version>
<persistence.version>2.0.0</persistence.version>
<spring.cdi.version>1.0.0</spring.cdi.version>
<weblogic.adminurl>t3://localhost:7050</weblogic.adminurl>
<weblogic.user>weblogic</weblogic.user>
<weblogic.password>welcome1</weblogic.password>
<weblogic.target>acmeLocalDomain</weblogic.target>
<weblogic.source>../../Business/ear/target/${parent.artifactId}.${packaging}</weblogic.source>
</properties>
<profiles>
<profile>
<id>production</id>
<properties>
<webapp.filter>production</webapp.filter>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.2</version>
</plugin>
</plugins>
</build>
</project>
It's clear that this is some classpathing issue, but I have gone scrollbind from staring at it over the course of two days and have decided that the time has come to wave the white flag and appeal for help!
The end goal is to take my EAR project (which currently is hampered from an annoying need to undeploy/redeploy on the command line for every little change) and get it so that I can perform hot fixes within a deployment which is run inside the IDE.
Thanks
Update:
By adding the offending dependency to the domains\<domain>\lib folder of the application server, and restarting the application server, I have now started getting ClassNotFoundExceptions for other WAR dependencies. It is clear now that Eclipse is not respecting the classpath of the WAR project - and I still don't understand why or how :-(
To package dependencies into your lib directory, add this to your EAR packaging pom:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.5</version>
<configuration>
<version>6</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
[Your EJB and Web modules here]
</modules>
</configuration>
</plugin>
</plugins>
</build>
Notice the defaultLibBundleDir tag.
After building the EAR using File > Export in Eclipse, I was able to compare the EAR to the one produced by my Maven POM.
I found that Eclipse did not contain references to the Maven Dependencies build path items in the Deployment Assembly (I discovered that simply adding the Projects as dependencies wasn't enough).
Reading around the subject, I found that it was neccessary to add the Maven Dependencies of the child WAR and JARs to their respective WAR and JAR projects, but with a destination of
../lib
This is declared on each WAR and JAR refers to the lib folder of the parent EAR.
Using a combination of this menu (and alternatively by editing each of the corresponding .settings/org.eclipse.wst.common.component files for each affected WAR and JAR in turn) I was able to build up a version of the EAR which matched the one produced via my Maven script.
I hope this helps someone.
I have the following in persistence.xml
<persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
<class>com.merc.model.log.EventLogging</class>
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<properties>
<!-- Scan for annotated classes and Hibernate mapping XML files -->
<property name="hibernate.archive.autodetection" value="class"/>
</properties>
</persistence-unit>
If I comment out com.merc.model.log.EventLogging, I get Unknown entity exception.
Any ideas as to why autodetection would not work
This can be caused by the fact that by default autodetection works for classes inside the same classpath item where persistence.xml is located.
So, you have separate target folders for the code itself and for the tests (for example, if you use Maven with default configuration), and if this persistence.xml ends up in tests' target folder after compilation, classes from the main target folder wouldn't be detected.
You can use <jar-file> elements to point to other classpath items that should be searched for entities.
If you use Maven, you can do it in elegant way using resource filtering:
persistence.xml:
<jar-file>${project.build.outputDirectory}</jar-file>
pom.xml:
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
</build>