Hi all, I want to access a Servlet that's defined in web.xml (per my teams current implementation). It's not a Spring managed bean, instead it's defined in a jar that my team uses across a number of non-Spring web applications, so all I have is the compiled jar. Note the "NonBeanServlet" in web.xml (see below). In my web app, I can normally call the static methods on NonBeanServlet like this:

String someString = NonBeanServlet.getSomeString();

...so long as I do so after the application is fully started. My problem is, I wan to call the method during startup. I'm thinking this has something to do with the HTTP request, session, etc. that propagate through my the class that call NonBeanServlet.getSomeString(); is not working the same during initialization.


Code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
	version="2.4">

	
	<servlet>
		<servlet-name>NonBeanServlet</servlet-name>
		<servlet-class>com.mycompany.package.NonBeanServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>NonBeanServlet</servlet-name>
		<url-pattern>/NonBeanServlet</url-pattern>
	</servlet-mapping> 
		
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/spring/*-config.xml</param-value>
	</context-param>
	<context-param>
		<param-name>log4jConfigLocation</param-name>
		<param-value>/WEB-INF/classes/log4j.xml</param-value>
	</context-param>
	<filter>
		<filter-name>springSecurityFilterChain</filter-name>
		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>springSecurityFilterChain</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<listener>
		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
	</listener>
	
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<listener>
		<listener-class>flex.messaging.HttpFlexSession</listener-class>
	</listener>

	<servlet>
		<servlet-name>flex</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<load-on-startup>2</load-on-startup>
	</servlet>
	
	<!-- 
		Defined per: http://static.springsource.org/spring-flex/docs/1.5.0.M2/reference/html/#configuration-mapping 
	-->
	<servlet-mapping>
		<servlet-name>flex</servlet-name>
		<url-pattern>/messagebroker/*</url-pattern>
	</servlet-mapping>
	
	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
	</welcome-file-list>
</web-app>

Any ideas on how I can make this work? The problem is a NullPointerException that happens in the NonBeanServlet while trying to get the connection like so:

String host = connection.getHost();
String port = connection.getPort();

Thanks in advance!