yoshiro_hagiy****@mnec*****
yoshiro_hagiy****@mnec*****
2010年 1月 12日 (火) 10:29:10 JST
矢野 様 ユーザの認証に失敗した場合のエラーメッセージ、以下のとおりになります。 (ユーザ欄やパスワード欄が空の場合も同じエラーメッセージです。) メール長くなりますが、ソースも添付します。 何かアドバイス頂ければ幸いです。 よろしくお願い致します。 萩谷 ------------------------------------------------------------------------ Error Message ------------------------------------------------------------------------ Unexpected RuntimeException WicketMessage: Method onFormSubmitted of interface org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component [MarkupContainer [Component id = form]] threw an exception Root cause: java.lang.NullPointerException at org.apache.wicket.resource.loader.PackageStringResourceLoader.loadStringResource(PackageStringResourceLoader.java:81) at org.apache.wicket.resource.loader.ComponentStringResourceLoader.loadStringResource(ComponentStringResourceLoader.java:246) at org.apache.wicket.Localizer.getStringIgnoreSettings(Localizer.java:241) at org.apache.wicket.Localizer.getString(Localizer.java:313) at org.apache.wicket.Localizer.getString(Localizer.java:138) at org.apache.wicket.markup.html.form.FormComponent$MessageSource.getString(FormComponent.java:223) at org.apache.wicket.markup.html.form.FormComponent$MessageSource.getMessage(FormComponent.java:164) at org.apache.wicket.validation.ValidationError.getErrorMessage(ValidationError.java:157) at org.apache.wicket.markup.html.form.FormComponent.error(FormComponent.java:677) at org.apache.wicket.markup.html.form.FormComponent.reportRequiredError(FormComponent.java:1587) at org.apache.wicket.markup.html.form.FormComponent.validateRequired(FormComponent.java:1578) at org.apache.wicket.markup.html.form.FormComponent.validate(FormComponent.java:1189) at org.apache.wicket.markup.html.form.Form$22.validate(Form.java:2125) at org.apache.wicket.markup.html.form.Form$ValidationVisitor.formComponent(Form.java:171) at org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPostOrderHelper(FormComponent.java:441) at org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPostOrderHelper(FormComponent.java:428) at org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPostOrder(FormComponent.java:400) at org.apache.wicket.markup.html.form.Form.visitFormComponentsPostOrder(Form.java:1200) at org.apache.wicket.markup.html.form.Form.validateComponents(Form.java:2117) at org.apache.wicket.markup.html.form.Form.validate(Form.java:2097) at org.apache.wicket.markup.html.form.Form.process(Form.java:972) at org.apache.wicket.markup.html.form.Form.process(Form.java:922) at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:887) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:182) at org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73) at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92) at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250) at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329) at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428) at org.apache.wicket.RequestCycle.request(RequestCycle.java:545) at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479) at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) at java.lang.Thread.run(Thread.java:619) Complete stack: org.apache.wicket.WicketRuntimeException: Method onFormSubmitted of interface org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component [MarkupContainer [Component id = form]] threw an exception at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:193) at org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73) at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92) at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250) at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329) at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428) at org.apache.wicket.RequestCycle.request(RequestCycle.java:545) at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479) java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:182) at org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73) at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92) at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250) at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329) at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428) at org.apache.wicket.RequestCycle.request(RequestCycle.java:545) at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479) Page [Page class = AuthSignInPage, id = 4, version = 0]: # Path Size Type Model Object 1 error 1.6K org.apache.wicket.markup.html.panel.FeedbackPanel 2 error:feedbackul 3.7K org.apache.wicket.markup.html.WebMarkupContainer 3 error:feedbackul:messages 3.7K org.apache.wicket.markup.html.list.ListView [] 4 form 3.7K org.apache.wicket.markup.html.form.Form [Page class = AuthSignInPage, id = 4, version = 0] 5 form:password 1.1K org.apache.wicket.markup.html.form.PasswordTextField 6 form:submit1 3.7K org.apache.wicket.markup.html.form.Button 7 form:username 1K org.apache.wicket.markup.html.form.TextField ------------------------------------------------------------------------ ------------------------------------------------------------------------ AuthApp.java ------------------------------------------------------------------------ import org.apache.wicket.Application; import org.apache.wicket.Page; import org.apache.wicket.RestartResponseAtInterceptPageException; import org.apache.wicket.authentication.AuthenticatedWebApplication; import org.apache.wicket.authentication.AuthenticatedWebSession; import org.apache.wicket.markup.html.WebPage; public class AuthApp extends AuthenticatedWebApplication{ @Override public String getConfigurationType() { return Application.DEVELOPMENT; } @Override protected void init() { super.init(); getMarkupSettings().setDefaultMarkupEncoding("UTF-8"); getRequestCycleSettings().setResponseRequestEncoding("UTF-8"); } @Override protected Class<? extends AuthenticatedWebSession> getWebSessionClass() { return AuthAppSession.class; } @Override protected Class<? extends WebPage> getSignInPageClass() { return AuthSignInPage.class; } @Override public Class<? extends Page> getHomePage() { return IndexPage.class; } @Override protected void onUnauthorizedPage(Page page) { throw new RestartResponseAtInterceptPageException(ErrorPage.class); } } ------------------------------------------------------------------------ ------------------------------------------------------------------------ AuthAppSession.java ------------------------------------------------------------------------ import java.util.HashMap; import org.apache.wicket.Request; import org.apache.wicket.authentication.AuthenticatedWebSession; import org.apache.wicket.authorization.strategies.role.Roles; public class AuthAppSession extends AuthenticatedWebSession { private Roles roles; private HashMap<String, String> map; public AuthAppSession(Request request) { super(request); map = new HashMap<String, String>(); map.put(Roles.ADMIN, "admin"); map.put(Roles.USER, "user"); } @Override public boolean authenticate(String username, String password) { if (map.get(username) != null && map.get(username).equals(password)) { roles = new Roles(username); return true; } else { roles = null; return false; } } @Override public Roles getRoles() { return roles; } } ------------------------------------------------------------------------ ------------------------------------------------------------------------ AuthSignInPage.html ------------------------------------------------------------------------ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Sign in</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <h1>Sign in Page.</h1> <span wicket:id="signInPanel"/> </body> </html> ------------------------------------------------------------------------ ------------------------------------------------------------------------ AuthSignInPage.java ------------------------------------------------------------------------ import org.apache.wicket.authentication.pages.SignInPage; public class AuthSignInPage extends SignInPage { public AuthSignInPage(){ super(); } } ------------------------------------------------------------------------ ------------------------------------------------------------------------ IndexPage.html ------------------------------------------------------------------------ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>IndexPage</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <h1>Index Page.</h1> <p>This page for logined user.</p> <p><a wicket:id="link">Admin Page</a></p> <p><a wicket:id="link2">Logout</a></p> </body> </html> ------------------------------------------------------------------------ ------------------------------------------------------------------------ IndexPage.java ------------------------------------------------------------------------ import org.apache.wicket.authorization.strategies.role.Roles; import org.apache.wicket.authorization.strategies.role.annotations.AuthorizeInstantiation; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.link.Link; @AuthorizeInstantiation({Roles.ADMIN, Roles.USER}) public class IndexPage extends WebPage { public IndexPage() { Link<String> link = new Link<String>("link") { @Override public void onClick() { this.setResponsePage(AdminPage.class); } }; this.add(link); Link<String> link2 = new Link<String>("link2") { @Override public void onClick() { this.setResponsePage(AuthSignOutPage.class); } }; this.add(link2); } } ------------------------------------------------------------------------