eclipse-ee4j / glassfish

Eclipse GlassFish
https://eclipse-ee4j.github.io/glassfish/
385 stars 144 forks source link

Instantiation of SSLSessionImpl fails in ClientHandshaker #22436

Closed glassfishrobot closed 4 years ago

glassfishrobot commented 6 years ago

When using SSL with JavaMail, the ClientHandshaker delivered by glassfish tries to instantiate the SSLSessionImpl. But the signature of the constructure seem to have change in recent updates of JDK 8 (u161).

Environment Details


Problem Description

The connection to an SSL email server fails, due to an error in instantiation the SSLSessionImpl in the ClientHandshaker.

Fatal exception occured while processing datasource: 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
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
    at sun.security.ssl.ClientHandshaker.serverHello(ClientHandshaker.java:709)
    at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:209)
    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:984)
    at sun.security.ssl.Handshaker.process_record(Handshaker.java:919)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
    at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:619)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:393)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:238)
    at com.sun.mail.iap.Protocol.<init>(Protocol.java:124)
    at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:128)
    at com.sun.mail.imap.IMAPStore.newIMAPProtocol(IMAPStore.java:758)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:693)
    at javax.mail.Service.connect(Service.java:366)
    at javax.mail.Service.connect(Service.java:246)

Steps to reproduce

Session session = Session.getInstance(props);

Store store = null;
store = session.getStore("imaps");

            store.connect("host",
                    "user",
                    "password" 
           );

Impact of Issue

No SSL available.

glassfishrobot commented 6 years ago
glassfishrobot commented 6 years ago

@yooouuri Commented I am having the same issue (not with email), java.lang.NoSuchMethodError: sun.security.ssl.SSLSessionImpl.<init>(...)

https://stackoverflow.com/questions/49383650/sun-security-ssl-sslsessionimpl-not-found

@sapsiero after downgrading to 1.8.0_151 the issue is gone.

So after 151 there is something broken...

glassfishrobot commented 6 years ago

@yaminikb Commented @yooouuri There is some incompatible changes in the JDK after u152 that is impacting Grizzly. Hence, Grizzly had to be fixed and integrated into GlassFish 5.0.1. Can you try with latest GlassFish 5.0.1? http://download.oracle.com/glassfish/5.0.1/nightly/latest-glassfish.zip

glassfishrobot commented 6 years ago

@yooouuri Commented @yaminikb When I try to create a JDBC pool with 5.0.1 I get the following error:

Ping Connection Pool failed for MysqlPool. The connection could not be allocated: Cannot open file:/Users/youri/glassfish5/glassfish/domains/test/config/keystore.jks [Keystore was tampered with, or password was incorrect] Please check the server.log for more details.

22473

glassfishrobot commented 6 years ago

@Asilvam Commented I have the same issue:

after downgrading to 1.8.0_151 the issue is gone.

thanks @yooouuri

Kunzol commented 5 years ago

I found a workaround with the help of a similar issue on stackoverflow

I removed the "sun" folder from the jar file "glassfish5/glassfish/modules/endorsed/grizzly-npn-bootstrap.jar"

After removing the "sun" folder from the jar, glassfish runs with openJDK 8 (1.8.0_181), too.

github-actions[bot] commented 4 years ago

This issue has been marked as inactive and old and will be closed in 7 days if there is no further activity. If you want the issue to remain open please add a comment

team172011 commented 4 years ago

thanks @Kunzol this issue was still the case for me with the current glassfish 5.1 and latest jdk 8 "1.8.0_261" on linux (ubuntu 18)

tbvinh commented 3 years ago

I just installed the Glassfish at: http://download.oracle.com/glassfish/5.0.1/nightly/latest-glassfish.zip (open java 1.8.0_275-8u275) Then remove out the folder sun* in glassfish5/glassfish/modules/endorsed/grizzly-npn-bootstrap.jar

Everything is OK

ghost commented 1 year ago
  1. I have removed sun folder from glassfish5/glassfish/modules/endorsed/grizzly-npn-bootstrap.jar.
  2. I have downgraded to jdk 8 "1.8.0_151" But the error does not go. Glassfish version 5.1.0 and Microsoft SQL server 2019 database. Thank you.
OndroMih commented 1 year ago

Dear @shrsm2022, have you considered using GlassFish 7 with Java 11+?

It looks like this issue has been resolved already in GlassFish 6: https://github.com/eclipse-ee4j/glassfish/pull/23179

GlassFish 5.1 is an old version and not supported anymore by the Eclipse GlassFish project team. If you can't deploy your application to GlassFish 7 because of the change in Jakarta EE package names from javax to jakarta, you can try the Eclipse Transformer tool to transform your application to use the jakarta package in the final WAR/EAR package and then deploy to GlassFish 7.

If you need help with upgrading to GlassFish 7 or support older versions of GlassFish, I recommend seeking professional services from companies that provide commercial support for Eclipse GlassFish, see: https://glassfish.org/support.html

ghost commented 1 year ago

Hello, Thank you for the reply. Since it is an old version of Java EE ie EE7 2013 version, will it not make more sense to downgrade my glassfish version to 4 rather than upgrade to 7. rgds

On Thu, 2 Mar 2023 at 00:01, Ondro Mihályi @.***> wrote:

Dear @shrsm2022 https://github.com/shrsm2022, have you considered using GlassFish 7 with Java 11+?

It looks like this issue has been resolved already in GlassFish 6: #23179 https://github.com/eclipse-ee4j/glassfish/pull/23179

GlassFish 5.1 is an old version and not supported anymore by the Eclipse GlassFish project team. If you can't deploy your application to GlassFish 7 because of the change in Jakarta EE package names from javax to jakarta, you can try the Eclipse Transformer https://github.com/eclipse/transformer tool to transform your application to use the jakarta package in the final WAR/EAR package and then deploy to GlassFish 7.

If you need help with upgrading to GlassFish 7 or support older versions of GlassFish, I recommend seeking professional services from companies that provide commercial support for Eclipse GlassFish, see: https://glassfish.org/support.html

— Reply to this email directly, view it on GitHub https://github.com/eclipse-ee4j/glassfish/issues/22436#issuecomment-1450655124, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6CIORVM4TX3XOXLJLBZI4LWZ6IZJANCNFSM4FVSXS3Q . You are receiving this because you were mentioned.Message ID: @.***>

OndroMih commented 1 year ago

It depends. It might fine under GlassFish 4 and Java 8. But you'll be running an old, unsupported and probably buggy version of GlassFish and Java 8. If you manage to upgrade to GlassFish 7, you'll be more safe, with a lot of upgraded components in GlassFish, security fixes and improvements, with more fixes and improvements coming in newer versions. And you'll be able to run on a newer Java too.

ghost commented 1 year ago

Ok, thank you. rgds

On Sun, 5 Mar 2023 at 10:15, Ondro Mihályi @.***> wrote:

It depends. It might fine under GlassFish 4 and Java 8. But you'll be running an old, unsupported and probably buggy version of GlassFish and Java 8. If you manage to upgrade to GlassFish 7, you'll be more safe, with a lot of upgraded components in GlassFish, security fixes and improvements, with more fixes and improvements coming in newer versions. And you'll be able to run on a newer Java too.

— Reply to this email directly, view it on GitHub https://github.com/eclipse-ee4j/glassfish/issues/22436#issuecomment-1454989098, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6CIORU2H4I4F2JP7SDHU3TW2QLALANCNFSM4FVSXS3Q . You are receiving this because you were mentioned.Message ID: @.***>

ghost commented 1 year ago

Hello,

  1. Please view the following link. https://javaee.github.io/glassfish/download It says here that for Java EE 7 I need Glassfish 4 as the supporting version.

  2. When I try to download Glassfish 4.0/4.1 I am redirected to the following link at oracle.com and it does not work. https://download.oracle.com/glassfish/4.0/release/index.html

  3. While oracle.com shows me this to download Glassfish 3.1 from https://www.oracle.com/middleware/technologies/glassfish-server.html

  4. So where has Glassfish 4.1 disappeared.Since I am learning Java EE 7 I thought I ought to get my basics right before moving on to Java EE 8 and Java EE 9. So can someone help me with the correct download link for glassfish 4.1 server.

Thank You in advance. glassfish 4.1.docx

OndroMih commented 1 year ago

Hi, @shrsm2022, if you really want to use GlassFish 4.1, then you can download it from this page: https://javaee.github.io/glassfish/download#older-glassfish-versions-archive. There are direct download links in the section Older GlassFish versions (archive) which work.

But if you're just now starting learning Java EE 7, I would recommend you to quickly try Jakarta EE 10 and GlassFish 7 as soon as you get familiar with the basics. The major difference between Java EE 7 and Jakarta EE 10 is that most classes were moved from packages starting with javax. to packages starting with jakarta. - it should be enough to change the imports in your Java files to switch from Java EE 7 to Jakarta EE 10.

ghost commented 1 year ago

Hello Ondro,

Thank you for your efforts and taking out the time to reply to my post. I managed to get the project working on JavaEE6 and JavaEE7 and JavaEE8 using Glassfish 5. I will take your advice and get started on Java EE10 asap.

Thank you. rgds

On Fri, 14 Apr 2023 at 02:32, Ondro Mihályi @.***> wrote:

Hi, @shrsm2022 https://github.com/shrsm2022, if you really want to use GlassFish 4.1, then you can download it from this page: https://javaee.github.io/glassfish/download#older-glassfish-versions-archive. There are direct download links in the section Older GlassFish versions (archive) which work.

But if you're just now starting learning Java EE 7, I would recommend you to quickly try Jakarta EE 10 and GlassFish 7 as soon as you get familiar with the basics. The major difference between Java EE 7 and Jakarta EE 10 is that most classes were moved from packages starting with javax. to packages starting with jakarta. - it should be enough to change the imports in your Java files to switch from Java EE 7 to Jakarta EE 10.

— Reply to this email directly, view it on GitHub https://github.com/eclipse-ee4j/glassfish/issues/22436#issuecomment-1507606285, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6CIORQANFG45DAKJX36TWTXBBSYDANCNFSM4FVSXS3Q . You are receiving this because you were mentioned.Message ID: @.***>

OndroMih commented 1 year ago

Hi, @shrsm2022, I'm glad you managed to get your project working on GlassFish 5.

If you have some issues with Jakarta EE 10 and GlassFish 7, I hope this resource will help you: https://github.com/OmniFish-EE/upgrading-jakarta-ee-applicaitons#readme. This is where I started documenting ways how to address some challenges when migrating projects from Java EE 8 to Jakarta EE 9 or 10, or when adding libraries to your application that require Java EE 8 and aren't compatible with Jakarta EE 9 or 10. A lot of libraries now support Jakarta EE 10, many others plan adding support in the next few months, but some popular libraries are pretty old and unmaintained, so it's possible that they will never support Jakarta EE out of the box. There are tools to address that pretty easily and Github repository shows how to use them.

ghost commented 1 year ago

Hello, I have one question to ask you. I got my project working by doing a fresh install of glassfish 5. But this second time around the errors pointed me in the direction to open the some ports through windows firewall. This did not happen the first time around. Is this step necessary to configure glassfish server or have I been mislead? rgds

On Mon, 17 Apr 2023 at 16:12, Ondro Mihályi @.***> wrote:

Hi, @shrsm2022 https://github.com/shrsm2022, I'm glad you managed to get your project working on GlassFish 5.

If you have some issues with Jakarta EE 10 and GlassFish 7, I hope this resource will help you: https://github.com/OmniFish-EE/upgrading-jakarta-ee-applicaitons#readme. This is where I started documenting ways how to address some challenges when migrating projects from Java EE 8 to Jakarta EE 9 or 10, or when adding libraries to your application that require Java EE 8 and aren't compatible with Jakarta EE 9 or 10. A lot of libraries now support Jakarta EE 10, many others plan adding support in the next few months, but some popular libraries are pretty old and unmaintained, so it's possible that they will never support Jakarta EE out of the box. There are tools to address that pretty easily and Github repository shows how to use them.

— Reply to this email directly, view it on GitHub https://github.com/eclipse-ee4j/glassfish/issues/22436#issuecomment-1511108038, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6CIORTX2ZFCJUKWSBJNIG3XBUM7ZANCNFSM4FVSXS3Q . You are receiving this because you were mentioned.Message ID: @.***>

OndroMih commented 1 year ago

If you want to configure GlassFish from a remote computer, you need to open the admin port (by default 4848) in the firewall. If you only configure it from the same computer where GlassFish is running, you don't need to open this port. It should be open for connections from localhost but this is normally allowed by firewalls.

ghost commented 1 year ago

Hi, During a forced fresh installation of glassfish 5.1 I was forced to open port 1433 for database in windows 10. And the project wouldnt run till I created a rule to that effect. But that did not happen in the earlier glassfish version. I am worried that I have allowed an inbound connection to my computer on that port from outside computers. rgds

On Thu, 20 Apr 2023 at 16:58, Ondro Mihályi @.***> wrote:

If you want to configure GlassFish from a remote computer, you need to open the admin port (by default 4848) in the firewall. If you only configure it from the same computer where GlassFish is running, you don't need to open this port. It should be open for connections from localhost but this is normally allowed by firewalls.

— Reply to this email directly, view it on GitHub https://github.com/eclipse-ee4j/glassfish/issues/22436#issuecomment-1516165914, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6CIORTCXVXV7VZPOEP5QB3XCEMVZANCNFSM4FVSXS3Q . You are receiving this because you were mentioned.Message ID: @.***>

OndroMih commented 1 year ago

1433 is the port of a MySQL database. GlassFish probably needs it when you create a datasource to connect to that database. It's enough to open the port only for local connections, from localhost, if both GlassFish and MySQL DB run on the same computer. No need to open this port to the outside world.

OndroMih commented 1 year ago

By the way, this isn't related to the ClientHandshaker issue and thus not related to this issues. Please raise your questions either on the mailing list https://accounts.eclipse.org/mailing-list/glassfish-dev or as a new issue. And specify more details, ideally a complete example and the configuration changes needed to reproduce your issue.

ghost commented 1 year ago

Thank you for your response.

On Mon, 8 May 2023 at 14:48, Ondro Mihályi @.***> wrote:

By the way, this isn't related to the ClientHandshaker issue and thus not related to this issues. Please raise your questions either on the mailing list https://accounts.eclipse.org/mailing-list/glassfish-dev or as a new issue. And specify more details, ideally a complete example and the configuration changes needed to reproduce your issue.

— Reply to this email directly, view it on GitHub https://github.com/eclipse-ee4j/glassfish/issues/22436#issuecomment-1538040729, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6CIORXFKNHE5SRVDNSWR7DXFC273ANCNFSM4FVSXS3Q . You are receiving this because you were mentioned.Message ID: @.***>