Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
9.0.0-M8, 9.0.0.RC1
-
None
Description
A Class cast Exception is occurring , see attachment ,when stopping the container. The app is using using @PostConstruct & @EJB Annotation.
This does not occur with GlassFish, 6.2.5.
But does for:
ENV:
TomEE Plus & MicroProfile TC v10.0.21/TCE: 9.0.0-M8
With OpenJDK 11 & 17 Under Ubuntu 22.04.
( I also built a Nightly from 9/2/2022 GitHash: 68be80e) using java 17 and the same error Occurs, I have also attached stack trace for that also. The Line # are the same.
The Generated WAR WEB-INF/lib folder only has Derby Jars nothing else.
The Repo with this app is at:
https://github.com/free2create/pro-jakarta-persistence-jakarta-ee10
It uses maven to build and after building you would want to deploy:
examples/Chapter3/03-slsbLifecycleExample/servlet/target/ WAR file.
To reproduce you just need to deploy the app, and shutdown tomcat, no need to exercise the application.
But if you did want to test the app this is the URL:
http://localhost:8080/ch3-03-slsb-servlet-1.0.0/LoggerServlet
Relevant Code:
______________ LoggerBean.java: ______________ package examples.stateless; import jakarta.annotation.PostConstruct; import jakarta.ejb.Stateless; import java.util.logging.Logger; @Stateless public class LoggerBean { private Logger logger; @PostConstruct private void init() { logger = Logger.getLogger("notification"); } public void logMessage(String message) { logger.info(message); } } _____________ LoggerServlet.java _____________ package examples.servlet; import java.io.IOException; import java.io.PrintWriter; import javax.naming.InitialContext; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.annotation.WebServlet; import jakarta.ejb.EJB; import examples.stateless.LoggerBean; @WebServlet(name="LoggerServlet", urlPatterns="/LoggerServlet") public class LoggerServlet extends HttpServlet { private final String TITLE = "Chapter 3: Stateless Session Bean Lifecycle Example"; private final String DESCRIPTION = "This example demonstrates the basic use of lifecycle callbacks to initialize a Stateless Session Bean. </br>" + "Enter a and click 'Go'. This will trigger a servlet client that talks " + "to a Stateless Session Bean to log a message."; @EJB LoggerBean logger; public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); printHtmlHeader(out); // if there was a message submitted, log it String message = request.getParameter("message"); if (message != null) { // use the logger bean to log a message logger.logMessage(message); out.println("Message '" + message + "' sent to logger. " + "See the output on the server console or the log file at <SERVER_ROOT>/glassfish/domains/domain1/logs/server.log."); } printHtmlFooter(out); } private void printHtmlHeader(PrintWriter out) throws IOException { //Code Deleted } private void printHtmlFooter(PrintWriter out) throws IOException { //Code Deleted } }