Uploaded image for project: 'EJBCA'
  1. EJBCA
  2. ECA-7379

Regression: throwing checked Exceptions from postConstruct is not allowed in JEE spec

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: EJBCA 7.0.0
    • Component/s: None
    • Labels:
      None
    • Sprint:
      EJBCA Sprint 21 Team Alice

      Description

      postConstruct is not allowed to throw checked exceptions.

      "throw Exception" is considered bad practice, i.e. never throw the "catch all" exception.
      On this case it comes from the underlying old code that is the cause of the catch all Exception throwing (EjbcaWebBean.initialize). In general that should be fixed to not throw Exception (but the specific exceptions instead)

      GlobalConfiguration.initialize may be a bit tricky in postConstruct? Since there are things like AuthenticationFailedException, which needs to be handled with nice messages...a bit tricky.
      I'm thinking that getEjbcaWebBean().initialize must be handled more centrally, per session, in a place where authentication failures can be handled nicely maybe?

      The specific warnings by JBoss EAP 7.1:

      16:33:08,507 WARN [org.jboss.weld.Validator] (MSC service thread 1-5) WELD-001471: Interceptor method postConstruct defined on class org.ejbca.ui.web.admin.cainterface.CAActivationMBean is not defined according to the specification. It should not throw java.lang.Exception, which is a checked exception.
       at org.ejbca.ui.web.admin.cainterface.CAActivationMBean.postConstruct(CAActivationMBean.java:65)
       StackTrace
      16:33:08,509 WARN [org.jboss.weld.Validator] (MSC service thread 1-5) WELD-001471: Interceptor method postConstruct defined on class org.ejbca.ui.web.admin.cainterface.CAFunctionsMBean is not defined according to the specification. It should not throw java.lang.Exception, which is a checked exception.
       at org.ejbca.ui.web.admin.cainterface.CAFunctionsMBean.postConstruct(CAFunctionsMBean.java:71)
       StackTrace
      16:33:08,511 WARN [org.jboss.weld.Validator] (MSC service thread 1-5) WELD-001471: Interceptor method postConstruct defined on class org.ejbca.ui.web.admin.AdminIndexMBean is not defined according to the specification. It should not throw java.lang.Exception, which is a checked exception.
       at org.ejbca.ui.web.admin.AdminIndexMBean.postConstruct(AdminIndexMBean.java:46)
       StackTrace
      16:33:08,514 WARN [org.jboss.weld.Validator] (MSC service thread 1-5) WELD-001471: Interceptor method initialize defined on class org.ejbca.ui.web.admin.certprof.CertProfilesBean is not defined according to the specification. It should not throw java.lang.Exception, which is a checked exception.
       at org.ejbca.ui.web.admin.certprof.CertProfilesBean.initialize(CertProfilesBean.java:113)
       StackTrace
      16:33:08,516 WARN [org.jboss.weld.Validator] (MSC service thread 1-5) WELD-001471: Interceptor method initialize defined on class org.ejbca.ui.web.admin.approval.ApprovalProfilesMBean is not defined according to the specification. It should not throw java.lang.Exception, which is a checked exception.
       at org.ejbca.ui.web.admin.approval.ApprovalProfilesMBean.initialize(ApprovalProfilesMBean.java:77)
       StackTrace
      16:33:08,520 WARN [org.jboss.weld.Validator] (MSC service thread 1-5) WELD-001471: Interceptor method initialize defined on class org.ejbca.ui.web.admin.approval.ApprovalProfileMBean is not defined according to the specification. It should not throw java.lang.Exception, which is a checked exception.
       at org.ejbca.ui.web.admin.approval.ApprovalProfileMBean.initialize(ApprovalProfileMBean.java:130)
       StackTrace

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hsunmark Henrik Sunmark
                Reporter:
                tomas Tomas Gustavsson
                Verified by:
                Tomas Gustavsson
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 1 day
                  1d
                  Remaining:
                  Time Spent - 6 hours, 10 minutes Remaining Estimate - 1 hour, 50 minutes
                  1h 50m
                  Logged:
                  Time Spent - 6 hours, 10 minutes Remaining Estimate - 1 hour, 50 minutes
                  6h 10m