cannot retrieve mapping for action error - struts

im using struts 1.2 and trying to create a link in jsp page with code
<html:link href="AdminModule/UserCreation.jsp" >
Create User </html:link> `
so that the link will move to page UserCreation in which the code like this is present
<html:form action="/adminUserCreation">
AdminName : <html:text property="username"/><html:errors property="username"/><br/>
Password : <html:password property="password"/><html:errors property="password"/><br/>
<html:submit/>
</html:form>
the struts-config file contain code like this
<form-beans>
<form-bean name="adminUserCreationForm" type="Admin.Form.AdminUserCreationForm" />
</form-beans>
<action-mappings>
<action
attribute="adminUserCreationForm"
input="/AdminModule/AdminHomePage.jsp"
name="adminUserCreationForm"
path="/adminUserCreation"
scope="request"
type="Admin.Action.AdminUserCreationAction"
validate="false">
<set-property property="cancellable" value="true" />
<forward name="failure" path="/AdminModule/AdminErrorPage.jsp" />
<forward name="success" path="/AdminSuccessPage.jsp" />
</action>
</action-mappings>
im getng exception
An exception occurred processing JSP page /AdminModule/UserCreation.jsp at line 30
30: <html:form action="/adminUserCreation">
31: AdminName : <html:text property="username"/><html:errors property="username"/><br/>
32: Password : <html:password property="password"/><html:errors property="password"/><br/>
33: <html:submit/>
root cause is
javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot retrieve mapping for action /adminUserCreation

How to open one jsp from another through struts
This helped me to solve it..
Maybe it will be helpful for anyone else who has the same problem.

Related

XmlException: Root element is missing (but it's not)

I have a VB.Net 4.7.2 desktop application that is throwing an exception occasionally. The exception is usually, "Root element is missing".
When this happens, I am able to view the file after the fact and the root element is there.
The file is written to the share by a remote Linux system and is accessed by this application using an SMB share.
I thought there might be a timing issue with the file being written to the share, so I implemented a retry and I still get the same exception after trying 3 times, 10 seconds apart.
The xmlPath is passed in as a parameter.
' xmlPath is the UNC path to a local network share.
Dim xmlDoc As New XmlDocument()
xmlDoc.Load(xmlPath)
When I view the XML file at the file location, here's what I see.
<reportrequest Version="1.0">
<report ReportGUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ReportCode="LENDPG_1" ABSReportCode="" Title="Lender Portal Collateral Screen Basic" Description="CS Basic Report" Price="0">
<account AccountNumber="6551198" Address="000 Main St" City="Spokane" State="WA" ZipCode="99201" />
<contact FirstName="Person" LastName="Ordering" Email="person#domain.com" Phone="000-000-0000" />
<outputtypecoll>
<outputtype Type="XML" FileName="" />
</outputtypecoll>
<featurecoll>
<feature Name="CSRDISTANCE" Value="false" />
<feature Name="CSRDBSTATUS" Value="false" />
<feature Name="CSRELEVATION" Value="false" />
<feature Name="FINDTP" Value="TRUE" />
<feature Name="DETAILS" Value="TRUE" />
</featurecoll>
<targetpropertycoll>
<targetproperty SiteIndex="0" PropertyGUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ExternalPropertyGUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" MonitoringGUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" PortfolioGUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" OrderGUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" PropertyName="My Property" Address="1 Wherever Ave" City="Sometown" State="CA" ZipCode="99999" Latitude="30.111111" Longitude="-110.88888">
<georeferenced Address="My Property" City="Sometown" State="CA" ZipCode="99999" Latitude="30.111111" Longitude="-110.88888" Fips="" County="" PostalCity="" />
<searchdistancecoll SetID="0000" SetName="LendPort Collateral" MaxDistance="5280" />
<edrdatacoll>
<edrdata Name="REPORTCOST" Value="0.00" />
<edrdata Name="BORROWER" Value="" />
<edrdata Name="LOANTYPE" Value="Other" />
<edrdata Name="LOANNUMBER" Value="" />
<edrdata Name="PROPERTYTYPE" Value="" />
<edrdata Name="DESTHOST" Value="www.xxxxxxxxxxx.com" />
</edrdatacoll>
</targetproperty>
</targetpropertycoll>
</report>
</reportrequest>
This certainly has a root element.
What can be causing this seemingly bogus exception?
Try adding this as the first line of the file
<?xml version="1.0" encoding="UTF-8"?>
EDIT:
Change this
Dim xmlDoc As New XmlDocument()
xmlDoc.Load(xmlPath)
to this
Dim xmlDoc As New XmlDocument()
Try
xmlDoc.Load(xmlPath)
Catch ex As Exception
Dim xe As XElement
xe = XElement.Load(xmlPath)
Stop
End Try

how to use dirSize() EL function in oozie decision node

I tried to use dirSize() in oozie decision node. but it does not work.
When I use ${fs:dirSize(InputDir) gt 10 * KB} in the decision node. The oozie workflow status moves to failed state and no error is displayed.
Please find below the code snippet from workflow.
<action name="L1_check" cred="hcat_creds">
<hive xmlns="uri:oozie:hive-action:0.2">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<script>l1_check_code.sql</script>
<param>PI_DB=${PI_DB}</param>
<param>PRD_DB=${PRD_DB}</param>
<param>PROMO_START_DATE=${PROMO_START_DATE}</param>
<param>PROMO_END_DATE=${PROMO_END_DATE}</param>
</hive>
<ok to="decision-node" />
<error to="fail" />
</action>
<decision name="decision-node">
<switch>
<case to="L1_exists">
${fs:dirSize(InputDir) gt 10 * KB}
</case>
<default to="fail"/>
</switch>
</decision>
InputDir is a defined in the properties file and the path exists.
First action L1_check executes and transitioned to decision node. then workflow status changes to Failed state.
Is there any error in the way function is used? If yes, what should be right function to use?
Also is there a way to give a path with combination of parameter and string
eg: dirSize(InputDir/l1_check)
where InputDir is a parameter and l1_check is a static name

Spring security 3.2: Does a custom UserDetails & UserDetailsService need a custom AuthenticationManager?

I'm working with spring security 3.2, JSF2 , Hibernate4.
I'have done 3/4 of the work :) but my authentication system doesn't work yet.
I have a UserService who implements UserDetailsService, a domain Class User who implements UserDetails.
THe login system never stop user to access secured pages, i tried user name and password who doesn't exist in my database...
Thanks for the help.
I have a loginBean who is trying to authenticate the user when he connects via login form :
public String login() {
try {
Authentication request = new UsernamePasswordAuthenticationToken(this.getUsername(), this.getPassword());
Authentication result = authenticationManager.authenticate(request);
SecurityContextHolder.getContext().setAuthentication(result);
} catch (AuthenticationException e) { e.printStackTrace();}
return "secured";
}
My spring security looks like this :
`<security:global-method-security jsr250-annotations="enabled" pre-post-annotations="enabled" secured-annotations="enabled" />
<security:http auto-config="true" use-expressions="true">
<security:intercept-url pattern="/Admin" access="isAuthenticated()" />
<security:form-login login-page="/login.xhtml" authentication-failure-url="/" > </security:form-login>
</security:http>
<!-- User Data Access Object -->
<beans:bean id="userDao" class="com.clb.genomic.lyon.dao.UserDaoImpl" >
<beans:property name="sessionFactory" ref="sessionFactory"></beans:property>
</beans:bean>
<!-- User Business Object -->
<beans:bean id="userBo" class="com.clb.genomic.lyon.bo.UserBoImpl" >
<beans:property name="userDao" ref="userDao" />
</beans:bean>
<beans:bean id="login" class="com.clb.genomic.lyon.beans.LoginBean" scope ="request">
<beans:property name="authenticationManager" ref="authenticationManager" />
</beans:bean>
<beans:bean id="standardPasswordEncoder" class="org.springframework.security.crypto.password.StandardPasswordEncoder"/>
<security:authentication-manager alias="authenticationManager">
<security:authentication-provider user-service-ref="userBo" >
<security:password-encoder ref="standardPasswordEncoder"/>
</security:authentication-provider>
</security:authentication-manager>`
This is the error who show up...
org.springframework.security.authentication.AuthenticationServiceException: 1
at org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:109)
at org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:132)
at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:156)
at com.clb.genomic.lyon.beans.LoginBean.login(LoginBean.java:47).....
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at com.clb.genomic.lyon.dao.UserDaoImpl.loadUserByUsername(UserDaoImpl.java:59)
at com.clb.genomic.lyon.bo.UserBoImpl.loadUserByUsername(UserBoImpl.java:68)
at com.clb.genomic.lyon.bo.UserBoImpl$$FastClassByCGLIB$$9ea98abf.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204).....
The exception from stack trace shows you are getting ArrayIndexOutOfBoundsException and it seems that you are reading from an empty array.
You should also check what value is being passed to loadUserByUsername() method, and if that user exists.

Apache Struts: Cannot retrieve ActionForward

I am trying to learn the Apache Struts framework and I have written a small application that does class enrollments but whenever I try and load up my application it just spits out the following exception:
javax.servlet.ServletException:
org.apache.jasper.JasperException:
javax.servlet.ServletException:
javax.servlet.jsp.JspException: Cannot create rewrite URL:
java.net.MalformedURLException: Cannot retrieve ActionForward named adminLogin
My index.jsp page looks like:
<%# taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<logic:redirect forward="showLogin"/>
The relevant parts of my struts-config.xml:
<global-forwards>
<forward name="showLogin" path="/showLogin.do" />
</global-forwards>
<action-mappings>
<action path="/showLogin" forward="/pages/choose.jsp" />
<action path="/adminLogin" forward="/pages/adminLogin.jsp" />
</action-mappings>
And finally the choose.jsp file:
<%# page import="javax.sql.*"%>
<%# taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%# taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<h1>Who are you?</h1>
<ul>
<li><html:link forward="adminLogin">Administrator</html:link></li>
<li><html:link forward="instructorLogin">Instructor</html:link></li>
<li><html:link forward="studentLogin">Student</html:link></li>
</ul>
I don't do Struts, so don't pin me on it, but the error seems to indicate that it is expecting a <forward name="adminLogin" /> somewhere in the config. You might want to have the same for the other two forwards.

Ldap invalid credentials not loading authentication failure url

Able to do the custom ldap authentication for external db authorities. But when I am trying to test wrong password the authentication failure URL is not showing instead my browser prints the exception details.Below is my securitycontext.xml and exception given:
<http auto-config="false" access-decision-manager-ref="accessDecisionManager" access-denied-page="/accessDenied.jsp">
<!-- Restrict access to ALL other pages -->
<intercept-url pattern="/index.jsp" filters="none" />
<!-- Don't set any role restrictions on login.jsp -->
<intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<intercept-url pattern="/service/**" access="PRIV_Report User, PRIV_305" />
<logout logout-success-url="/index.jsp" />
<form-login authentication-failure-url="/index.jsp?error=1" default-target-url="/home.jsp" />
<anonymous/>
</http>
<b:bean id="accessDecisionManager" class="org.springframework.security.vote.AffirmativeBased">
<b:property name="decisionVoters">
<b:list>
<b:ref bean="roleVoter" />
<b:ref bean="authenticatedVoter" />
</b:list>
</b:property>
</b:bean>
<b:bean id="roleVoter" class="org.springframework.security.vote.RoleVoter">
<b:property name="rolePrefix" value="PRIV_" />
</b:bean>
<b:bean id="authenticatedVoter" class="org.springframework.security.vote.AuthenticatedVoter">
</b:bean>
<b:bean id="contextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
<b:constructor-arg value="ldap://mydomain:389" />
</b:bean>
<b:bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
<b:constructor-arg ref="contextSource" />
</b:bean>
<b:bean id="ldapAuthenticationProvider"
class="com.zo.sas.gwt.security.login.server.SASLdapAuthenticationProvider">
<b:property name="authenticator" ref="ldapAuthenticator" />
<custom-authentication-provider />
</b:bean>
<b:bean id="ldapAuthenticator"
class="com.zo.sas.gwt.security.login.server.SASAuthenticator">
<b:property name="contextSource" ref="contextSource" />
<b:property name="userDnPatterns">
<b:value>uid={0},OU=People</b:value>
</b:property>
</b:bean>
And my exception logs:
org.springframework.ldap.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]; nested exception is javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]
org.springframework.ldap.support.LdapUtils.convertLdapException(LdapUtils.java:180)
org.springframework.ldap.core.support.AbstractContextSource.createContext(AbstractContextSource.java:266)
org.springframework.ldap.core.support.AbstractContextSource.getContext(AbstractContextSource.java:106)
com.zo.sas.gwt.security.login.server.SASAuthenticator.authenticate(SASAuthenticator.java:55)
com.zo.sas.gwt.security.login.server.SASLdapAuthenticationProvider.authenticate(SASLdapAuthenticationProvider.java:45)
org.springframework.security.providers.ProviderManager.doAuthentication(ProviderManager.java:188)
org.springframework.security.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:46)
org.springframework.security.ui.webapp.AuthenticationProcessingFilter.attemptAuthentication(AuthenticationProcessingFilter.java:82)
org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:258)
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:183)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:138)
This is my index.jsp
<html>
<script type="text/javascript" language="javascript">
var dictionary = {
loginErr: "${SPRING_SECURITY_LAST_EXCEPTION.message}",
error: "${param.error}"
};
</script>
<head>
</head>
<body >
<iframe src="javascript:''" id="__gwt_historyFrame" style="width:0;height:0;border:0"></iframe>
<script type="text/javascript" language="javascript" src="com.zo.sas.gwt.sasworkflow.home.Home.nocache.js"></script>
</body>
</html>
that log doesn't say much. You should put org.springframework to log at DEBUG level and see what is going on.
Look for this messages: "Updated SecurityContextHolder to contain null Authentication" and "Authentication request failed: ", after that there must be a redirect to index.jsp.
What is the code of index.jsp?
This is the correct error message, LDAP: error code 49 - Invalid Credentials, maybe not the format that you wanted though.
The LDAP server should pass a subcode for the reason, Active Directory has a list:
AD LDAP 49 codes and eDirectory will send usually a 669 error for bad password of 601 for bad DN. Though I think that changed in the last couple of versions, and they all show up as 669 errors on eDirectory, so as not to help attackers determine real user names.