Build fails with Groovy 1.8, Hibernate JPA annotations
I've been stuck using Groovy 1.7.0 and unable to upgrade to the numerous updates due to a JPA Annotation build error.
My code is pretty standard JPA Annotations and has worked fine with the past groovy versions. I would like to be able to upgrade to Groovy 1.8.0. If anyone has seen and solved this issue, I will appreciate your help!
It seems to be failing to compile on the #JoinTable parts of all of my #ManyToMany annotations.
It fails with a "annotation value must be an annotation" message. I have looked through the JPA javadocs and I don't appear to be missing any required fields. My annotations worked fine in past versions.
Also, I'm using Gant for my build and I wouldn't rule that out as being a possible problem??
Here is an example mapping:
#ManyToMany(mappedBy='topics')
#JoinTable(name="screencast_topic",
joinColumns=[#JoinColumn(name="topicId")],
inverseJoinColumns=[#JoinColumn(name="screenCastId")])
#Sort(type=SortType.NATURAL)
Compile output:
[groovyc] Compiling 412 source files to /Users/ben/workspace/nofluff/build/webapps/ROOT/WEB-INF/classes
[groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
[groovyc] Abnormal termination of javac.
[groovyc] /var/folders/rs/rsmW8feBHJyH6EPl+V3XME+++TI/-Tmp-/groovy-generated-1581380806855929206-java-source/nfjs/model/Topic.java:84: <b>annotation value must be an annotation</b>
[groovyc] #org.apache.struts2.json.annotations.JSON(serialize=false) #javax.persistence.ManyToMany(mappedBy="topics") #javax.persistence.JoinTable(inverseJoinColumns={"org.codehaus.groovy.ast.AnnotationNode#7997f538"}, name="screencast_topic", joinColumns={"org.codehaus.groovy.ast.AnnotationNode#67646de5"}) #org.hibernate.annotations.Sort(type=org.hibernate.annotations.SortType.NATURAL) public java.util.SortedSet<nfjs.model.screencast.Screencast> getScreencasts() { return (java.util.SortedSet<nfjs.model.screencast.Screencast>)null;}
the groovy devs are aware of this issue (http://jira.codehaus.org/browse/GROOVY-4768).
Looks like a fix is in place for the next release. The current workaround is to make your own Groovy build and test it out.
Related
I was using HiveMQ Client version 1.0.1 but I decided to update to the recently released version 1.1. I completely started from scratch and imported the project as a Gradle project and tried to build. The build work only after ignoring a few failed tests. I'm getting 3 errors in 3 different classes. I realize this is likely related to the Dagger dependency injection tool and I had already successfully built the project and added the directory of build/generated/source/apt/main/ to my build path as noted by my previous stack post where I had issues with a DaggerSingletonComponent not being found: How to fix DaggerSingletonComponent not resolved in HiveMQ (MQTT protocol) . This seems to be a new issue and I'm not sure what's wrong. I tried rebuilding by project but the errors still persist. I've left some screenshot below as well as the specific errors.
HiveMQ:
https://github.com/hivemq/hivemq-community-edition
https://github.com/hivemq/hivemq-mqtt-client
Errors:
The constructor MqttChannelInitializer(MqttClientConfig, MqttConnAckFlow, MqttEncoder, MqttConnectHandler, MqttDisconnectHandler, MqttAuthHandler, Lazy) is undefined
The constructor MqttSession(MqttClientConfig, MqttSubscriptionHandler, MqttIncomingQosHandler, MqttOutgoingQosHandler) is undefined
The method provideBootstrap(NettyEventLoopProvider, MqttChannelInitializer) in the type ConnectionModule is not applicable for the arguments (MqttClientConfig, NettyEventLoopProvider, MqttChannelInitializer)
Screenshots:
Executing ./gradlew clean build on the command line will fix your error.
But I also think that the real solution for your use case is to create a new empty project (gradle or maven) and add the client library as a dependency, like described here: https://hivemq.github.io/hivemq-mqtt-client/docs/installation.html
The issue turned out to be caused by an issue with the source folder in the directory build/generated/source/apt/main/ not having the option “Update exclusion filters in other source folders to solve nesting” selected. Selecting that option solved all of the errors.
I am trying to introduce Lombok into my project. Everything builds fine when I compile it locally but on Jenkins it reports this problem and then it fail on all the getters and setter which I replaced with #Data anotation. Jenkins uses Java 1.8. Any idea what might be wrong?
[INFO] Compiling 154 source files to /var/lib/jenkins/jobs/MERGE REQUEST build error_prone/workspace/com.betradar.betpal.server.app.api/target/classes
/var/lib/jenkins/jobs/MERGE REQUEST build error_prone/workspace/com.betradar.betpal.server.app.api/src/main/java/com/betradar/betpal/server/app/message/ObjectFactory.java:22: warning: lombok.javac.apt.LombokProcessor could not be initialized. Lombok will not run during this compilation: java.lang.IllegalArgumentException: com.google.errorprone.MaskedClassLoader$1$1 extends com.sun.tools.javac.file.JavacFileManager
public class ObjectFactory {
^
at lombok.javac.apt.LombokFileObjects.getCompiler(LombokFileObjects.java:148)
at lombok.javac.apt.InterceptingJavaFileManager.<init>(InterceptingJavaFileManager.java:40)
...
Errorprone uses the java9 compiler under the hood. There are two possible solutions:
Upgrade the Lombok dependency to 1.16.20
Downgrade the errorprone dependency
I recently migrated to Elasticsearch 2.4 in my Java code. I am using the following external libs in my gradle file:
'spring-data-mongodb': 'org.springframework.data:spring-data-mongodb:1.6.0.RELEASE',
'spring-data-rest': 'org.springframework.data:spring-data-rest-webmvc:2.2.0.RELEASE',
'spring-webmvc': 'org.springframework:spring-webmvc:4.0.7.RELEASE',
'elasticsearch-client': 'org.elasticsearch:elasticsearch:2.4.0',
'spring-context': 'org.springframework:spring-context:4.0.7.RELEASE',
'jackson': 'com.fasterxml.jackson.core:jackson-databind:2.8.1',
'commons-io': 'commons-io:commons-io:2.4',
'commons-codec': 'commons-codec:commons-codec:1.8',
'commons-httpclient': 'org.apache.httpcomponents:httpclient:4.3.6',
'commons-lang': 'org.apache.commons:commons-lang3:3.3.2',
'commons-collections': 'org.apache.commons:commons-collections4:4.0',
'commons-cli': 'commons-cli:commons-cli:1.3',
'commons-csv': 'org.apache.commons:commons-csv:1.1',
'joda-time': 'joda-time:joda-time:2.3',
'spring-reactor': 'org.projectreactor.spring:reactor-spring-context:1.1.3.RELEASE',
'json-smart': 'net.minidev:json-smart:1.3.1',
'mongeez': 'org.mongeez:mongeez:0.9.3',
'mongo-driver': 'org.mongodb:mongo-java-driver:2.12.3',
'akka-actor': 'com.typesafe.akka:akka-actor_2.10:2.3.13',
'scala-library': 'org.scala-lang:scala-library:2.10.4
I am using mockmvc to test my project. The error is occurring in MockMvc.java class and is the following:
Could not instantiate bean class:
[org.springframework.hateoas.hal.Jackson2HalModule$HalLinkListDeserializer]: Constructor threw exception
com.fasterxml.jackson.databind.deser.std.ContainerDeserializerBase: method (Ljava/lang/Class;)V not found
I think that this is is problem related to Jackson dependencies but I am not sure.
Yes, it does sound like an incompatibility between Jackson version that one of Spring modules was compiled against (and expected to use with), and 2.8.
It may be necessary to try a more recent version of Spring (MVC?).
Note that you also will want to use Jackson 2.8.3 instead of 2.8.1, due to various bug fixes, although it probably does not matter wrt this particular issue.
Thanks #StaxMan this issue was fixed by adding the following configuration in plugin-security.policy file location on C:\elasticsearch-2.4.1\modules\lang-groovy:
permission org.elasticsearch.script.ClassPermission "java.lang.*";
permission org.elasticsearch.script.ClassPermission "java.text.*";
I am trying to execute some Java with the Maven exec plugin, and am getting an error Caused by: org.hibernate.UnknownEntityTypeException: Unable to locate persister: my.biz.CoolEntity. I tried a number of failed solutions, before ultimately finding a hacky fix. Based on the hacky fix, I believe the issue to be a runtime classpath error.
I am looking for an answer that will tell me how to address the problem without resorting to copying the needed files into place, as I do in the hacky fix.
Background
I have a Maven project "Project A" which has dependencies upon Hibernate 5.0.1.Final as well as another project "Project B". Project B contains my JPA entity classes, including my.biz.CoolEntity.
Normally, I build everything into a shaded JAR and run/deploy that, without any issues.
Hibernate issue
Recently, I began using Maven's exec:java goal, but am running into what on the surface is a Hibernate issue. when I run mvn exec:java -DmainClass=my.biz.CoolEntity, I get this error:
Caused by: org.hibernate.UnknownEntityTypeException: Unable to locate persister: my.biz.CoolEntity
at org.hibernate.internal.SessionFactoryImpl.locateEntityPersister(SessionFactoryImpl.java:792) ~[hibernate-core-5.0.1.Fi
nal.jar:5.0.1.Final]
at org.hibernate.internal.SessionImpl.locateEntityPersister(SessionImpl.java:2641) ~[hibernate-core-5.0.1.Final.jar:5.0.1
.Final]
at org.hibernate.internal.SessionImpl.access$2500(SessionImpl.java:164) ~[hibernate-core-5.0.1.Final.jar:5.0.1.Final]
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.<init>(SessionImpl.java:2579) ~[hibernate-core-5.0.1.Final
.jar:5.0.1.Final]
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.<init>(SessionImpl.java:2566) ~[hibernate-core-5.0.1.Final
.jar:5.0.1.Final]
at org.hibernate.internal.SessionImpl.byId(SessionImpl.java:1044) ~[hibernate-core-5.0.1.Final.jar:5.0.1.Final]
at org.hibernate.internal.SessionImpl.get(SessionImpl.java:955) ~[hibernate-core-5.0.1.Final.jar:5.0.1.Final]
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:1075) ~[hibernate-entitymanager-5.
0.1.Final.jar:5.0.1.Final]
Failed attempts
I tried making use of the exec plugin's <additionalClasspathElements> and <includePluginDependencies>. The first solution didn't result in any different, and the second resulted in a compile-time error.
Hacky fix
What ended up working for me was copying the compiled classes from Project B into Project A.
Try changing the imports from "javax" to "jakarta". I had the same issue and mine worked when I made the change.
When the entities are residing in a different jar, you have to include it in persistence.xml. <jar-file>entities-packaged.jar</jar-file>. Different options are explained here
When we use Hibernate 5 jars, then we get
org.hibernate.UnknownEntityTypeException: Unable to locate persister".
I just changed the hibernate jar versions from 5 to 4 and then everything was fine.
Hibernate 5 does not locate the entity classes even after mapping.
I too got the same exception and it was due to missing the entity annotation #Entity for the class. Please check if the #Entity annotation is available in your class
When I create a new "Grails Project" in GGTS-3.3.0 with Grails 2.3, I get several errors in ForkedTomcatServer.groovy. These are the errors I get:
Groovy:[Static type checking] - No such property: version for class:
org.codehaus.groovy.grails.plugins.GrailsPluginInfo ForkedTomcatServer.groovy /testapp/.link_to_grails_plugins/tomcat-7.0.42/src/groovy/org/grails/plugins/tomcat/fork line
165
Groovy:[Static type checking] - No such property: descriptor for
class:
org.codehaus.groovy.grails.plugins.GrailsPluginInfo ForkedTomcatServer.groovy /testapp/.link_to_grails_plugins/tomcat-7.0.42/src/groovy/org/grails/plugins/tomcat/fork line
166
These are the lines of code referenced in the errors:
GrailsPluginInfo info = GrailsPluginUtils.getPluginBuildSettings().getPluginInfoForName('tomcat')
String jarName = "grails-plugin-tomcat-${info.version}.jar"
File jar = info.descriptor.file.parentFile.listFiles().find { File f -> f.name.equals(jarName) }
I have not made any changes whatsoever. I just clicked File -> New -> Grails Project and the output has these errors. I have made several different projects and they all generate the same way.
Why is this happening and how can I fix it?
To fix this issue you should install Groovy 2.1. In GGTS the Groovy 2.1 is available from the dashboard. This solved my the problem.
From 2.3.0 Latest News updated yesterday
We are aware that the IDEs will require some updates to work with
Grails 2.3.0. If you plan to use 2.3.0 soon, please use the Intellij
IDEA EAPs and latest GGTS milestone releases which include updates to
work with Grails 2.3.0
I have the same issue to use Grails 2.3.0 with GGTS 3.3.0. After I installed the Groovy 2.1 from dashboard, this problem is gone. The same issue of the compiler version mismatch is also gone after install the latest Groovy
Workaround. Open ForkedTomcatServer.groovy, comment out the #CompileStatic, save file. The error will disappear. Now you can go ahead and un-comment that line and the error is gone. Groovy magic!
I also had this issue. Installtion of the Groovy 2.1 compiler sorted that out.
One of my errors said my workspace did not match the project and I could right-click and Eclipse fixed that part. Real issue was that I needed to update my compiler to 2.1.