Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

AEM 6.1 java 1.8 compatibility issue

Avatar

Level 3

Hi,

we are trying to upgrade our project to AEM 6.1 and JDK 1.8 version . 

 

we are trying to modify the pom.xml files of my project. 

we used  the following combinations :

 

<plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
                </plugin>

<plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-scr-plugin</artifactId>
                    <version>1.21.0</version>
                    <extensions>true</extensions>
                     <configuration>
                    <sourceExcludes>com/sapient/archive/*.java</sourceExcludes>
                </configuration>               
                    <executions>
                        <execution>
                            <id>generate-scr-scrdescriptor</id>
                            <goals>
                                <goal>scr</goal>
                            </goals>
                            
                        </execution>
                    </executions>
                </plugin>

 

 

<dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.scr.annotations</artifactId>
            <version>1.9.6</version>
            <scope>provided</scope>
        </dependency>

 

if we use the following combination in parent and as well and child we are getting the following error: 

 

[ERROR] Failed to execute goal org.apache.felix:maven-scr-plugin:1.21.0:scr (generate-scr-scrdescriptor) on project aem.foundation: SCR Descriptor parsing had failures (see log) -> [Help 1]

 

if we use the above combination only in parent, build got the success, but generated jar file is not creating OSGI-INF folder . 

 

 

can anyone please provide the sample pom.xml file which will both compatible with 1.7 and 1.8 . 

 

 

 

Thanks, 

Lakshmi Raghava Reddy M.

 

can any one help

1 Accepted Solution

Avatar

Correct answer by
Employee

There seems to be some details on this issue online, looks like your java code may need to be updated. What version of AEM are you migrating from?

https://issues.apache.org/jira/browse/FELIX-4586

http://apache-sling.73963.n3.nabble.com/jira-Created-SLING-3792-Fields-in-ResourceAccessSecurityTrac...

View solution in original post

14 Replies

Avatar

Employee Advisor

Hi,

Looks like the maven SCR plugin fails to parse the SCR annotations; can you run maven on debug (-X) and post the relevant exception? Please don't post the complete output then :)

Kind regards,
Jörg

Avatar

Level 3

Thanks jorg for the response ,  i  ran in debug mode, following is the error that i am getting :

 


[ERROR] Failed to execute goal org.apache.felix:maven-scr-plugin:1.20.0:scr (generate-scr-scrdescriptor) on project aem.foundation: SCR Descriptor parsing had failures (see log) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.felix:maven-scr-plugin:1.20.0:scr (generate-scr-scrdescriptor) on project aem.foundation: SCR Descriptor parsing had failures (see log)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: SCR Descriptor parsing had failures (see log)
    at org.apache.felix.scrplugin.mojo.SCRDescriptorMojo.execute(SCRDescriptorMojo.java:251)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: org.apache.felix.scrplugin.SCRDescriptorFailureException: SCR Descriptor parsing had failures (see log)
    at org.apache.felix.scrplugin.SCRDescriptorGenerator.execute(SCRDescriptorGenerator.java:223)
    at org.apache.felix.scrplugin.mojo.SCRDescriptorMojo.execute(SCRDescriptorMojo.java:237)
    ... 21 more

 

Please let me know, if you need more details. 

Avatar

Level 3

Hi Jorg,

Following is the error that i am getting once i ran the build with debug mode:

[ERROR] D:\IEA 2.2 -6.0\aem.foundation\src\main\java\com\sapient\platform\iea\aem\core\cache\impl\ComponentViewAndViewHelperCacheImpl.java [1:1]: @Reference(viewHelperfactory) : Dynamic field must be declared volatile for unary references
[ERROR] D:\IEA 2.2 -6.0\aem.foundation\src\main\java\com\sapient\platform\iea\aem\core\cache\impl\ComponentViewAndViewHelperCacheImpl.java [1:1]: @Reference(componentViewAndViewHelperResolver) : Dynamic field must be declared volatile for unary references
[ERROR] D:\IEA 2.2 -6.0\aem.foundation\src\main\java\com\sapient\platform\iea\aem\core\discovery\ViewHelperFactoryImpl.java [1:1]: @Reference(viewHelperCache) : Dynamic field must be declared volatile for unary references
[ERROR] D:\IEA 2.2 -6.0\aem.foundation\src\main\java\com\sapient\platform\iea\aem\core\resolver\impl\ComponentViewAndViewHelperResolverImpl.java [1:1]: @Reference(viewHelperFactory) : Dynamic field must be declared volatile for unary references

 

Please provide the answer if you know.

Avatar

Employee Advisor

Hm,

what version of Java are you using to run Maven? I haven't tried it with Java8 yet. Please check the URLs Opkar already posted.

kind regards,
Jörg

Avatar

Correct answer by
Employee

There seems to be some details on this issue online, looks like your java code may need to be updated. What version of AEM are you migrating from?

https://issues.apache.org/jira/browse/FELIX-4586

http://apache-sling.73963.n3.nabble.com/jira-Created-SLING-3792-Fields-in-ResourceAccessSecurityTrac...

Avatar

Level 3

Hi Jorg,

In my local, i am using maven version -3.0.4 and in pom.xml file we are using maven-version as 3.1 and maven-scr-plugin version is 1.20. 

As per the Opkar URLs, we modified code by adding volatile to the reference. My build got success,  i deployed the jar files to console  but some of the components were in unsatisfied mode and when i tried to activate them, those components were disappearing from component console.  

Did you face this issue as well, can you please help us to resolve this issue. 

please let me know, if you need more details. 

 

Thanks,

Lakshmi Raghava Reddy M.

Avatar

Level 3

i am migrating AEM 6.0 to AEM 6.1 version. 

Avatar

Employee

When you deploy your package to AEM, tail the error.log file and see if any errors are thrown when your bundle is started.

Regards,

Opkar

Avatar

Level 3

Hi Opkar,

Yes there are some errors, it's related my project. But with out having project code deployment, following out of box components are in unsatisfied  mode. I am using Java 8 in my local.

 

com.adobe.acs.commons.forms.helpers.impl.ForwardAsGetFormHelperImpl    unsatisfied (reference)    
 
2278     com.adobe.acs.commons.forms.helpers.impl.PostRedirectGetFormHelperImpl    unsatisfied (reference)    
 
2313     com.adobe.acs.commons.forms.impl.FormsPostFilterImpl    unsatisfied (reference)    
 
2315     com.adobe.acs.commons.forms.impl.FormsPostRedirectGetFilterImpl    unsatisfied (reference)    
 
2304     com.adobe.acs.commons.quickly.impl.QuicklyFilter    unsatisfied (reference)    
 
2316     com.adobe.acs.commons.quickly.impl.QuicklyInitServlet    unsatisfied (reference)    
 
2266     com.adobe.acs.commons.quickly.impl.QuicklyServlet    unsatisfied (reference)    
 
1305     com.adobe.cq.dam.mac.sync.helper.impl.MACSyncClientImpl    unsatisfied (reference)    
  
272     com.adobe.granite.httpcache.impl.ExpiresCacheHandler    unsatisfied (reference)    
 
1108     com.day.cq.workflow.impl.email.EMailNotificationService    unsatisfied (reference)    
  
1101     com.day.cq.workflow.impl.email.TaskEMailNotificationService    unsatisfied (reference)    
  
200     org.apache.sling.resourceaccesssecurity.impl.ApplicationResourceAccessSecurityImpl    unsatisfied (reference)    
----------------------------------------------------

Please let me know, whether we can ignore those issues or not? 

 

 

 

Thanks,

Lakshmi Raghava Reddy M.

Avatar

Level 3

Hi, I am also facing the similar kind of problem. Please let me know if there is any fix

Avatar

Level 3

Yes, we figure out the issue and issue and issue is with the code that we modified for the deprecated API. With out code changes of Deprecated API, everything is working fine with java 8 .

Avatar

Employee Advisor

Unsatiesfied components are not an issue in the first place. A number of them will only get active if you provide proper configuration. This depends on the component.

Kind regards,
Jörg

Avatar

Level 2

Hi

Wanted to share my experience and learning with the group. I have faced same issues with maven-compiler and scr annotations with JDK 1.8 and AEM 6.1. I eventually found that its a maven compiler and related dependencies' compatibility to JDK 1.8 issue and resolved with following changes in my reactor project's POM.xml. Please note that:

  1. Earlier Environment - JDK 1.7, Maven 3.2.2 and AEM 6.0 SP1
  2. New Environment - JDK 1.8...73 (the latest at the moment), Maven 3.3.3 and AEM 6.1 SP1

Changes:

CHANGE-1: Under the tag <build><pluginManagement>

<!-- commented due to AEM 6.1 JDK 1.8 issue
<plugin>
   <artifactId>maven-compiler-plugin</artifactId>
   <version>3.0</version>
   <configuration>
      <source>1.6</source>
      <target>1.6</target>
      <encoding>utf-8</encoding>
   </configuration>
</plugin>
-->

<!-- Added due to AEM 6.1 JDK 1.8 issue -->
<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-compiler-plugin</artifactId>
   <version>3.1</version>
   <inherited>true</inherited>
   <configuration>
      <source>1.8</source>
      <target>1.8</target>
   </configuration>
</plugin>

Change-2: Under the tag <build><pluginManagement>

<!-- Added due to AEM 6.1 JDK 1.8 Issue -->
<plugin>
   <groupId>org.apache.felix</groupId>
   <artifactId>maven-scr-plugin</artifactId>
   <version>1.17.0</version>
</plugin>

<!-- commented due to AEM 6.1 JDK 1.8 Issue
<plugin>
   <groupId>org.apache.felix</groupId>
   <artifactId>maven-scr-plugin</artifactId>
   <version>1.8.0</version>
</plugin>
-->

Change 3: Under the tag <dependencyManagement><dependencies>

<!-- Added due to JDK 1.8 AEM 6.1 issue -->
<dependency>
   <groupId>org.apache.felix</groupId>
   <artifactId>org.apache.felix.scr.annotations</artifactId>
   <version>1.9.8</version>
</dependency>

<!-- commented due to JDK 1.8 AEM 6.1 issue
<dependency>
   <groupId>org.apache.felix</groupId>
   <artifactId>org.apache.felix.scr.annotations</artifactId>
   <version>1.7.0</version>
</dependency>
-->

It solved my AEM 6.1 JDK 1.8 issue related to scr annotation issue as described in this POST originally.

 

Cheers

Anand 

Avatar

Level 1

Many thanks Anand, that helped me out.