JBoss 7.2 and Tapestry: can not access login url
suvha-ratnomazumder Feb 21, 2020 8:58 AMHello,
I am using JBoss 7.1 and Tapestry 5.3.8 and my project is working fine. Now I need to upgrade JBoss from 7.1 to 7.2. When I build war file and deploy in STANDALONE JBoss 7.2 it is working. But when I integrate JBoss 7.2 using eclipse for development the I got following error:
"
ERROR 2020-02-20 09:19:00,021 [default task-1] [org.apache.tapestry5.ioc.Registry] | Method net.atos.wlp.olw.gui.pages.user.Login.login() references component id 'loginForm' which does not exist. ERROR 2020-02-20 09:19:00,022 [default task-1] [org.apache.tapestry5.ioc.Registry] | Operations trace: ERROR 2020-02-20 09:19:00,022 [default task-1] [org.apache.tapestry5.ioc.Registry] | [ 1] Constructing instance of page class net.atos.wlp.olw.gui.pages.user.Login ERROR 2020-02-20 09:19:00,022 [default task-1] [com.awl.tapestry.owasp.services.internal.TapestryOverrides.owaspRequestExceptionHandler] | Owasp Exception Handler : an unexpected exception has occured org.apache.tapestry5.ioc.internal.OperationException: Method net.atos.wlp.olw.gui.pages.user.Login.login() references component id 'loginForm' which does not exist. at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.logAndRethrow(OperationTrackerImpl.java:121) at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:88) at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87) at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124) at org.apache.tapestry5.internal.pageload.PageLoaderImpl.loadPage(PageLoaderImpl.java:177) at $PageLoader_31e1f6e1f97.loadPage(Unknown Source) at org.apache.tapestry5.internal.services.PageSourceImpl.getPage(PageSourceImpl.java:104) at $PageSource_31e1f6e1f94.getPage(Unknown Source) at org.apache.tapestry5.internal.services.NonPoolingRequestPageCacheImpl.get(NonPoolingRequestPageCacheImpl.java:82) at $RequestPageCache_31e1f6e1f93.get(Unknown Source)
"
Login.java:
package net.atos.wlp.olw.gui.pages.user;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.apache.tapestry5.EventConstants;
import org.apache.tapestry5.annotations.AfterRender;
import org.apache.tapestry5.annotations.Import;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.beaneditor.Validate;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.Response;
import org.apache.tapestry5.services.Session;
import net.atos.wlp.olw.config.ConfigAccessor;
import net.atos.wlp.olw.datamodel.rmolw.RmOLWException;
import net.atos.wlp.olw.datamodel.rmolw.RmOlwManager;
import net.atos.wlp.olw.gui.Debug;
import net.atos.wlp.olw.gui.Info;
import net.atos.wlp.olw.gui.utils.AuditGuiMessages;
import net.atos.wlp.olw.gui.utils.PciSessionHandler;
import net.atos.xa.audit.AuditService;
import net.atos.xa.audit.AuditServiceProvider;
import net.atos.xa.rm.api.RMMaintainer;
import net.atos.xa.rm.api.user.UserSelector;
import net.atos.xa.rm.app.feature.accountstate.LockedByAdminException;
import net.atos.xa.rm.app.feature.calendar.AccessCalendarException;
import net.atos.xa.rm.app.feature.counter.BurntAuthenticationException;
import net.atos.xa.rm.app.feature.counter.CounterConfForUser;
import net.atos.xa.rm.app.feature.otp.OtpExpiredException;
import net.atos.xa.rm.app.feature.periodicchange.CredentialExpiredException;
@Import(stylesheet = "classpath:styles/Login.css")
public class Login {
@SessionState(create = false)
@Property
private String loginmessage;
@Property
private String loginMessageOutput;
@Inject
private Messages messages;
@Inject
private Request request;
@Inject
private Response response;
@Inject
private org.apache.tapestry5.services.Cookies cookie;
private Subject currentUser;
private RMMaintainer rm;
/**
* Use to store the current user login
*/
@Property
@Persist
@Validate("required")
private String userName;
@Inject
private RmOlwManager rmOLWManager;
/**
* Use to store the password of the current user
*/
@Property
@Validate("required")
private String password;
@Inject
private HttpServletRequest httpRequest;
@AfterRender
void afterRender() {
// we force a new session after each login
// see also discussion
// http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/change-session-id-after-login-td3217239.html
final Session session = request.getSession(false);
if (session != null) {
session.invalidate();
}
// I think this never worked - in the Jira it is described to use
// the configuration of tomcat!
final String jSessionId = cookie.readCookieValue("JSESSIONID");
// cookie.removeCookieValue("JSESSIONID");
final String path = request.getContextPath();
response.setHeader("SET-COOKIE", "JSESSIONID=" + jSessionId + "; path=" + path + "/; SECURE; HttpOnly");
}
public String getInstallInfo() {
// read the 'InstallationInfo' from the configuration file 'wlp-olw.xml'
return ConfigAccessor.getInstance().getConfig().getGeneral().getInstance().getInstallationInfo();
}
public String getVersionInfo() {
// read the 'showVersion' from the configuration file 'wlp-olw.xml'
final boolean showVersion = ConfigAccessor.getInstance().getConfig().getGeneral().getInstance().isShowVersion();
if (showVersion) {
return messages.get("common.version.text");
} else {
return "";
}
}
@OnEvent(value = EventConstants.SUCCESS, component = "loginForm")
Object login() {
/* Gets a non secured RMMaintainer */
rm = new RMMaintainer(false);
if (Debug.isDebugEnabled()) {
Debug.DEFAULT.format(this, "Login data are submitted...");
}
Class nextPage = null;
currentUser = SecurityUtils.getSubject();
final AuditService auditService = AuditServiceProvider.getAuditService();
final AuditGuiMessages auditMessages = auditService.getAuditor(AuditGuiMessages.class);
if (currentUser != null && !currentUser.isAuthenticated()) {
try {
final UserSelector userSelector = rm.user().select().withName(userName);
if (userSelector.get() != null) {
boolean isLockedByCounter = false;
final CounterConfForUser conf = userSelector.counter();
if (conf != null) {
final Integer counter = rm.user().select().withName(userName).counter().getCounter();
if (counter != null) {
isLockedByCounter = counter <= 0;
}
}
if (isLockedByCounter) {
throw new BurntAuthenticationException("Locked by counter");
}
if (rm.user().select().withName(userName).accountState().getAccountState()) {
throw new LockedByAdminException("User locked by admin");
}
final UsernamePasswordToken token = new UsernamePasswordToken(userName, password);
final org.apache.shiro.mgt.SecurityManager sm = SecurityUtils.getSecurityManager();
// currentUser.getSession().getId()
currentUser.login(token);
if (currentUser.isAuthenticated()) {
/* Attention: Here the API is not consistent (or I did not find the correct entry point)
* We can get the principal which is a unique identifier for the user but only as an Object.
* At other places in the API we get an Principal object and the call the UUID method.
* It seems that we are here always getting the String of the UUID as return object.
*/
String prnUuid = (String) currentUser.getPrincipal();
try {
rmOLWManager.updateLastLogin(prnUuid, request.getRemoteHost());
} catch (RmOLWException e) {
net.atos.wlp.olw.gui.Error.E0064.format(this, prnUuid, e);
}
nextPage = net.atos.wlp.olw.gui.pages.Index.class;
if (userSelector.otp().isOtp()) {
loginmessage = "Your password is valid only for this session. Please change it immediately.";
nextPage = net.atos.wlp.olw.gui.pages.user.ChangePassword.class;
} else if (userSelector.periodicChangeCredential().getPrewarnDay() != null) {
if (userSelector.periodicChangeCredential().getPrewarnDay() < 1) {
loginmessage = "Your password is expired. Please change it immediately.";
nextPage = net.atos.wlp.olw.gui.pages.user.ChangePassword.class;
} else {
loginmessage = "Your password will expire in "
+ userSelector.periodicChangeCredential().getPrewarnDay() + " days";
}
}
}
} else {
Info.I0030.format(this, userName, httpRequest.getRemoteAddr());
throw new AuthenticationException("User not found.");
}
} catch (final LockedByAdminException e) {
loginmessage = "The account for this user name has been locked. Please contact the administration of this system.";
auditMessages.loginDenied(userName, new Date(), e.getLocalizedMessage());
Info.I0022.format(this, userName,httpRequest.getRemoteAddr());
} catch (final OtpExpiredException e) {
loginmessage = "The one time password is expired.";
auditMessages.loginDenied(userName, new Date(), e.getLocalizedMessage());
Info.I0023.format(this, userName, httpRequest.getRemoteAddr());
} catch (final BurntAuthenticationException e) {
loginmessage = "The account is locked due too many failed login attempts.";
auditMessages.loginDenied(userName, new Date(), e.getLocalizedMessage());
Info.I0024.format(this, userName,httpRequest.getRemoteAddr());
} catch (final CredentialExpiredException e) {
loginmessage = "The password is expired.";
auditMessages.loginDenied(userName, new Date(), e.getLocalizedMessage());
Info.I0025.format(this, userName,httpRequest.getRemoteAddr());
} catch (final AccessCalendarException e) {
loginmessage = "The access calendar does not allow a login currently.";
auditMessages.loginDenied(userName, new Date(), e.getLocalizedMessage());
Info.I0026.format(this, userName,httpRequest.getRemoteAddr());
} catch (final AuthenticationException e) {
loginmessage = messages.get("Login.error.Fail");
auditMessages.loginDenied(userName, new Date(), e.getLocalizedMessage());
Info.I0027.format(this, userName,httpRequest.getRemoteAddr());
} catch(net.atos.xa.rm.api.NotFoundException e)
{
loginmessage = messages.get("Login.error.Fail");
auditMessages.loginDenied(userName, new Date(), e.getLocalizedMessage());
Info.I0028.format(this, userName,httpRequest.getRemoteAddr());
}
} else {
loginmessage = "You are already logged in.";
nextPage = net.atos.wlp.olw.gui.pages.Index.class;
}
if (currentUser != null && currentUser.isAuthenticated() && currentUser.getPrincipal() != null) {
auditMessages.loginSucceeded(currentUser.getPrincipal().toString(), new Date());
Info.I0029.format(this, userName, httpRequest.getRemoteAddr());
PciSessionHandler.getInstance().addSession(userName, null, httpRequest.getSession().getId(),
httpRequest.getRemoteAddr());
}
return nextPage;
}
@OnEvent("activate")
public Object onActivate() {
if (loginmessage != null) {
loginMessageOutput = loginmessage;
loginmessage = null;
}
final Class nextPage = null;
return nextPage;
}
}
Login.tml:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" p:title="OnlineWatcher Login"
xml:lang="en" lang="en"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
xmlns:p="tapestry:parameter">
<head>
<title>${message:common.title.text}</title>
<link href="${asset:classpath:/imgs/favicon.ico}" rel="shortcut icon" />
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
<meta name="copyright" content="Atos Worldline" />
<meta name="author" content="PPC" />
</head>
<body>
<!-- Framekiller -->
<style> html{display:none;} </style>
<script>
if(self == top) {
document.documentElement.style.display = 'block';
} else {
top.location = self.location;
}
</script>
<h1>
<img src="${asset:classpath:/imgs/logo_login.png}"
width="150"
alt="${message:Layout.text.img.alt.applicationName}"
id="logo"/>
</h1>
<div id="wrapper">
<h2>${message:Login.text.p.welcome}</h2>
<p class="intro">${message:Login.text.p.welcomedetail}</p>
<t:form t:id="loginForm">
<fieldset>
<p>
<t:label for="userName">
${message:Login.text.label.login}
</t:label>
<input type="text" t:type="TextField"
t:id="userName" id="userName" name="userName" t:value="userName" tabindex="1" />
</p>
<p>
<t:label for="password">
${message:Login.text.label.password}
</t:label>
<input type="password" t:type="PasswordField" autocomplete="off"
t:id="password" id="password" name="password" t:value="password" tabindex="2" />
</p>
<!--
<p class="pForgpwd">
<a href="lostpwd">
${message:Login.text.a.forgotpasswd}
</a>
</p>
-->
<p>
<input type="submit" t:type="submit"
t:id="submitButton" title="Enter" tabindex="3" value="${message:Login.text.input.submitButton}"/>
</p>
</fieldset>
<!-- ERROR MESSAGE ZONE -->
<p id="ferrorlg">${loginMessageOutput}</p>
</t:form>
<p class="installinfo">
<t:outputRaw value="installinfo" t:mixins="FilterHtml"/>
</p>
<p class="certification">
<a href="http://www.legalis.net/cgi-iddn/certificat.cgi?IDDN.FR.010.0118219.000.R.X.2012.035.30000" title="Visit IDDN Site">
<img src="${asset:classpath:/imgs/iddn_66.gif}" alt="IDDN : All rights protected" />
</a>
</p>
<p id="cprgthp">© ${message:Login.text.p.copyright}</p>
</div>
</body>
</html>