First, know that I'm new to programming and currently taking a course on EE through Udemy, so please help, but in simple terms. On the sample projects I've built as part of this course, I've been using Glassfish to deploy servlets with no problems.
The SSL certificate expiration message I get on my console just started happening while trying to deploy a new project using JPA for the first time. In this project, I'm using eclipseLink and Derby. I followed the instructions exactly except in the following:
When specifying a Driver and connection details using the Data Source Explorer tool in Eclipse after creating the data Source in the Glassfish Management Console, I didn't get any drivers from the dropdown list, so I chose "Derby Embedded JDBC Driver" from the template choices, cleared all the jar files, and then added the url for the jar file included in my Glassfish 4.1.1/DerbyDB computer folder, even though I'm using Glassfish 5.0.
I am able to establish a connection, so I don't think that's causing any problems, but I had to add that comment just in case, so you'll know that's the only thing I have done differently from the instructions. This is the comment in the response page (which is supposed to be in blank because I didn't add anything):
Served at: /jpa3
(jpa3 is the name of my project).
The following is the exact console message I get when I access my servlet in my browser: (Notice the bold*, and please pardon my long console message, but I haven't earned enough credits to post a picture). Thanks in advance!
2020-04-01T10:37:37.855-0400|Info: Running GlassFish Version: GlassFish Server Open Source Edition 5.0 (build 25)
2020-04-01T10:37:37.863-0400|Info: Server log file is using Formatter class: com.sun.enterprise.server.logging.ODLLogFormatter
2020-04-01T10:37:37.989-0400|Info: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
2020-04-01T10:37:38.005-0400|Info: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
2020-04-01T10:37:38.005-0400|Info: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.
2020-04-01T10:37:38.205-0400|Info: Authorization Service has successfully initialized.
2020-04-01T10:37:38.494-0400|Info: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry
2020-04-01T10:37:38.575-0400|Info: JTS5014: Recoverable JTS instance, serverId = [100]
2020-04-01T10:37:38.691-0400|Info: Grizzly Framework 2.4.1 started in: 85ms - bound to [/0.0.0.0:8080]
2020-04-01T10:37:38.854-0400|Info: Grizzly Framework 2.4.1 started in: 0ms - bound to [/0.0.0.0:8181]
2020-04-01T10:37:38.854-0400|Info: Grizzly Framework 2.4.1 started in: 0ms - bound to [/0.0.0.0:4848]
2020-04-01T10:37:38.923-0400|Info: Grizzly Framework 2.4.1 started in: 0ms - bound to [/0.0.0.0:3700]
2020-04-01T10:37:39.108-0400|Info: visiting unvisited references
**2020-04-01T10:37:40.479-0400|Severe: The SSL certificate has expired:** [
[
Version: V3
Subject: CN=UTN-USERFirst-Client Authentication and Email, OU=http://www.usertrust.com, O=The USERTRUST Network, L=Salt Lake City, ST=UT, C=US
Signature Algorithm: SHA1withRSA, OID = 1.2.840.113549.1.1.5
Key: Sun RSA public key, 2048 bits
modulus: 22498783463083432959284168386409369291955038543860490014652552599946227610701597170140025777460440051576940055114151688564424450502962692946914121648464149848971060576483061771422853543951215013563325278089962342124385107871785292348304269132449951488798696535892014442011779480523971888046182115783313222830528011595242687378120162559160959607028365210240184157701430166819711652309059420982812476846459005227651384919840114419411479826761790470294309563612921306187982315796035562139890571490770636907160827366435324974533991196628542326996888957757240366713401462322756766583136758771465334269521766556285170101483
public exponent: 65537
Validity: [From: Fri Jul 09 13:28:50 EDT 1999,
To: Tue Jul 09 13:36:58 EDT 2019]
Issuer: CN=UTN-USERFirst-Client Authentication and Email, OU=http://www.usertrust.com, O=The USERTRUST Network, L=Salt Lake City, ST=UT, C=US
SerialNumber: [ 44be0c8b 500024b4 11d33625 2567c989]
Certificate Extensions: 5
[1]: ObjectId: 2.5.29.19 Criticality=true
BasicConstraints:[
CA:true
PathLen:2147483647
]
[2]: ObjectId: 2.5.29.31 Criticality=false
CRLDistributionPoints [
[DistributionPoint:
[URIName: http://crl.usertrust.com/UTN-USERFirst-ClientAuthenticationandEmail.crl]
This is the servlet:
package com.airline.controllers;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.airline.models.FlightClass;
import com.airline.models.Gender;
import com.airline.models.Passenger;
import com.airline.service.PassengerService;
/**
* Servlet implementation class AddPassenger
*/
@WebServlet("/AddPassenger")
public class AddPassenger extends HttpServlet {
private static final long serialVersionUID = 1L;
@EJB
PassengerService ps;
/**
* @see HttpServlet#HttpServlet()
*/
public AddPassenger() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
// response.getWriter().append("Served at: ").append(request.getContextPath());
Passenger p = new Passenger();
p.setFirstName("Daniel");
p.setLastName("Charnetz");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 1986);
cal.set(Calendar.MONTH, 9);
cal.set(Calendar.DAY_OF_MONTH, 10);
Date dob = cal.getTime();
p.setDob(dob);
p.setGender(Gender.Male);
p.setFlightClass(FlightClass.Coach);
System.out.println(p);
System.out.println("Passenger object has been set.");
ps.addPassenger(p);
System.out.println("Passenger has been saved");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
// doGet(request, response);
}
}
This is the EJB service:
package com.airline.service;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import com.airline.models.Passenger;
/**
* Session Bean implementation class PassengerService
*/
@Stateless
@LocalBean
public class PassengerService {
/**
* Default constructor.
*/
public PassengerService() {
// TODO Auto-generated constructor stub
}
// inject the airline persistence unit (database unit) as it appears in the xml file
// instead of injecting an enterprise java bean (@EJB), inject a database EntityManager object from the xml file by the name of "airline"
@PersistenceContext(unitName="airline") // inject managed database into an EntityManager object.
private EntityManager em; // allows us to communicate with the database through its methods.
public void addPassenger(Passenger p)
{
em.persist(p);
}
}
This is the entity class:
package com.airline.models;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
/**
* Entity implementation class for Entity: Passanger
*
*/
@Entity
// Go to project's Properties -> JPA, then look for: "Persistent class management", and select option: "Discover annotated classes automatically, and press "apply."
// so this manage's class name doesn't need to be added to the xml file.
// OR: explicitly add the name of the class in the xml file within <class>com.airline.models.Passenger</class> before the proterties tag and after the jts tag.
public class Passenger implements Serializable {
@Transient // We don't want this field to represent a column in our database.
private static final long serialVersionUID = 1L;
public Passenger() {
super();
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private String firstName;
private String lastName;
@Temporal(TemporalType.DATE) // This is so that the date can be saved as a date in the dob column in the
// database.
private Date dob;
@Enumerated(EnumType.STRING) // The value in Gender column in database would be saved as a digit if we don't
// put this as String annotation.
private Gender gender;
@Enumerated(EnumType.STRING) // ordinal (digit) is the default, instead of STRING.
private FlightClass flightClass;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public Date getDob() {
return dob;
}
public void setDob(Date dob) {
this.dob = dob;
}
public Gender getGender() {
return gender;
}
public void setGender(Gender gender) {
this.gender = gender;
}
public FlightClass getFlightClass() {
return flightClass;
}
public void setFlightClass(FlightClass flightClass) {
this.flightClass = flightClass;
// toString method here
}
}
This is the JPA persistence xml file:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="airline">
<jta-data-source>jdbc/airline</jta-data-source>
<properties>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"></property>
</properties>
</persistence-unit>
</persistence>
I hava two enum classes, one for gender and one for the flight service class, that I'm not listing here, but they are self-explanatory. Disregard all the comments within code; I do that for learning purposes.
Also, just so you'll know, all the previous non-JPA projects I had worked on worked perfectly fine when deployed, but none of them work now since I deleted Glassfish and re-installed it. NOTE: The Passenger object I'm trying to print and persist in this project's servlet (see servlet) is not being printed or saved in the database, so the problem lies in the server.
Thanks so much for taking the time! I'm really stuck:)