Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is wrong with my POM? "Resolving expression..detected recursive expression cycle"

Tags:

java

maven

So I have some TestNG SuiteXML files containing runtime params like so:-

 <!--SERVER AND TARGET PARAMS-->
    <parameter name="environment" value="${environment}"/>
    <parameter name="port" value="${port}"/>

and my POM looks like so:

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

<groupId>co.uk.multicom.test.project</groupId>
<artifactId>fab-handler-automation</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <sl4j.version>1.7.7</sl4j.version>
    <suiteFile>${suiteFile}</suiteFile>
    <environment>${environment}</environment>
    <port>${port}</port>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
                <systemProperties>
                    <property>
                        <name>javax.xml.parsers.SAXParserFactory</name>
                        <value>org.apache.xerces.jaxp.SAXParserFactoryImpl</value>
                    </property>
                    <property>
                        <name>user.language</name>
                        <value>en</value>
                    </property>
                </systemProperties>
                <!--<testFailureIgnore>true</testFailureIgnore>-->
                <suiteXmlFiles>
                    <suiteXmlFile>${suiteFile}</suiteXmlFile>
                </suiteXmlFiles>
                <systemPropertyVariables>
                    <environment>${environment}</environment>
                    <port>${port}</port>
                </systemPropertyVariables>
                <properties>
                    <property>
                        <name>parallel</name>
                        <value>methods</value>
                    </property>
                    <property>
                        <name>threadCount</name>
                        <value>1</value>
                    </property>
                    <property>
                        <name>dataproviderthreadcount</name>
                        <value>1</value>
                    </property>
                </properties>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <!-- https://mvnrepository.com/artifact/com.jayway.restassured/rest-assured -->
    <dependency>
        <groupId>com.jayway.restassured</groupId>
        <artifactId>rest-assured</artifactId>
        <version>2.9.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>4.4.6</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.9.10</version>
    </dependency>
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <version>1.3</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>htmlunit-driver</artifactId>
        <version>2.21</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.0.0</version>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.jexcelapi</groupId>
        <artifactId>jxl</artifactId>
        <version>2.6.12</version>
    </dependency>
    <!-- Logging -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.21</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.21</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <!-- pom.xml -->
    <dependency>
        <groupId>com.aventstack</groupId>
        <artifactId>extentreports</artifactId>
        <version>3.0.0</version>
    </dependency>
</dependencies>

My error is:

[ERROR]     Resolving expression: '${environment}': Detected the following recursive expression cycle in 'environment': [environment] -> [Help 2]
[ERROR]     Resolving expression: '${port}': Detected the following recursive expression cycle in 'port': [port] -> [Help 2]

Am I being stupid? Probably, I am only a tester after all and have a very small brain. Can anyone help me troubleshoot? Does my POM look squiffy?

It will not download my required jars to the local .m2 until I can fix it - I have tried blowing away .m2 and doing mvn install etc....no joy.

like image 497
Steerpike Avatar asked Feb 26 '17 11:02

Steerpike


2 Answers

Your errors come from this part:

<properties>
    <sl4j.version>1.7.7</sl4j.version>
    <suiteFile>${suiteFile}</suiteFile>
    <environment>${environment}</environment>
    <port>${port}</port>
</properties>

When you use ${port} Maven looks for the value in <port>X</port> which here X=${port} and so on... So that's why you get a recursive issue here

like image 80
Adonis Avatar answered Nov 16 '22 10:11

Adonis


I'm not sure because I only have time for a quick look, but defining a property and then assigning that property to itself is what I think your doing and is what causes the error.

Can't you just use ${suiteFile} in your pom without defining it in your <properties></properties>?

Or can you use another property name in the pom? for example:

 <properties>
        <suiteFile1>${suiteFile}</suiteFile>
        <environment1>${environment}</environment>
        <port1>${port}</port>
    </properties>

and use those further down in your pom?

like image 2
rdhaese Avatar answered Nov 16 '22 10:11

rdhaese