Weblogic + Hibernate Error: javax.persistence.JoinTable.indexes()[Ljavax/persistence/Index - java

I'm migrating a project that was running on Tomcat 8 to Weblogic.
I am using Hibernate + JPA 2. When I deploy in weblogic got the following error:
Failure occurred in the execution of deployment request with ID "26012160125422" for task "114". Error is: "weblogic.application.ModuleException: java.lang.NoSuchMethodError: javax.persistence.JoinTable.indexes()[Ljavax/persistence/Index;"
weblogic.application.ModuleException: java.lang.NoSuchMethodError: javax.persistence.JoinTable.indexes()[Ljavax/persistence/Index
Environment
- Java: jdk1.8.0_60
- Weblogic: 12.1.3
- hibernate-entitymanager: 4.3.1.Final
- hibernate-core: 4.3.1.Final
- javaee-api: 7.0
pom.xml
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.1.Final</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
</dependencies>

It is strange that you use javaee-api-7.0.jar, Hibernate 4 has hibernate-jpa-2.1-api-1.0.0.Final.jar as a dependency. But it is not a reason of the error.
JoinTable.indexes() was added with Java Persistence 2.1. So you just have an old jar with JoinTable annotation in the classpath (in the Weblogic default lib folders).
To check where is this jar, run this code before the Hibernate configuration code
URL joinTableUrl = Thread.currentThread().getContextClassLoader()
.getResource(
"javax/persistence/JoinTable.class");
System.out.println(joinTableUrl);
To check JoinTable has indexes() method
Class<?> joinTable = Thread.currentThread().getContextClassLoader()
.loadClass(JoinTable.class.getName());
System.out.println(Arrays.asList(joinTable.getDeclaredMethods()));

Related

Wildfly/JBOSS persistence error MSC000001: Failed to start service jboss.persistenceunit

We are migrating from Wildfly 8(for tests) and 9(for deployment) up to 21, Yay :). Unfortunately I am getting this error message when attempting to run the standalone.sh script:
ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 78) MSC000001: Failed to start service jboss.persistenceunit."projectName.war#ertDatasource": org.jboss.msc.service.StartException in service jboss.persistenceunit."projectName.war#ertDatasource": java.lang.NoClassDefFoundError: javax/persistence/TableGenerators
From what i have gathered online, this should exist in the hibernate persistence that we are using: hibernate-jpa-2.1-api-1.0.0.Final. Wondering what i may have missed?
Hibernate is set as a dependency in the pom.xml:
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>4.0.4.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.7.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>4.3.9.Final</version>
<scope>compile</scope>
</dependency>
And these dependencies worked fine while we were on wildfly 8 and 9. Wondering what i may have missed in the config?
If you look at wildfly pom.xml at https://github.com/wildfly/wildfly/blob/21.0.2.Final/pom.xml you see that:
version.org.hibernate is 5.3.20.Final
version.org.hibernate.commons.annotations is 5.0.5.Final
I suggest removing all hibernate dependencies and include only the API spec:
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
<scope>provided</scope>
</dependency>
The version of jpa used by wildfly 21.x is 2.2.3.

Issue with deployment on Wildfly 17.0.1.Final

I want to deploy an ear file that consists of submodules over wildfly 17.0.1.final.
The code gets deployed on wildfly 10.1.0.final properly but gives issue over wildfly 17.0.1.final.
I tried both with standalone.xml as well as standalone-full.xml.
While using standalone.xml for deployment,I get following error on deployment console:-
Service service jboss.ejb.default-resource-adapter-name-service not found
And when I use standalone-full.xml on deployment console,I get following error:-
{"WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"WFLYCTL0080: Failed services" => {"jboss.depl
oyment.subunit.\"MyEarFile.ear\".\"EAR-AllVersion1.0.war\".POST_MODULE" => "WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment \"EAR-AllVersion1.0.war
\" of deployment \"MyEarFile.ear\"
Caused by: java.lang.NoSuchMethodError: org.hibernate.validator.internal.util.logging.LoggerFactory.make()Lorg/hibernate/validator/internal/util/logging/Log;","jbo
ss.deployment.subunit.\"MyEarFile.ear\".\"EARmobile-AllVersion1.0.war\".POST_MODULE" => "WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment \"EARm
obile-AllVersion1.0.war\" of deployment \"MyEarFile.ear\"
Caused by: java.lang.NoSuchMethodError: org.hibernate.validator.internal.util.logging.LoggerFactory.make()Lorg/hibernate/validator/internal/util/logging/Log;"},"WF
LYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.comp.MyEarFile.\"EjbDbfinder-AllVersion1.0\".ChangeBasicDataBaseData","jboss.namin
g.context.java.comp.MyEarFile.\"EjbDbfinder-AllVersion1.0\".MessegeConsumer",........
..
..
..
..]"]}}}
I am not getting how to resolve it.I tried removing sl4j dependency from pom but still it didn't work.I am using eclipse ide for this and just installed jboss tool for wildfly as other jboss tools were not getting installed.
So please let me know how I need to upgrade this to deploy the code and make it running.Please let me know If I need to to specify any more details for this.
Following is the Hibernate Dependency I am using :-
In DB module:-
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId> hibernate-core</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>4.0.1.Final</version>
</dependency>
<!--In other Module:--->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.5.1-Final</version>
<scope>compile</scope>
</dependency>
Any help would be apreciable.
I got the solution.This is how I achieved the goal:-
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>5.4.2.Final</version>
<exclusions>
<exclusion>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.16.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.4.0.Final</version>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-weld</artifactId>
<version>17.0.1.Final</version>
</dependency>
Excluding jboss-logging from hibernate-ehcache,changing the wildfly dependencyand including hibernate-validation dependency resolved my problem.

Spring - Hibernate Integration

I am trying to integrate Spring 4 with Hibernate 4 and i am using eclipse ide with out maven dependencies,But i am getting below mentioned error:
Caused by: java.lang.classnotfoundexception : org.hibernate.annotations.Entity
if any one has implemented already and working fine, So please can you share the project for reference so that i can understand the flow of integration, As i am new to spring and hibernate.I need some good guidance.
you need to use some dependency, which you can find below :
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.5-Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.2.9.Final</version>
</dependency>
and if you are not using maven project then you need to download the hibernate-entitymanager and hibernate-annotations jar and add into build path and rebuild the project

Spring Web Services 2.2.5 in Jboss 5.1.0 GA

I'm having some problem while running a Spring WS quick start example in Jboss 5.1.GA.
When I'm trying to deploy a jar, with my web service, I get this error:
DEPLOYMENTS IN ERROR:
Deployment "vfszip:/.../.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_5.1_Runtime_Server/deploy/SpringWS.jar/" is in error due to the following reason(s): java.lang.IllegalStateException: Factory$org.jboss.aspects.remoting.InvokeRemoteInterceptor is already installed.
I'm using Maven2 and these dependencies:
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-ws</artifactId>
<version>1.3.0.RELEASE</version>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.1</version>
</dependency>
I think, there is a conflict of jars in JBossand spring-boot-starter-ws's dependencies.
Can jboss 5.1 deploy spring WS projects? Can any body help me?

Which maven dependency to choose for JPA 2.1 + 'Spring Data JPA' on Weblogic 12.1.x application server?

I am trying to deploy a JPA 2.1 (Hibernate) project on Weblogic 12.1.3 on Java 8 and getting this error. But works on Tomcat 8.
Caused By: java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:973)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:824)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3845)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3799)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1412)
Truncated. see log file for complete stacktrace
pom.xml
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.11.Final</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<!--
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.8.2.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
</exclusion>
</exclusions>
</dependency>
-->
Update:-
As answered below, JPA 2.1 is not enabled in Weblogic 12.1.3 by default. And can be enabled as explained here http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/wls/12c/01-06-004-JavaEE7andWebLogicServer/javaee7.html#section1
Weblogic is a java-ee application server and comes with the full java-ee stack (and includes so JPA).
Weblogic 12.1.3 comes with jpa 2.1 with eclipselink as provider see here
including hibernate as jpa implementation have so no sense here as the server already come with it's own implmentation (maven scope provided)
I suppose that this dependencies
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
is so sufficient (jpa 2.1 is part of java-ee 7 stack)
Could be that Weblogic is using its own library for JPA, which is older than yours. Could be that JPA 2.1 wasn't enabled during setup. You need to configure the server to enforce your libraries instead of those provided by WLS.
How to configure prefer application packages

Categories

Resources