maven java.lang.NoClassDefFoundError:sun/安全性/ssl/问候扩展

yrwegjxp  于 2022-11-22  发布在  Maven
关注(0)|答案(1)|浏览(273)

我目前正在进行一个项目,该项目使用NetBeans 8.2、jdk 1.8.0_311和glassfish 5.0将PayPal支付集成到Java Maven Web应用程序中。
共有两个文件,

** checkout .jsp:**

<%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>Check Out</title>
        <style type="text/css">
            table { border: 0; }
            table td { padding: 10px; }
        </style>
    </head>
    <body>
        <div align="center">
            <h1>Check Out</h1>
            <br/>
            <form action="./authorize_payment" method="post">
            <table>
                <tr>
                    <td>Product/Service:</td>
                    <td><input type="text" name="product" value="Next iPhone" /></td>
                </tr>
                <tr>
                    <td>Sub Total:</td>
                    <td><input type="text" name="subtotal" value="100" /></td>
                </tr>
                <tr>
                    <td>Shipping:</td>
                    <td><input type="text" name="shipping" value="10" /></td>
                </tr>    
                <tr>
                    <td>Tax:</td>
                    <td><input type="text" name="tax" value="10" /></td>
                </tr>    
                <tr>
                    <td>Total Amount:</td>
                    <td><input type="text" name="total" value="120" /></td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                        <input type="submit" value="Checkout" />
                    </td>
                </tr>
            </table>
            </form>
        </div>
    </body>
   </html>

授权支付.java(servlet):

package net.codejava.mavenproject1;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;

import com.paypal.base.rest.PayPalRESTException;

@WebServlet("/authorize_payment")
public class authorize_payment extends HttpServlet {
private static final long serialVersionUID = 1L;

public authorize_payment() {
}

protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String product = request.getParameter("product");
    String subtotal = request.getParameter("subtotal");
    String shipping = request.getParameter("shipping");
    String tax = request.getParameter("tax");
    String total = request.getParameter("total");
     
    OrderDetail orderDetail = new OrderDetail(product, subtotal, shipping, tax, total);

    try {
        PaymentServices paymentServices = new PaymentServices();
        String approvalLink = paymentServices.authorizePayment(orderDetail);

        response.sendRedirect(approvalLink);
         
    } catch (PayPalRESTException ex) {
        request.setAttribute("errorMessage", ex.getMessage());
        ex.printStackTrace();
        request.getRequestDispatcher("error.jsp").forward(request, response);
    }
}

}

当我单击checkout.jsp上的“checkout”按钮时,它显示:

例外情况

javax.servlet.ServletException:HTTP监视器服务器端组件在处理JSP或Servlet时截获并重新引发错误。请查看下面根本原因消息下的堆栈跟踪以确定问题。

根本原因

java.lang.NoClassDefFoundError:无法初始化类sun.security.ssl.SSLExtension

完整堆栈跟踪

Severe: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". Severe: SLF4J: Defaulting to no-operation (NOP) logger implementation Severe: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Warning: StandardWrapperValve[net.codejava.mavenproject1.authorize_payment]: Servlet.service() for servlet net.codejava.mavenproject1.authorize_payment threw exception java.lang.NoClassDefFoundError: sun/security/ssl/HelloExtension at sun.security.ssl.SSLExtension.(SSLExtension.java:225) at sun.security.ssl.SSLConfiguration.getEnabledExtensions(SSLConfiguration.java:380) at sun.security.ssl.ClientHello$ClientHelloKickstartProducer.produce(ClientHello.java:562) at sun.security.ssl.SSLHandshake.kickstart(SSLHandshake.java:509) at sun.security.ssl.ClientHandshakeContext.kickstart(ClientHandshakeContext.java:115) at sun.security.ssl.TransportContext.kickstart(TransportContext.java:250) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:394) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:373) at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:587) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:197) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1354) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1329) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:264) at com.paypal.base.HttpConnection.executeWithStream(HttpConnection.java:111) at com.paypal.base.HttpConnection.execute(HttpConnection.java:65) at com.paypal.base.rest.OAuthTokenCredential.generateAccessToken(OAuthTokenCredential.java:383) at com.paypal.base.rest.OAuthTokenCredential.getAccessToken(OAuthTokenCredential.java:230) at com.paypal.base.rest.APIContext.fetchAccessToken(APIContext.java:303) at com.paypal.base.rest.PayPalResource.configureAndExecute(PayPalResource.java:282) at com.paypal.base.rest.PayPalResource.configureAndExecute(PayPalResource.java:228) at com.paypal.api.payments.Payment.create(Payment.java:149) at net.codejava.mavenproject1.PaymentServices.authorizePayment(PaymentServices.java:35) at net.codejava.mavenproject1.authorize_payment.doPost(authorize_payment.java:29) at javax.servlet.http.HttpServlet.service(HttpServlet.java:665) at javax.servlet.http.HttpServlet.service(HttpServlet.java:750) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1540) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:297) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167) at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:215) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:119) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:550) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:75) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:114) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:199) at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:439) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:144) 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:515) 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(Thread.java:748)

Warning: StandardWrapperValve[net.codejava.mavenproject1.authorize_payment]: Servlet.service() for servlet net.codejava.mavenproject1.authorize_payment threw exception java.lang.NoClassDefFoundError: Could not initialize class sun.security.ssl.SSLExtension at sun.security.ssl.SSLConfiguration.getEnabledExtensions(SSLConfiguration.java:380) at sun.security.ssl.ClientHello$ClientHelloKickstartProducer.produce(ClientHello.java:562) at sun.security.ssl.SSLHandshake.kickstart(SSLHandshake.java:509) at sun.security.ssl.ClientHandshakeContext.kickstart(ClientHandshakeContext.java:115) at sun.security.ssl.TransportContext.kickstart(TransportContext.java:250) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:394) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:373) at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:587) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:197) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1354) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1329) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:264) at com.paypal.base.HttpConnection.executeWithStream(HttpConnection.java:111) at com.paypal.base.HttpConnection.execute(HttpConnection.java:65) at com.paypal.base.rest.OAuthTokenCredential.generateAccessToken(OAuthTokenCredential.java:383) at com.paypal.base.rest.OAuthTokenCredential.getAccessToken(OAuthTokenCredential.java:230) at com.paypal.base.rest.APIContext.fetchAccessToken(APIContext.java:303) at com.paypal.base.rest.PayPalResource.configureAndExecute(PayPalResource.java:282) at com.paypal.base.rest.PayPalResource.configureAndExecute(PayPalResource.java:228) at com.paypal.api.payments.Payment.create(Payment.java:149) at net.codejava.mavenproject1.PaymentServices.authorizePayment(PaymentServices.java:35) at net.codejava.mavenproject1.authorize_payment.doPost(authorize_payment.java:29) at javax.servlet.http.HttpServlet.service(HttpServlet.java:665) at javax.servlet.http.HttpServlet.service(HttpServlet.java:750) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1540) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:297) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167) at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:215) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:119) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:550) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:75) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:114) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:199) at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:439) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:144) 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:515) 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(Thread.java:748)

我已经尝试将jdk版本降级到jdk1.8.0_151、jdk1.8.0_181、jdk1.8.0_221和jdk1.8.0_291,但是我还是得到了同样的错误。我也试着用glassfish server 5.1运行这个程序,但是仍然没有成功。我也试着删除grizzly-npn-bootstrap.jar中的sun文件this post中所建议的,但不幸的是,它没有工作。
我希望有人能帮我找出问题所在,因为我已经试着解决它将近一个星期了,它让我发疯。

roejwanj

roejwanj1#

首先,这是由于webapp配置错误。您需要阅读该链接,并采取建议的操作来获得正常运行的日志记录。

Severe: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
Severe: SLF4J: Defaulting to no-operation (NOP) logger implementation 
Severe: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

然后这些来自不同版本的Java8

java.lang.NoClassDefFoundError: sun/security/ssl/HelloExtension
java.lang.NoClassDefFoundError: Could not initialize class sun.security.ssl.SSLExtension

HelloExtensionSSLExtension类是内部类,前者被后者替换。
但是请注意,NoClassDefFoundError异常可能并不意味着类丢失了,它们可能意味着类静态初始化失败了......或者类所依赖的类静态初始化失败了。
我本以为会有其他堆栈追踪Map到初始化失败。可能是因为记录组态问题而遗失。
目前还不清楚实际的问题是什么,但看起来在SSL代码的初始化过程中出现了故障。一种可能性是SSL设置有问题。
我的建议是:
1.首先修复日志记录问题。
1.接下来使用最新版本的Java8。使用过时的Java8版本有帮助的可能性几乎为零。
1.检查您在Web容器中使用的所有SSL设置。
1.查找 * 其他 * 堆栈跟踪,解释 * 为什么 * 发生以下情况:

Could not initialize class sun.security.ssl.SSLExtension

相关问题