JavaWeb java.lang.NoClassDefFoundError: sun/security/ssl/HelloExtension

筅森魡賤 提交于 2021-02-17 05:59:51

问题


I'm getting an error when trying to use a JavaWeb project using Glassfish 5.0. Everytime it tries to bring data from my SQL Database it gives me this error.
StandardWrapperValve[ListadoPersonas]: Servlet.service() for servlet ListadoPersonas threw exception java.lang.NoClassDefFoundError: sun/security/ssl/HelloExtension

Here is the servlet ListadoEstadosCiviles where I call the function which brings the data back from my database

GestorPersonas g = new GestorPersonas();
ArrayList<EstadoCivil> lista = g.obtenerEstadosCiviles();
for (EstadoCivil estadoCivil : lista) {
    out.println("<tr><td>" + estadoCivil.getId() + "</td><td>" + estadoCivil.getNombre() + "</td></tr>");
}

Here is GestorPersonas() constructor:

 public GestorPersonas() {
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(GestorPersonas.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

Here is obtenerEstadosCiviles() method

public ArrayList<EstadoCivil> obtenerEstadosCiviles() {
    ArrayList<EstadoCivil> lista = new ArrayList<>();
    
    try {
        Connection conn = DriverManager.getConnection(CONN,USER,PASS);
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery("select * from EstadosCiviles");
        // Si el select devuelve una única fila, en lugar de while, se usa un if
        while (rs.next()) {
            int id = rs.getInt("id");
            String nombre = rs.getString("nombre");
            EstadoCivil ec = new EstadoCivil(id, nombre);
            lista.add(ec);
        }
        
        rs.close();
        st.close();
        conn.close();
    } catch (SQLException ex) {
        Logger.getLogger(GestorPersonas.class.getName()).log(Level.SEVERE, null, ex);
    }
    
    return lista;
}

I have no problem connecting my java application to sql, I think the problem is with glassfish but i cant figure out why it is not working

This is the servlet that is calling obtenerEstadosCiviles() function, I expect that table full with data

What I expect:

UPDATE

I've just checked my plugins and it appears that Java Web and EE it´s activated but the "Active" symbol doesnt appears active. Could this be part of the problem?


回答1:


Had basically the same problem, eventually solved it with this solution here.

In your glassfish folder go to glassfish5/glassfish/modules/endorsed/ and open the grizzly-npn-bootstrap.jar file with winrar or your preferred unzipper.

Delete the sun folder and try running your program again.



来源:https://stackoverflow.com/questions/64140616/javaweb-java-lang-noclassdeffounderror-sun-security-ssl-helloextension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!