Pedro
Pedro

Reputation: 313

java.lang.NoSuchMethodError: sun.security.ssl.SSLSessionImpl.<init> in Spring, Hibernate and JSF project running on Glassfish with Java 8

I have a project using the following technologies:

The application is throwing the following exception (java.lang.NoSuchMethodError):

[2018-09-11T12:57:32.846+0100] [glassfish 5.0] [WARNING] [] [org.springframework.context.annotation.AnnotationConfigApplicationContext] [tid: _ThreadID=31 _ThreadName=http-listener-1(3)] [timeMillis: 1536667052846] [levelValue: 900] [[
  Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'applicationServiceImp': Unsatisfied dependency expressed through field 'applicationDAO'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'applicationDAO': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in com.foo.app.HibernateConf: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: sun.security.ssl.SSLSessionImpl.<init>(Lsun/security/ssl/ProtocolVersion;Lsun/security/ssl/CipherSuite;Ljava/util/Collection;Lsun/security/ssl/SessionId;Ljava/lang/String;I)V]]

Here is my POM:

<?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.foo</groupId>
    <artifactId>FOO</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
    </properties>

    <dependencies>

        <!--EmailAddress Validator-->
        <dependency>
            <groupId>commons-validator</groupId>
            <artifactId>commons-validator</artifactId>
            <version>1.6</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.primefaces/primefaces -->
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>6.2</version>
        </dependency>

        <dependency>
            <groupId>org.primefaces.extensions</groupId>
            <artifactId>primefaces-extensions</artifactId>
            <version>6.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/javax.faces/javax.faces-api -->
        <dependency>
            <groupId>javax.faces</groupId>
            <artifactId>javax.faces-api</artifactId>
            <version>2.1</version>
        </dependency>

        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.2.9</version>
        </dependency>

        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.2.9</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.3.1.Final</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator -->
        <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>6.0.9.Final</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.17</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.17</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.lowagie/itext -->
        <dependency>
            <groupId>com.lowagie</groupId>
            <artifactId>itext</artifactId>
            <version>2.1.7</version>
        </dependency>

        <!-- spring-orm module provides the Spring integration with Hibernate -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>5.0.6.RELEASE</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>5.0.6.RELEASE</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-dbcp2 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-dbcp2</artifactId>
            <version>2.3.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/jaxen/jaxen -->
        <dependency>
            <groupId>jaxen</groupId>
            <artifactId>jaxen</artifactId>
            <version>1.1.6</version>
        </dependency>


    </dependencies>

    <build>
        <sourceDirectory>src/main/java</sourceDirectory>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>

        <testSourceDirectory>src/test/java</testSourceDirectory>
        <testResources>
            <testResource>
                <directory>source/test/resources</directory>
            </testResource>
        </testResources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <warSourceDirectory>web</warSourceDirectory>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

I'm not experienced with back end technologies. I received this project and just wanted it to run well so I can start changing the front end. I know it runs well on the computer of the person who created the project. It runs without this exception being thrown.

The project compiles fine. And also starts running fine. I don't understand why this exception happens.

Upvotes: 2

Views: 1995

Answers (3)

Ikbel
Ikbel

Reputation: 2213

After downgrading java to 1.8 version and still have the same issue :

org.hibernate.exception.GenericJDBCException: Unable to open JDBC Connection for DDL execution]]  it seems that this error occurred due to a  bad  database connection, thus

You have to set up your database connection properties in application.properties under the resources folder

spring.datasource.driverClassName=com.mysql.jdbc.Driver 
spring.datasource.username=Ur user name 
spring.datasource.password=Your data base password
spring.datasource.platform=mysql spring.datasource.continueOnError=false

Upvotes: 2

Daniel Piskorz
Daniel Piskorz

Reputation: 440

I thing the error I mentioned was replaced by this one when I downgraded: org.hibernate.exception.GenericJDBCException: Unable to open JDBC Connection for DDL execution

That's good. Now we have to establish database connection and we're home.

On that point I'd focus on hibernate data source configuration. Big chance that there is a problem.

Properties set in connection driver have to perfectly match. Check driver, url, port, username and password (watch out for case sensitive and spaces).

Your user may also miss SQL Server permissions, but this is a case for DB admin.

Upvotes: 1

Daniel Piskorz
Daniel Piskorz

Reputation: 440

You should downgrade java (JDK & JRE) to 1.8.0_151.

That will solve the problem.

Upvotes: 2

Related Questions