bitnami / charts

Bitnami Helm Charts
https://bitnami.com
Other
8.92k stars 9.18k forks source link

Jasperreports email setting 'mail.smtp.starttls.enable' gets lost after restart #6067

Closed bjsee closed 1 year ago

bjsee commented 3 years ago

Jasperreports chart version: 10.2.4 (first try with older version 8.0.3 - same behaviour) Following settings:

jasperreportsEmail: *****
smtpEmail: *****
smtpHost: smtp.office365.com
smtpPort: 587
smtpUser: ******
smtpPassword: ******
smtpProtocol: smtp

When I deploy helm chart for first time everything works as expected, so if I execute a scheduled report the report is sent to my mail account as configured. If jasperreports gets restartet for some reason, the report execution job fails with following error message:

com.sun.mail.smtp.SMTPSendFailedException: 451 5.7.3 STARTTLS is required to send mail [PR2P264CA0013.FRAP264.PROD.OUTLOOK.COM]
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2358)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1823)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1300)

I think the reason for this is because file /bitnami/tomcat/data/jasperserver/WEB-INF/applicationContext-report-scheduling.xml gets changed after restart:

value after first deployment:

    <bean id="reportSchedulerMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl" lazy-init="true">
        <property name="host" value="${report.scheduler.mail.sender.host}"/>
        <property name="username" value="${report.scheduler.mail.sender.username}"/>
        <property name="password" value="${report.scheduler.mail.sender.password}"/>
        <property name="protocol" value="${report.scheduler.mail.sender.protocol}"/>
        <property name="port" value="${report.scheduler.mail.sender.port}"/>
        <property name="javaMailProperties">
            <props>
                <prop key="mail.smtp.sendpartial">true</prop>
                <prop key="mail.smtp.auth">true</prop>
                <prop key="mail.smtp.starttls.enable">true</prop>
            </props>
        </property>
    </bean>

the file is generated at startup as I can see via shell: -rw-r--r-- 1 root root 31278 Apr 11 11:23 applicationContext-report-scheduling.xml

If jasperreports is somehow restarted the file has a different timestamp: -rw-r--r-- 1 root root 31227 Aug 7 2020 applicationContext-report-scheduling.xml and following mail settings:

<bean id="reportSchedulerMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl" lazy-init="true">
        <property name="host" value="${report.scheduler.mail.sender.host}"/>
        <property name="username" value="${report.scheduler.mail.sender.username}"/>
        <property name="password" value="${report.scheduler.mail.sender.password}"/>
        <property name="protocol" value="${report.scheduler.mail.sender.protocol}"/>
        <property name="port" value="${report.scheduler.mail.sender.port}"/>
        <property name="javaMailProperties">
            <props>
                <prop key="mail.smtp.sendpartial">true</prop>
                <prop key="mail.smtp.auth">false</prop>
            </props>
        </property>
    </bean>

So the last property setting for javaMailProperties is somehow lost and now no STARTTLS is sent. I can only fix this by completely deleting the service including db via helm delete jasperreports. Sadly I also have to delete the pvc for mariadb because it cannot start otherwise (maybe another bug?).

What I tried:

I saw that the only directory which is permanently persisted is /bitnami/jasperreports so I thought that creating a persistent volume for /opt/bitnami/jasperreports/WEB-INF would help cause this is where the WEB-INF folder is finally linked to. But it makes no difference, it seems to me that all files are removed and newly created.

alvneiayu commented 3 years ago

hi @bjsee

I can reproduce the issue. Thanks to report the issue. I created an internal task and added it to the backlog. I am not able to give you an ETA. We will update this thread once we have news.

Álvaro

alvneiayu commented 3 years ago

hi @bjsee

I included a patch inside the docker image. In the next release, the issue must be fixed. Let me know if you have still problems.

Thanks for your time

Álvaro

bjsee commented 3 years ago

Hi @alvneiayu

thank you! Just for my interest: Do you have a link to the patch?

Björn

alvneiayu commented 3 years ago

hi @bjsee

I can not share with you a link to the patch because this is an internal repository. We are migrating the dockers to bash but right now Jasperreports is not in this format right now. The problem was that we are doing different postinstall actions if the persist storage is already mounted. So the first creation of the pod you can see that the issue is not present and if you recreate the pod, you can see the issue.

I think that the image is already release. Let me know if you can reproduce the problem or now it is fixed.

Thanks for your time

Álvaro

bjsee commented 3 years ago

Hi @alvneiayu

I tried the new release and now it works! Thank you very much!

Björn

bjsee commented 1 year ago

Hi,

it seems that the bug reoccured after updating our JR version.

Docker Image: docker.io/bitnami/jasperreports:8.2.0-debian-11-r6 Helm-Chart Version: jasperreports-15.1.2

Same behavior as described two years ago:

After initial deployment of JR the /bitnami/tomcat/webapps/jasperserver/WEB-INF/applicationContext-report-scheduling.xmlcontains following mail-settings:

<bean id="reportSchedulerMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl" lazy-init="true">
    <property name="host" value="${report.scheduler.mail.sender.host}"/>
    <property name="username" value="${report.scheduler.mail.sender.username}"/>
    <property name="password" value="${report.scheduler.mail.sender.password}"/>
    <property name="protocol" value="${report.scheduler.mail.sender.protocol}"/>
    <property name="port" value="${report.scheduler.mail.sender.port}"/>
    <property name="javaMailProperties">
      <props>
        <prop key="mail.smtp.sendpartial">true</prop>
        <prop key="mail.smtp.auth">true</prop>
        <prop key="mail.smtp.starttls.enable">true</prop>
        <prop key="mail.smtp.ssl.protocols">TLSv1.2</prop>
      </props>
    </property>
  </bean>

When restarting JR the settings are changed to:

    <bean id="reportSchedulerMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl" lazy-init="true">
        <property name="host" value="${report.scheduler.mail.sender.host}"/>
        <property name="username" value="${report.scheduler.mail.sender.username}"/>
        <property name="password" value="${report.scheduler.mail.sender.password}"/>
        <property name="protocol" value="${report.scheduler.mail.sender.protocol}"/>
        <property name="port" value="${report.scheduler.mail.sender.port}"/>
        <property name="javaMailProperties">
            <props>
                <prop key="mail.smtp.sendpartial">true</prop>
                <prop key="mail.smtp.auth">false</prop>
            </props>
        </property>
    </bean>

This will again result in following error:

2023-07-27T06:04:04,011 ERROR SecureExceptionHandlerImpl,JasperServerScheduler_Worker-1:125 - Auf dem Server ist ein Fehler auf │
│ ; message exception details (1) are:                                                                                            │
│ Failed message 1:                                                                                                               │
│ com.sun.mail.smtp.SMTPSendFailedException: 451 5.7.3 STARTTLS is required to send mail [FR2P281CA0084.DEUP281.PROD.OUTLOOK.COM  │
│                                                                                                                                 │
│     at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2358)                                                │
│     at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1823)                                                        │
│     at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1300)                                                     │
│     at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:465)                                 │
│     at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:361)                                   │
│     at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:356)                                   │
│     at com.jaspersoft.jasperserver.api.engine.scheduling.quartz.ReportExecutionJobMailNotificationImpl.sendMailNotification(Rep │
│     at com.jaspersoft.jasperserver.api.engine.scheduling.quartz.ReportExecutionJob.executeAndSendReport(ReportExecutionJob.java │
│     at com.jaspersoft.jasperserver.api.engine.scheduling.quartz.ReportExecutionJob.execute(ReportExecutionJob.java:324)         │
│     at org.quartz.core.JobRunShell.run(JobRunShell.java:202)                                                                    │
│     at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) 
jotamartos commented 1 year ago

Hi @bjsee,

Sorry for the delay and thank you for reporting this. I could reproduce the issue using the Bitnami JasperReports containers and I'm trying to obtain more information now.

jotamartos commented 1 year ago

Hi @bjsee,

The container was just updated with the change to fix this issue. You can wait for the chart to be updated or use this new image to deploy the solution.

Let us know if everything works as expected after that.

Thanks

jotamartos commented 1 year ago

Just a quick note to let you know that the chart was also updated

https://github.com/bitnami/charts/pull/18244

bjsee commented 1 year ago

Hi @jotamartos,

this works for me :) Thanks!