You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Richard Zowalla (Jira)" <ji...@apache.org> on 2022/09/08 05:29:00 UTC
[jira] [Assigned] (TOMEE-4032) Class cast Exception when undeploying application with @PostConstruct LifeCycle
[ https://issues.apache.org/jira/browse/TOMEE-4032?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Richard Zowalla reassigned TOMEE-4032:
--------------------------------------
Assignee: Richard Zowalla
> Class cast Exception when undeploying application with @PostConstruct LifeCycle
> -------------------------------------------------------------------------------
>
> Key: TOMEE-4032
> URL: https://issues.apache.org/jira/browse/TOMEE-4032
> Project: TomEE
> Issue Type: Bug
> Components: TomEE Core Server
> Affects Versions: 9.0.0-M8, 9.0.0-M9
> Reporter: Rob Leland
> Assignee: Richard Zowalla
> Priority: Major
> Fix For: 9.0.0-M9
>
> Attachments: Stack-9.0.0-M8.log, Stack-9.0.0-M9-Sept-02-2022-GitHash-68be80e.log
>
>
> 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|https://github.com/free2create/tomee/commit/68be80e60291468a1c196b503837921e59e64a87]) 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:*
> {code:java}
> ______________
> 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
> }
> }
>
> {code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)