Hi Jan,

     Thanks for the reply.

      I only changed the waitForChild to understand what was the problem, as my 
tests failed and maven logs only showed the logs that I shared below... i.e 
src/main/webapp  UNAVAILABLE.
      If you see below, our company has a specific logging plugin for logback 
and jetty, which I reused. I think I will spend some time to understand what it 
does. There might be a issue when it is used with run-forked.

Sent from my iPad

On 21 Jan 2017, at 16:53, Jan Bartel 
<[email protected]<mailto:[email protected]>> wrote:

Kris,

Using the "start" goal would be incorrect:  AFAIK you need to start another 
process to pass the jacoco jvm args into.

So you want to use "run-forked". However, you shouldn't use 
"waitForChild=true". That will make the whole maven process wait for jetty to 
run and won't progress until jetty stops. So you want waitForChild=false.  That 
will kick off the new process (passing in any special jvm args you've 
specified), and read the output of the process looking for the signal that the 
process started correctly: it will read up to maxStartupLines looking for that 
signal. waitForChild=true is ok just for manual debugging purposes, but not for 
automated test runs.

How do you know the server wasn't starting when you used waitForChild=false? 
Was there any more output from the plugin?

If you've got a WEB-INF/jetty-web.xml file that will be found and applied to 
the webapp just before the startup is finished, you should also be trying to 
use it as a context xml file. In recent versions of the jetty plugin, you've 
been able to put a lot of configuration onto the <webApp> element instead of 
requiring a context file, so please have a look at the doco and see if you can 
do that.

Finally, have a look at your logging configuration for the forked jetty 
instance: are you trying to log everything to logback (ie including container 
messaging) or only application messaging? Try configuring logback to write to a 
log file so you can see what's going on, even if waitForChild=false.

Jan

On 21 January 2017 at 14:33, krisrr3 R 
<[email protected]<mailto:[email protected]>> wrote:


Hi guys,

          I initially posted my question on the jacoco forum 
(https://groups.google.com/d/msg/jacoco/unzcby1_8DY/NbKiq3YGAwAJ), but I was 
told this forum would be more appropriate.



        So let me explain situation



          I am building a Spring based Resful Api which is deployed on Jetty.

          I have tried a lot of combinations to get coverage for my integration 
tests, but nothing has worked so far.

          The command I am running is


mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install


          My pom config is shown below.


<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.maven.plugin.version}</version>

<configuration>
<excludes>
</excludes>
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
                        
<destFile>${project.parent.build.directory}/jacoco.exec</destFile>
                        <excludes>
                            <exclude>**/*Test*</exclude>
                        </excludes>
                        <propertyName>surefireArgLine</propertyName>
                     </configuration>
</execution>
<execution>
                    <id>post-unit-test</id>
                    <goals>
                        <goal>report</goal>
                    </goals>
                    <configuration>
                        
<dataFile>${project.parent.build.directory}/jacoco.exec</dataFile>
                        
<outputDirectory>${project.pa<http://project.pa>rent.reporting.outputDirectory}/jacoco</outputDirectory>
                    </configuration>
                </execution>
<execution>
<id>prepare-agent-integration</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
<configuration>
                        
<destFile>${project.parent.build.directory}/jacoco-it.exec</destFile>
                        <excludes>
                            <exclude>**/*Test*</exclude>
                        </excludes>
                        
<propertyName>jacoco.agent.it<http://jacoco.agent.it>ArgLine</propertyName>
                    </configuration>
</execution>
<execution>
                    <id>post-integration-test</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>report-integration</goal>
                    </goals>
                    <configuration>
                        
<dataFile>${project.parent.build.directory}/jacoco-it.exec</dataFile>
                        
<outputDirectory>${project.pa<http://project.pa>rent.reporting.outputDirectory}/jacoco-it</outputDirectory>
                    </configuration>
                </execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<includes>
<include>**/*Test*.class</include>
</includes>
<excludes>
<exclude>**/*IT</exclude>
</excludes>
<forkCount>3</forkCount>
     <reuseForks>true</reuseForks>
<argLine>${surefireArgLine} -Xmx1024m -XX:MaxPermSize=256m</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven.failsafe.plugin.version}</version>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<forkCount>3</forkCount>
     <reuseForks>true</reuseForks>
<argLine>${jacoco.agent.itArgLine} -Xmx1024m -XX:MaxPermSize=256m</argLine>
<skipTests>false</skipTests>
<includes>
<include>**/*IT.class</include>
</includes>
<systemPropertyVariables>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<goals>
<goal>set-system-properties</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<properties>
<property>
<name>logs.output</name>
<value>${project.parent.basedir}/Api/target/logs</value>
</property>
<property>
<name>logs.api.name<http://logs.api.name/></name>
<value>a-sample-api</value>
</property>
<property>
<name>logback.configurationFile</name>
<value>${project.parent.basedir}/Api-bundle/config/logback.xml</value>
</property>
<property>
<name>apibundle.dir</name>
<value>${project.parent.basedir}/Api-bundle</value>
</property>
<property>
<name>lib</name>
<value>${project.parent.basedir}/Api/target/dependency/lib</value>
</property>
<property>
<name>org.apache.cxf.Logger</name>
<value>org.apache.cxf.common.logging.Slf4jLogger</value>
</property>
<property>
<name>org.jboss.logging.provider</name>
<value>slf4j</value>
</property>
<property>
<name>org.eclipse.jetty.annotations.maxWait</name>
<value>120</value>
</property>
<property>
<name>application.properties</name>
<value>${project.parent.basedir}/Api-bundle/config/env/application-integrationtest.properties</value>
</property>
<property>
<name>sensitive.properties</name>
<value>${project.parent.basedir}/Api/src/test/resources/sensitive.properties</value>
</property>
<property>
<name>javax.net.ssl.trustStore</name>
<value>${project.parent.basedir}/Api-bundle/config/env/certs.jks</value>
</property>

</properties>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<!-- Ensure context xml is set to significantly increase application startup 
time -->
<contextXml>${project.parent.basedir}/Api/src/main/webapp/WEB-INF/jetty-web.xml</contextXml>
                    <!--
                        NOTE: To enable SSL locally make sure you the following 
line below
                        
${project.parent.basedir}/Api-bundle/config/env/jetty-https_ssl-dev.xml
                    -->
                    
<jettyXml>${project.parent.basedir}/Api-bundle/config/jetty/jetty.xml,${project.parent.basedir}/Api-bundle/config/env/jetty-http-dev.xml</jettyXml>

<dumpOnStart>true</dumpOnStart>
<scanIntervalSeconds>0</scanIntervalSeconds>
<stopPort>${jetty.stop.port}</stopPort>
<stopKey>${jetty.stop.key}</stopKey>
<stopWait>10</stopWait>
<jvmArgs>${jacoco.agent.itArgLine} 
-Dlib=${project.parent.basedir}/Api/target/dependency/lib 
-Dlogback.configurationFile=${project.parent.basedir}/Api-bundle/config/jetty/logback.xml
 
-Dapplication.properties=${project.parent.basedir}/Api-bundle/config/env/application-integrationtest.properties</jvmArgs>

</configuration>
<dependencies>
<dependency>
<groupId>au.com.company.toolkit</groupId>
<artifactId>company-toolkit-logging-jetty</artifactId>
<version>${toolkit.logging.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
            <goals>
                         <goal>run-forked</goal>
                     </goals>
                     <configuration>
                     <daemon>true</daemon>
                        <waitForChild>true</waitForChild>
                        <maxStartupLines>1000</maxStartupLines>
                    </configuration>
</execution>
<!-- execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
            <goals>
                         <goal>start</goal>
                     </goals>
</execution-->
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
<configuration>
<stopWait>1</stopWait>
<stopPort>${jetty.stop.port}</stopPort>
<stopKey>${jetty.stop.key}</stopKey>
</configuration>
</execution>
</executions>
</plugin>

</plugins>


  *   If I use the jetty start goal, my tests run and I get coverage for the 
unit tests. But integration tests coverage is 0%.


  *   I changed it to run-forked, as recommended by a few posts, including 
this<http://stackoverflow.com/questions/33645713/jacoco-and-jetty-maven-plugin-gets-0-coverage>
 But I could not get it to work. As I launched the build, the server would not 
even start and I was seeing this in the logs

[INFO] Webapp directory = C:\workspace\Api\src\main\webapp
[INFO] Quickstart generating
[INFO] Started 
o.e.j.m.p.JettyWebAppContext@13137835{/,file:///C:/workspace/Api/src/main/webapp/,AVAILABLE}{file:///C:/workspace/Api/src/main/webapp/}
[INFO] Stopped 
o.e.j.m.p.JettyWebAppContext@13137835{/,file:///C:/workspace/Api/src/main/webapp/,UNAVAILABLE}{file:///C:/workspace/Api/src/main/webapp/}
[INFO] Forked process starting

       The whole of the logs were not visible, so I changed the property 
waitForChild to true, and the end of the logs seemed to indicate something but 
it was not an error.

[STDOUT] 13:52:24.872 [main] DEBUG org.springframework.jndi.JndiLocatorDelegate 
- Converted JNDI name [java:comp/env/spring.liveBeansView.mbeanDomain] not 
found - trying original name [spring.liveBeansView.mbeanDomain]. 
javax.naming.NameNotFoundException; remaining name 
'spring.liveBeansView.mbeanDomain'
[STDOUT] 13:52:24.872 [main] DEBUG org.springframework.jndi.JndiTemplate - 
Looking up JNDI object with name [spring.liveBeansView.mbeanDomain]
[STDOUT] 13:52:24.872 [main] DEBUG org.springframework.jndi.JndiPropertySource 
- JNDI lookup for name [spring.liveBeansView.mbeanDomain] threw NamingException 
with message: null. Returning null.
[STDOUT] 13:52:24.873 [main] DEBUG 
org.springframework.core.env.PropertySourcesPropertyResolver - Could not find 
key 'spring.liveBeansView.mbeanDomain' in any property source


     I guess my questions are :

  1.  Can I get the coverage to work with jetty start goal?
  2.  What could help me investigate the issue I am facing with run-forked?

Thanks a lot for your time.





Best regards

Kris


_______________________________________________
jetty-users mailing list
[email protected]<mailto:[email protected]>
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users



--
Jan Bartel <[email protected]<mailto:[email protected]>>
www.webtide.com<http://www.webtide.com>
Expert assistance from the creators of Jetty and CometD

_______________________________________________
jetty-users mailing list
[email protected]<mailto:[email protected]>
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to