I have a spring app for some reasons, I have a standard servlet and I'm able to reach some spring beans (I know that this is not ideal, and I would like to find something better in the future.)
in Web.xml
& lt; Servlet & gt; & Lt; Servlet-name & gt; MVC-Despatcher & lt; / Servlet-name & gt; & Lt; Servlet category & gt; Org.springframework.web.servlet.DispatcherServlet & lt; / Servlet category & gt; & Lt; Load-On-Startup & gt; 1 & lt; / Load-on-startup & gt; & Lt; Async-supported & gt; True & lt; / Async-supported & gt; & Lt; / Servlet & gt; & Lt; Servlet-mapping & gt; & Lt; Servlet-name & gt; MVC-Despatcher & lt; / Servlet-name & gt; & Lt; URL pattern & gt; / & Lt; / URL pattern & gt; & Lt; / Servlet-mapping & gt; & Lt; Servlet & gt; & Lt; Details & gt; Tunnel servlet. & Lt; / Description & gt; & Lt; Servlet-name & gt; Tunnel & lt; / Servlet-name & gt; & Lt; Servlet category & gt; Com.something.GuacamoleController & lt; / Servlet-class & gt; & Lt; / Servlet & gt; & Lt; Servlet-mapping & gt; & Lt; Servlet-name & gt; Tunnel & lt; / Servlet-name & gt; & Lt; URL pattern & gt; / Path & lt; / URL pattern & gt; & Lt; / Servlet-mapping & gt;
and GuacamoleController
extends to the public class GuacamoleController GuacamoleHTTPTunnelServlet {@Override Protects GuacamoleTunnel doConnect (HttpServletRequest Request) GuacamoleException throws {WebApplicationContext Web Application Contex = RequestContextUtils.getWebApplicationContext (requested); [...]}}
but it is throwing this error:
java.lang.IllegalStateException: No WebApplicationContext found: Not DispatcherServlet In request?
How can I make a Dispatcher Serial request to this matter?
I need a web application reference, so I can manually access the example of a service with the GetBean method
You are not in the context of a dispatcher service
, you are rolling in your own servlet
implementation
You can be in the context of a context-loader listener
. Use
WebApplicationContext Web Applications CONTACTS = Web Application Context UT .getRequiredWebApplicationContext (request.getServletContext ()); To get WebApplicationContext
loaded ContextLoaderListener
. If it does not exist then the method will throw exceptions.
Comments
Post a Comment