0

I'm developing the same code from the https://github.com/OhadR/Authentication-Flows (basically looking for Spring MVC application to reset the password or forgot password or lock password functionality)

After research I find this URL which is awesome, but when trying to compile and deploy code on Tomcat web server causes the following error:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authFlowsProperties': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String com.ohadr.auth_flows.config.AuthFlowsProperties.accountActivatedEndpointUrl; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'com.ohadr.auth-flows.endpoints.accountActivatedEndpointUrl'
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
    at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5262)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5550)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String com.ohadr.auth_flows.config.AuthFlowsProperties.accountActivatedEndpointUrl; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'com.ohadr.auth-flows.endpoints.accountActivatedEndpointUrl'
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
    ... 29 more

The pom.xml which I used ? Still OhadR needs to update pom.xml

<properties>
    <ohadr.spring.version>4.0.9.RELEASE</ohadr.spring.version>
    <ohadr.spring.security.version>3.2.7.RELEASE</ohadr.spring.security.version>
    <ohadr.flows.version>1.6.2-SNAPSHOT</ohadr.flows.version>
</properties>
<dependencies>

    <dependency>
        <groupId>com.ohadr</groupId>
        <artifactId>authentication-flows</artifactId>
        <version>${ohadr.flows.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>4.0.9.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>${ohadr.spring.security.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>${ohadr.spring.security.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>${ohadr.spring.security.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${ohadr.spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${ohadr.spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>${ohadr.spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${ohadr.spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${ohadr.spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${ohadr.spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${ohadr.spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-taglibs</artifactId>
        <version>${ohadr.spring.security.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${ohadr.spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-expression</artifactId>
        <version>${ohadr.spring.version}</version>
    </dependency>


    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>2.2.2</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>


    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.5</version>
    </dependency>

    <dependency>
        <groupId>c3p0</groupId>
        <artifactId>c3p0</artifactId>
        <version>0.9.1.2</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.16</version>
    </dependency>

    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>

    <!-- Pair impl -->
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.1</version>
    </dependency>

    <!-- sending emails... -->
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.1</version>
    </dependency>
</dependencies>

The "client.properties" (As suggested by ohadR)

com.ohadr.oauth2.db.username=root
com.ohadr.oauth2.db.password=root
com.ohadr.oauth2.db.host=localhost
com.ohadr.oauth2.db.port=3306
com.ohadr.oauth2.db.schema=test

com.ohadr.auth-flows.linksExpirationMinutes=60
com.ohadr.auth-flows.mail.username=ohadr.developer@gmail.com
com.ohadr.auth-flows.mail.password=*****
com.ohadr.auth-flows.isREST=false
com.ohadr.auth-flows.email.fromField=ohadr.com Admin

# Crypto settings
com.ohadr.crypto.keystore=C:/Ohad/Dev/Tools/ohad.ks
com.ohadr.crypto.password=kspass
com.ohadr.crypto.keyAlias=ohadr
com.ohadr.crypto.createKeystoreFileIfNotExist=false
com.ohadr.auth-flows.endpoints.accountActivatedEndpointUrl=/login/accountActivated.htm
halfer
  • 19,824
  • 17
  • 99
  • 186
  • try to put your 'client.properties' in source folder src/main/resources not in src/test/resources and then try to run your server. – Pratik Shah Apr 07 '15 at 13:46
  • @prtk - I'm referring to https://github.com/OhadR/Authentication-Flows code and this code has "client.properties" already present in src/main/resources –  Apr 07 '15 at 14:08
  • 1
    Okay and if this https://github.com/OhadR/Authentication-Flows/blob/master/client/src/main/resources/client.properties is your client.properties then please add "com.ohadr.auth-flows.endpoints.accountActivatedEndpointUrl" property init. – Pratik Shah Apr 07 '15 at 15:54
  • @prtk - Could you tell me please what value should be assign to com.ohadr.auth-flows.endpoints.accountActivatedEndpointUrl ? –  Apr 07 '15 at 18:02
  • @user4567570 why do you say that I need to update the pom.xml? what is wrong with the pom? – OhadR Apr 08 '15 at 07:05

1 Answers1

1

@prtk_shah is correct in his comment - the client application should add several properties in "client.properties" file. one of them is

com.ohadr.auth-flows.endpoints.accountActivatedEndpointUrl

Basically this is the URL that the controller redirects to, upon account activation (meaning, when the user clicks the link in the verification email that he gets after he subscribes). This property lets the auth-flows to be generic in sense that it does not force the client-app to a specific activation endpoint. So each client-app can has its own endpoint URL. For example, one app can have this endpoint: /login/accountActivated.htm while another app can use this one: /activatation.jsp

You are completely right; This is described here, and maybe it should have been even in the README of the auth-flows itself.

UPDATE

BTW, I see that you have updated your question and added your client.properties file. Note that the props file that is in GitHub is only an example, and each client-app should edit it so it fits the client-app. For example, I believe that your email address that you use in order to send emails to your customers is not ohadr.developer... and the password is not ******. and com.ohadr.crypto.keystore should contain the real path to your keystore (read this section)

OhadR
  • 8,276
  • 3
  • 47
  • 53
  • i've updated my answer. please read my update. hope that helps. – OhadR Apr 07 '15 at 19:49
  • You need to update project for maven dependencies, as I see its too old version(s), I will be give a try to use all latest versions. It's worth if you can make it workable again. thanks for cooperation –  Apr 07 '15 at 20:03
  • I've update the docs - https://github.com/OhadR/Authentication-Flows#4-properties – OhadR Apr 07 '15 at 20:11
  • BTW if my answer here helped you, feel free to mark it as correct (or upvote it...) – OhadR Apr 07 '15 at 20:12