Hi all
i just implemented the Embedded
Tomcat in our Webapplication. To do that i wrote the following code which starts the Tomcat Server:
Embedded mbedTC5 = new Embedded();
MemoryRealm memRealm = new MemoryRealm();
memRealm.setPathname("C:\\ndbjs\\workspace\\NAJS_Re5\\WebContent\\WEB-INF\\conf\\tomcat-users.xml");
mbedTC5.setRealm(memRealm);
Engine baseEngine = mbedTC5.createEngine();
baseEngine.setName("DIK NDBJS");
baseEngine.setDefaultHost("localhost");
Host baseHost = mbedTC5.createHost("localhost", "C:\\ndbjs\\workspace\\NAJS_Re5\\WebContent");
baseEngine.addChild(baseHost);
Context ndbjsCtx = mbedTC5.createContext("/ndbjs", "");
baseHost.addChild(ndbjsCtx);
// add new Engine to set of
// Engine for embedded server
mbedTC5.addEngine(baseEngine);
Connector httpConnector = mbedTC5.createConnector((java.net.InetAddress) null, 8080, false);
mbedTC5.addConnector(httpConnector);
try {
mbedTC5.start();
} catch (org.apache.catalina.LifecycleException ex) {
ex.printStackTrace();
}
The server is started correctly. But when I try to access my Web-Application i get the following error:
2005-12-27 11:38:08,886 WARN Unexpected error forwarding to login page in (FormAuthenticator.java:317)
java.lang.NullPointerException
at org.apache.catalina.authenticator.FormAuthenticator.forwardToLoginPage(FormAuthenticator.java:314)
at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:242)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
I'm using Tomcat 5.5.12 and the file tomcat-user.xml to authenticate the users.
<tomcat-users>
<role rolename="ndbjsadmin"/>
<user name="PJWK11" password="" roles="tomcat,ndbjsadmin" />
</tomcat-users>
Further there are roles defined in the web.xml file:
<security-constraint>
<web-resource-collection>
<web-resource-name>DIK NDBJS</web-resource-name>
<description> accessible by authorised users </description>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<description>These are the roles who have access</description>
<role-name>ndbjsuser</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>DIK NDBJS</web-resource-name>
<description> accessible by authorised users </description>
<url-pattern>/admin</url-pattern>
</web-resource-collection>
<auth-constraint>
<description>These are the roles who have access</description>
<role-name>ndbjsadmin</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>DIK NDBJS</web-resource-name>
<description> accessible all users </description>
<url-pattern>/login</url-pattern>
</web-resource-collection>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/error.jsp</form-error-page>
</form-login-config>
</login-config>
<security-role>
<description>an ndbjsuser</description>
<role-name>ndbjsuser</role-name>
</security-role>
<security-role>
<description>proxool
servlet admin</description>
<role-name>ndbjsadmin</role-name>
</security-role>
Any help would be appreciated.
Kind regards
Angela