Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AS2ReceiveServlet startup issue in Spring Boot application if servlet is configured programmatically #96

Closed
yaskovdev opened this issue Oct 3, 2019 · 7 comments
Assignees
Labels

Comments

@yaskovdev
Copy link

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 by this.m_aStatusMgr = ServletStatusManager.getInstance(); line from the AbstractXServlet. The issue is reproducible when the servlet is configured programmatically because in this case instantiation of the servlet happens before the AS2WebAppListener 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 to init method permanently to make possible to use the servlet with Spring Boot?

@phax phax self-assigned this Oct 3, 2019
@phax phax added the bug label Oct 3, 2019
phax added a commit that referenced this issue Oct 4, 2019
@phax
Copy link
Owner

phax commented Oct 4, 2019

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.

phax added a commit that referenced this issue Oct 4, 2019
@phax
Copy link
Owner

phax commented Oct 4, 2019

@yaskovdev do you mind I take your as2-sandbox as a spring boot template into the as2-lib?

@yaskovdev
Copy link
Author

@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.

@yaskovdev
Copy link
Author

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.

@phax
Copy link
Owner

phax commented Oct 5, 2019

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?

@yaskovdev
Copy link
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. :)

phax added a commit that referenced this issue Oct 8, 2019
@phax
Copy link
Owner

phax commented Oct 8, 2019

Initial version is in. An @AutoWired ServletContext sc; did the trick so no change was needed in the base config

@phax phax closed this as completed Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants