Closed yaskovdev closed 4 years ago
Thanks for the input. Unfortunately I am not an expert in Spring Boot, but I think I understand the issue.
I moved the initialization stuff in the AS2ReceiveServlet
to the GenericServlet.init()
override method.
Additionally I added static init/destroy methods to AS2WebAppListener
so that you can call them without having the need to use the ServletContextListener
infrastructure.
~Based on this request I will also extend AbstractXServlet
to save the ServletConfig
from init
so that you can access it later on from init()
~ (it's already in GenericServlet :) )
Based on these changes you can create a derived Servlet that does AS2WebAppListener.staticInit (getServletConfig ().getServletContext ())
before super.init()
and similar in shutdown.
@yaskovdev do you mind I take your as2-sandbox as a spring boot template into the as2-lib?
@phax, thank you for the quick response and fix. As for the template, I do not mind at all, feel free to use it wherever it may be useful.
I believe that in order to fully resolve the issue changes in AbstractXServlet
are needed. Because currently its constructor calls the ServletStatusManager.getInstance()
method and the method requires the AS2WebAppListener.staticInit(getServletConfig().getServletContext())
to finish in order to do its job.
Okay, I will check this out. Do I have the permission to publish your code under the Apache 2 license, stating you as the original author?
Thank you.
As for the publishing, of course you have. "Code" sounds too much for this example, to be honest, given that I just took the Spring Boot template and used the guide you created to configure the AS2ReceiveServlet
. :)
Initial version is in. An @AutoWired ServletContext sc;
did the trick so no change was needed in the base config
The project that reproduces the issue is here. The error is the same as in this issue (No global scope object has been set!), however the
AS2WebAppListener
is in place.The exception happens on
AS2ReceiveServlet
instantiation and is caused bythis.m_aStatusMgr = ServletStatusManager.getInstance();
line from theAbstractXServlet
. The issue is reproducible when the servlet is configured programmatically because in this case instantiation of the servlet happens before theAS2WebAppListener
has a chance to do its job.As a temporary solution I moved the problematic line of code from the constructor to the
init
method. Would it make more sense to move this line toinit
method permanently to make possible to use the servlet with Spring Boot?