Hi to All
I have a DeskTop B4J app running in windows, that sends users emails using mailgun mail service and it used to wirk ok.
I upgraded B4J to 9.50 and compile the app, but now it gives an error in SMTP.To.Clear instruction.
Have anyone experienced same problem ? Thanks in advance for any help.
I'm using Open Java, jdk-11.0.12
My code:
In this function I'm adding recipients, but first I try to Clear existing ones
Running in debug mode it stops and gives this message in log window
Cannot get methods of class: null, disabling cache.
Error occurred on line: 313 (Main)
java.lang.NullPointerException
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at anywheresoftware.b4a.shell.Shell$MethodCache.getMethod(Shell.java:867)
at anywheresoftware.b4a.shell.Shell.getMethod(Shell.java:539)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:670)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:240)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:64)
at b4j.enviacorreos.main._envia_correo_html(main.java:2667)
at b4j.enviacorreos.main$ResumableSub_Lee_Correo_A_Enviar.resume(main.java:1638)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
at anywheresoftware.b4a.shell.Shell.runGoodChain(Shell.java:366)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:181)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:156)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at anywheresoftware.b4a.keywords.Common$3.run(Common.java:1119)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
Thanks in advance !
I have a DeskTop B4J app running in windows, that sends users emails using mailgun mail service and it used to wirk ok.
I upgraded B4J to 9.50 and compile the app, but now it gives an error in SMTP.To.Clear instruction.
Have anyone experienced same problem ? Thanks in advance for any help.
I'm using Open Java, jdk-11.0.12
My code:
Initialize of SMTP:
Sub Conecta_Servidor_Correo As ResumableSub
'...............................................................................................
' Configuramos del Servidor de Correo
'...............................................................................................
Log(" - Funcion de Conecta Servidor Correo")
Select Servidor_Correo_Usar
Case 1
SMTP1.Initialize( "smtp.mailgun.org", 587, "user1", "password1", "SMTP")
Log(" - Cuenta de Correo: gbp")
Case 2
SMTP1.Initialize( "smtp.mailgun.org", 587, "user2", "password2", "SMTP")
Log(" - Cuenta de Correo: sac")
End Select
'...............................................................................................
' Seguridad del Servidor de Correos
'...............................................................................................
SMTP1.UseSSL = True
SMTP1.StartTLSMode = True
SMTP1.AuthMethod = SMTP1.AUTH_LOGIN
Log_Datos.Add("Conectado al Servidor de Correos... " & DateTime.Date(DateTime.Now) )
Log(" - Saliendo de Funcion de Conecta Servidor Correo")
Return Null
End Sub
In this function I'm adding recipients, but first I try to Clear existing ones
Create html mail message:
Sub Envia_Correo_html As ResumableSub
'...............................................................................................
' Funcion que leera los Datos del Correo para su envío
'...............................................................................................
Dim Cuenta_Origen As String
'Dim SMTP1 As SMTP
Log(" - Entrando a Envia_Correo_html")
Log(CRLF & " - Enviando Correo....")
'...............................................................................................
' Limpiamos el recipiente y agregamos Destinatarios
'...............................................................................................
SMTP1.To.Clear <------- Error
'...............................................................................................
' Agregamos a los Destinatarios
'...............................................................................................
If lst_Lista_Destinatarios.Size > 0 Then
For i = 0 To lst_Lista_Destinatarios.Size - 1
SMTP1.To.Add(lst_Lista_Destinatarios.Get(i))
Next
Else
Return Null
End If
'...............................................................................................
' Datos adicionales
'...............................................................................................
SMTP1.Subject = mAsunto
SMTP1.HtmlBody = True
sMensaje_Correo.Initialize
'...............................................................................................
' Prepara el Mensaje
'...............................................................................................
Select Servidor_Correo_Usar
Case 1, 0
Cuenta_Origen = "GBP"
Case 2
Cuenta_Origen = "SAC"
Case Else
Cuenta_Origen = "Sistemas"
End Select
sMensaje_Correo.Append($"<!DOCTYPE html>
<html>
<body>
<h2 style="color:DodgerBlue;">${Cuenta_Origen}</h2>
<!--<h2 style="color:DodgerBlue;"></h2>-->
<hr>
<p>${sLinea_Mensajes_html}
<hr>
** Correo Generado Automaticamente **
<br>
</p>
</body>
</html>"$)
SMTP1.Body = ""
SMTP1.Body = sMensaje_Correo
' Log("************************************************************")
' Log("Body: ")
' Log(SMTP1.Body)
' Log("************************************************************")
'....................................................
' Adjuntamos el Archivo si hay indicacion
'....................................................
If mNombre_Archivo_Adjunto <> Null Then
Log(" - Verificando Archivo Adjunto")
Log("Archivo adjunto en tabla: " & mNombre_Archivo_Adjunto )
If IsEmptyString(mNombre_Archivo_Adjunto) = False Then
If File.Exists( mRuta_Archivo_Adjunto , mNombre_Archivo_Adjunto ) Then
Log(" - Enviando Archivo Adjunto: " & mRuta_Archivo_Adjunto & mNombre_Archivo_Adjunto)
Log_Datos.Add(" - Se adjunta archivo: " & mRuta_Archivo_Adjunto &mNombre_Archivo_Adjunto )
SMTP1.AddAttachment( mRuta_Archivo_Adjunto, mNombre_Archivo_Adjunto)
Else
Log_Datos.Add(" - No se encontro el archivo adjunto: " & mRuta_Archivo_Adjunto & mNombre_Archivo_Adjunto )
Log(" - No se encontro el archivo adjunto: " & mRuta_Archivo_Adjunto & mNombre_Archivo_Adjunto )
End If
Else
Log_Datos.Add(" - No se especifico archivo para adjuntar")
Log(" - No se especifico archivo para adjuntar")
End If
Else
Log(" No se indico adjuntar archivo")
End If
'...................................................................
' Intentamos enviar el correo
'...................................................................'
Log(" - Enviando Correo para: " & mIdentificador_Id )
Try
SMTP1.Send
Catch
'Log_Datos.Add(" - Enviando Correo de: " & Destinatario & ", Folio: " & Solicitud_ID & ", Usuario: " & mUsuario )
' Solo se muestra el primer Correo
Log(" *** Error Enviando Correo de: " & SMTP1.To.Get(0) )
End Try
Log("Finalizando Envio de Correo .......................................................")
Return Null
End Sub
Cannot get methods of class: null, disabling cache.
Error occurred on line: 313 (Main)
java.lang.NullPointerException
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at anywheresoftware.b4a.shell.Shell$MethodCache.getMethod(Shell.java:867)
at anywheresoftware.b4a.shell.Shell.getMethod(Shell.java:539)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:670)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:240)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:64)
at b4j.enviacorreos.main._envia_correo_html(main.java:2667)
at b4j.enviacorreos.main$ResumableSub_Lee_Correo_A_Enviar.resume(main.java:1638)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
at anywheresoftware.b4a.shell.Shell.runGoodChain(Shell.java:366)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:181)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:156)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at anywheresoftware.b4a.keywords.Common$3.run(Common.java:1119)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
Thanks in advance !