Glassfish 5.1 missing modules from previous versions - java

We have an application running on Glassfish 5.0.1 and before that 4.1.1 versions. Recently server is updated to Glassfish 5.1.0 and our application can not be compiled due to the missing of javax.inject.Inject. This relevant jar was in the previous Glassfish versions (in the module folder).
So I'd like to hear that in glassfish 5.1 should we add this jar as an external library or is there a way to make this work in the latest glassfish ?

For GlassFish 5.1 the maven coordinates of dependencies are now jakarta.* instead of javax.*. So for the javax.inject.Inject annotation use the maven dependency
<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
<version>1.0.3</version>
</dependency>

Related

I want to use sqlserver dependency in maven project(jar) for jre6 which version I should use

I am using jdk1.6 for maven project and I want to use sqlserver dependency in pom.xml file,which version of sqlserver I should write in pom file tag of maven project. I can not change my jdk version as client is having the same environment.
As maven has officially stopped the support of jdk1.6 I requested client to upgrade their environment, and executed on jdk1.8. It worked on 1.8 version.

Jython 2.7.0 with jersey

I was using Jython standalone version 2.5.3 in my REST application. It was working fine. When I upgraded to Jython 2.7.0, I am getting the following exception,
javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: javax.xml.transform.TransformerFactoryConfigurationError: Provider org.python.apache.xalan.processor.TransformerFactoryImpl not found
Java xml classes were packaged and distributed with version 2.7.0. But if I understand it correctly Java SE comes with these classes. This issue is raised as a bug here. In order to avoid this exception add the xalan processor dependency in your pom.xml
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.1</version>
</dependency>
Another solution would be to upgrade to the latest version of the jython-standalone jar. This issue is fixed in the latest release 2.7.1

JSP support in Jetty 9.3

I'm trying to upgrade embedded Jetty to the latest version (9.3.2.v20150730 as of now) from an older release (9.3.0.M1).
I'm using JSP and current maven dependency is as follows:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp</artifactId>
<version>9.3.0.M1</version>
</dependency>
However I can't find a new version for this dependency in maven central.
Looks like they have not released new jetty-jsp artifacts after 9.3.0.M1 for Jetty 9.3. New versions for all other jetty-related artifacts are available.
What is the alternative I should use for JSP support with latest Jetty version?
I got the answer from jett-users mailing list. Updated dependency is:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jsp</artifactId>
<version>${jetty.version}</version>
</dependency>
Also, from jetty-announce list:
The 9.2 release has switched to using the Apache version of Jasper for
JSP and JSTL. Early releases of Jetty used these implementations,
but switched to Glassfish when it became the reference implementation.
However the Apache version is now more rigorously maintained and hence
we have switched back. Currently we are using a slightly modified
version of 8.0.3, however our modifications have been contributed
back to apache and have been accepted for their 8.0.9 release, so we
will soon switch to using a standard jar from Apache.
Apparently they have switched back to standard jar from Apache.

Issue with using Hibernate in Jersey service [duplicate]

I have a Play Framework application and I was using Hibernate 4.2.5.Final (which is retrieved via the Maven dependency manager). I decided to upgrade to Hibernate 4.3.0.Final, recompile my application successfully, and ran it.
I got the exception below, and haven't been able to figure out why. I downgraded back to 4.2.5 and this issue did not occur. I then, tried upgrading Hibernate with each Final release after 4.2.5. That is, I went from 4.2.5.Final to 4.2.6.Final, to 4.2.7.Final, to 4.2.8.Final and then to 4.3.Final. The issue does not occur until I upgrade to 4.3.0.Final.
Java version information
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
And exception:
play.api.UnexpectedException: Unexpected exception[NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:152) ~[play_2.10.jar:2.2.1]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:112) ~[play_2.10.jar:2.2.1]
at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:112) ~[play_2.10.jar:2.2.1]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:110) ~[play_2.10.jar:2.2.1]
at scala.util.Success.flatMap(Try.scala:200) ~[scala-library.jar:na]
Caused by: java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:936) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:781) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3762) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3716) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1410) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
I've ran into the same problem. The question here is that play-java-jpa artifact (javaJpa key in the build.sbt file) depends on a different version of the spec (version 2.0 -> "org.hibernate.javax.persistence" % "hibernate-jpa-2.0-api" % "1.0.1.Final").
When you added hibernate-entitymanager 4.3 this brought the newer spec (2.1) and a different factory provider for the entitymanager. Basically you ended up having both jars in the classpath as transitive dependencies.
Edit your build.sbt file like this and it will temporarily fix you problem until play releases a new version of the jpa plugin for the newer api dependency.
libraryDependencies ++= Seq(
javaJdbc,
javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"),
"org.hibernate" % "hibernate-entitymanager" % "4.3.0.Final"
)
This is for play 2.2.x. In previous versions there were some differences in the build files.
Hibernate 4.3 is the first version to implement the JPA 2.1 spec (part of Java EE 7). And it's thus expecting the JPA 2.1 library in the classpath, not the JPA 2.0 library. That's why you get this exception: Table.indexes() is a new attribute of Table, introduced in JPA 2.1
I update my Hibernate JPA to 2.1 and It works.
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
You probablly have 2 different versions of hibernate-jpa-api on the classpath. To check that run:
mvn dependency:tree >dep.txt
Then search if there are hibernate-jpa-2.0-api and hibernate-jpa-2.1-api. And exclude the excess one.
I could solve the issue simply by replacing the JPA api jar file which is located jboss7/modules/javax/persistence/api/main with 'hibernate-jpa-2.1-api'. also with updating module.xml in the directory.
Error:
java.lang.NoSuchMethodError: javax.persistence.JoinTable.indexes()[Ljavax/persistence/Index;
The only thing that solved my problem was removing the following dependency in pom.xml:
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
And replace it for:
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
Hope it helps someone.
i have experienced same issue in my spring boot application. after removing manually javax.persistance.jar file from lib folder. issue was fixed. in pom.xml file i have remained following dependency only
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
I had the same issue, I fixed it by using org.hibernate.annotations.Table annotation instead of javax.persistence.Table in the Entity class.
import javax.persistence.Entity;
import org.hibernate.annotations.Table;
#Entity
#Table(appliesTo = "my_table")
public class MyTable{
//and rest of the code
There are multiple JPA providers in your classpath. Or atleast in your Application server lib folder.
If you are using Maven
Check for dependencies using command mentioned here https://stackoverflow.com/a/47474708/3333878
Then fix by removing/excluding unwanted dependency.
If you just have one dependecy in your classpath, then the application server's class loader might be the issue.
As JavaEE application servers like Websphere, Wildfly, Tomee etc., have their own implementations of JPA and other EE Standards, The Class loader might load it's own implementation instead of picking from your classpath in WAR/EAR file.
To avoid this, you can try below steps.
Removing the offending jar in Application Servers library path. Proceed with Caution, as it might break other hosted applications.
In Tomee 1.7.5 Plume/ Web it will have bundled eclipselink-2.4.2 in the lib folder using JPA 2.0, but I had to use JPA 2.1 from org.hibernate:hibernate-core:5.1.17, so removed the eclipselink jar and added all related/ transitive dependencies from hibernate core.
Add a shared library. and manually add jars to the app server's path. Websphere has this option.
In Websphere, execution of class loader can be changed. so making it the application server's classpath to load last i.e, parent last and having your path load first. Can solve this.
Check if your appserver has above features, before proceeding with first point.
Ibm websphere References :
https://www.ibm.com/support/knowledgecenter/SSEQTP_9.0.5/com.ibm.websphere.base.doc/ae/trun_classload_server.html
https://www.ibm.com/support/pages/how-create-shared-library-and-associate-it-application-server-or-enterprise-application-websphere-application-server

NoSuchMethodError in javax.persistence.Table.indexes()[Ljavax/persistence/Index

I have a Play Framework application and I was using Hibernate 4.2.5.Final (which is retrieved via the Maven dependency manager). I decided to upgrade to Hibernate 4.3.0.Final, recompile my application successfully, and ran it.
I got the exception below, and haven't been able to figure out why. I downgraded back to 4.2.5 and this issue did not occur. I then, tried upgrading Hibernate with each Final release after 4.2.5. That is, I went from 4.2.5.Final to 4.2.6.Final, to 4.2.7.Final, to 4.2.8.Final and then to 4.3.Final. The issue does not occur until I upgrade to 4.3.0.Final.
Java version information
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
And exception:
play.api.UnexpectedException: Unexpected exception[NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:152) ~[play_2.10.jar:2.2.1]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:112) ~[play_2.10.jar:2.2.1]
at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:112) ~[play_2.10.jar:2.2.1]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:110) ~[play_2.10.jar:2.2.1]
at scala.util.Success.flatMap(Try.scala:200) ~[scala-library.jar:na]
Caused by: java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:936) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:781) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3762) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3716) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1410) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
I've ran into the same problem. The question here is that play-java-jpa artifact (javaJpa key in the build.sbt file) depends on a different version of the spec (version 2.0 -> "org.hibernate.javax.persistence" % "hibernate-jpa-2.0-api" % "1.0.1.Final").
When you added hibernate-entitymanager 4.3 this brought the newer spec (2.1) and a different factory provider for the entitymanager. Basically you ended up having both jars in the classpath as transitive dependencies.
Edit your build.sbt file like this and it will temporarily fix you problem until play releases a new version of the jpa plugin for the newer api dependency.
libraryDependencies ++= Seq(
javaJdbc,
javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"),
"org.hibernate" % "hibernate-entitymanager" % "4.3.0.Final"
)
This is for play 2.2.x. In previous versions there were some differences in the build files.
Hibernate 4.3 is the first version to implement the JPA 2.1 spec (part of Java EE 7). And it's thus expecting the JPA 2.1 library in the classpath, not the JPA 2.0 library. That's why you get this exception: Table.indexes() is a new attribute of Table, introduced in JPA 2.1
I update my Hibernate JPA to 2.1 and It works.
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
You probablly have 2 different versions of hibernate-jpa-api on the classpath. To check that run:
mvn dependency:tree >dep.txt
Then search if there are hibernate-jpa-2.0-api and hibernate-jpa-2.1-api. And exclude the excess one.
I could solve the issue simply by replacing the JPA api jar file which is located jboss7/modules/javax/persistence/api/main with 'hibernate-jpa-2.1-api'. also with updating module.xml in the directory.
Error:
java.lang.NoSuchMethodError: javax.persistence.JoinTable.indexes()[Ljavax/persistence/Index;
The only thing that solved my problem was removing the following dependency in pom.xml:
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
And replace it for:
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
Hope it helps someone.
i have experienced same issue in my spring boot application. after removing manually javax.persistance.jar file from lib folder. issue was fixed. in pom.xml file i have remained following dependency only
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
I had the same issue, I fixed it by using org.hibernate.annotations.Table annotation instead of javax.persistence.Table in the Entity class.
import javax.persistence.Entity;
import org.hibernate.annotations.Table;
#Entity
#Table(appliesTo = "my_table")
public class MyTable{
//and rest of the code
There are multiple JPA providers in your classpath. Or atleast in your Application server lib folder.
If you are using Maven
Check for dependencies using command mentioned here https://stackoverflow.com/a/47474708/3333878
Then fix by removing/excluding unwanted dependency.
If you just have one dependecy in your classpath, then the application server's class loader might be the issue.
As JavaEE application servers like Websphere, Wildfly, Tomee etc., have their own implementations of JPA and other EE Standards, The Class loader might load it's own implementation instead of picking from your classpath in WAR/EAR file.
To avoid this, you can try below steps.
Removing the offending jar in Application Servers library path. Proceed with Caution, as it might break other hosted applications.
In Tomee 1.7.5 Plume/ Web it will have bundled eclipselink-2.4.2 in the lib folder using JPA 2.0, but I had to use JPA 2.1 from org.hibernate:hibernate-core:5.1.17, so removed the eclipselink jar and added all related/ transitive dependencies from hibernate core.
Add a shared library. and manually add jars to the app server's path. Websphere has this option.
In Websphere, execution of class loader can be changed. so making it the application server's classpath to load last i.e, parent last and having your path load first. Can solve this.
Check if your appserver has above features, before proceeding with first point.
Ibm websphere References :
https://www.ibm.com/support/knowledgecenter/SSEQTP_9.0.5/com.ibm.websphere.base.doc/ae/trun_classload_server.html
https://www.ibm.com/support/pages/how-create-shared-library-and-associate-it-application-server-or-enterprise-application-websphere-application-server

Categories