title: Fix 'java.lang.NoSuchMethodError: sun.security.ssl.SSLSessionImpl'
body: <p>I've set up a virtual machine where I will deploy my JavaEE backend on glasssfish (payara). The deployment is not the problem, but whenever I want to access my API I get this</p>
  
  <blockquote>
    <p>java.lang.NoSuchMethodError: sun.security.ssl.SSLSessionImpl</p>
  </blockquote>
  
  <p>error in my server logs. I can access my API on the open 8080 port of my VM, e.g. </p>
  
  <blockquote>
    <p>myapp.westeurope.cloudapp.azure.com:8080/myapp/services/rest/authentication</p>
  </blockquote>
  
  <p>and when I try to access this I get an internal server error with the mentioned error. However whenever I deploy the exact same .war file on my own PC with IntelliJ IDEA or with the command prompt and the same Glassfish and JDK versions I can access the API on my localhost without any errors and all functions will work.</p>
  
  <p>I am using:</p>
  
  <ul>
  <li>Azure Virtual Machine</li>
  <li>Glassfish (payara) 5.183</li>
  <li>JDK 1.8.0_201</li>
  <li>Frameworks: Hibernate and JAX-RS</li>
  </ul>
  
  <p>I've read this answer from a similar question:</p>
  
  <ul>
  <li>If you use GlassFish 5.0, you need to be on a version of JDK 8 below JDK </li>
  <li>If you use GlassFish 5.0.1 or higher, you need to be on a version of JDK 8
  above</li>
  </ul>
  
  <p>Looking at the versions I'm using this suggestion isn't the solution since the problem is still there. Another suggestion was that downgrading to JDK 1.8.0_151 should fix the problem, however it did not.</p>
  
  <p>The stacktrace from the server log:</p>
  
  <pre><code>[2019-03-23T15:39:33.248+0000] [Payara 5.183] [WARNING] [] [javax.enterprise.web] [tid: _ThreadID=34 _ThreadName=http-thread-pool::http-listener-1(3)] [timeMillis: 1553355573248] [levelValue: 900] [[
    StandardWrapperValve[API.Config.App]: Servlet.service() for servlet API.Config.App threw exception
  java.lang.NoSuchMethodError: sun.security.ssl.SSLSessionImpl.&lt;init&gt;(Lsun/security/ssl/ProtocolVersion;Lsun/security/ssl/CipherSuite;Ljava/util/Collection;Lsun/security/ssl/SessionId;Ljava/lang/String;IZ)V
      at sun.security.ssl.ClientHandshaker.serverHello(ClientHandshaker.java:776)
      at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:224)
      at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1077)
      at sun.security.ssl.Handshaker.process_record(Handshaker.java:1012)
      at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
      at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
      at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
      at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
      at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1799)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2452)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2103)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1950)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1162)
      at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:735)
      at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:38)
      at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:58)
      at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.addConnections(DriverManagerConnectionProviderImpl.java:363)
      at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.&lt;init&gt;(DriverManagerConnectionProviderImpl.java:282)
      at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.&lt;init&gt;(DriverManagerConnectionProviderImpl.java:260)
      at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections$Builder.build(DriverManagerConnectionProviderImpl.java:401)
      at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildPool(DriverManagerConnectionProviderImpl.java:112)
      at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:75)
      at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:100)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:246)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
      at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145)
      at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66)
      at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
      at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:94)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
      at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
      at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.&lt;init&gt;(InFlightMetadataCollectorImpl.java:179)
      at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:119)
      at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:904)
      at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:935)
      at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56)
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
      at Services.Implementation.UserRepository.&lt;init&gt;(UserRepository.java:33)
      at Services.Implementation.UserRepository.&lt;clinit&gt;(UserRepository.java:25)
      at API.AuthenticationResource.&lt;init&gt;(AuthenticationResource.java:28)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1375)
      at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:272)
      at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:366)
      at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:487)
      at org.glassfish.jersey.inject.hk2.RequestContext.findOrCreate(RequestContext.java:83)
      at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2126)
      at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:777)
      at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:740)
      at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:710)
      at org.glassfish.jersey.inject.hk2.AbstractHk2InjectionManager.getInstance(AbstractHk2InjectionManager.java:184)
      at org.glassfish.jersey.inject.hk2.ImmediateHk2InjectionManager.getInstance(ImmediateHk2InjectionManager.java:54)
      at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:129)
      at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:286)
      at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:75)
      at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:110)
      at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
      at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
      at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
      at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:93)
      at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:62)
      at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197)
      at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:269)
      at org.glassfish.jersey.internal.Errors$1.call(Errors.java:272)
      at org.glassfish.jersey.internal.Errors$1.call(Errors.java:268)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:268)
      at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:289)
      at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:256)
      at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:704)
      at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:416)
      at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:370)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:389)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:342)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:229)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1628)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:258)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:755)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:575)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
      at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:516)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:213)
      at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
      at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
      at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
      at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
      at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
      at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:524)
      at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
      at java.lang.Thread.run(Unknown Source)
  ]]
  
  </code></pre>