Uploaded image for project: 'Tools (JBoss Tools)'
  1. Tools (JBoss Tools)
  2. JBIDE-13074

The attribute lookup is undefined for the annotation type Resource.

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • None
    • None
    • maven
    • None

      The attribute "lookup" is not recognized by JBDS 5 for the annotation @Resource.
      To reproduce the issue,
      1) import cdi-injection quickstart into JBDS 5.0.1 as a maven project.
      2) run maven build "eclipse:eclipse" from JBDS.
      3) open EnglishTranslateService.java and add the annotation @Resource(lookup="")

      It will shows the message "the attribute lookup is undefined for the annotation type Resource".

      This issue is raised in the wiki [1] in the section "Correct build path precedence errors".

      It seems that it's related to the eclipse bug [2].

      The wiki provides a workaround which works fine. However, can we provide a complete and clean fix from JBDS side?

      [1] https://community.jboss.org/wiki/HackingAS7UsingEclipse

      [2] https://bugs.eclipse.org/bugs/show_bug.cgi?id=342128

            [JBIDE-13074] The attribute lookup is undefined for the annotation type Resource.

            Fred Bricon added a comment -

            Resolving as per user's comment

            Fred Bricon added a comment - Resolving as per user's comment

            OP behind the salesforce reference here.

            Thank you for the information this issue will be fixed in JBDS 6.

            Thank you as well for having attached the required POM. I also tried to follow the instructions on [1] but got stuck on the full modification of the POM to mark goal as ignored.

            Considering all these info, I'm actually more happier to just use the "Order and Export" tab, and to try this POM modification only if I will eventually find myself performing this manual operation too many times.

            I'm happy for you to close this JIRA in relation to the JBDS 6 release, you provided all information of possible workarounds which satisfy my original enquiry. Thank you
            Ciao,
            Matteo

            [1] http://jaitechwriteups.blogspot.fr/2011/02/resource-and-new-lookup-attribute-how.html

            Matteo Mortari added a comment - OP behind the salesforce reference here. Thank you for the information this issue will be fixed in JBDS 6. Thank you as well for having attached the required POM. I also tried to follow the instructions on [1] but got stuck on the full modification of the POM to mark goal as ignored. Considering all these info, I'm actually more happier to just use the "Order and Export" tab, and to try this POM modification only if I will eventually find myself performing this manual operation too many times. I'm happy for you to close this JIRA in relation to the JBDS 6 release, you provided all information of possible workarounds which satisfy my original enquiry. Thank you Ciao, Matteo [1] http://jaitechwriteups.blogspot.fr/2011/02/resource-and-new-lookup-attribute-how.html

            Gary - does this answer you ?

            Can the user try devstudio.jboss.com/earlyaccess ?

            And can you verify things just work for you when using Java 7 instead where there are no weird overlaps in these libraries?

            Max Andersen added a comment - Gary - does this answer you ? Can the user try devstudio.jboss.com/earlyaccess ? And can you verify things just work for you when using Java 7 instead where there are no weird overlaps in these libraries?

            Fred Bricon added a comment - - edited

            This is actually covered by JBIDE-11738. If you follow the workaround described in http://jaitechwriteups.blogspot.fr/2011/02/resource-and-new-lookup-attribute-how.html you just need to :

            • add a <phase> to the maven-dependency-plugin execution. This is a small bug we'll fix in JBDS 6 CR1
            • right-click on project Maven > Update Project Configuration
            • you might see an error marker on the maven-plugin-compiler plugin if the endorsed lib folder doesn't exist, you can quick fix it http://screencast.com/t/xRjuLJZaYHga
            • also quick fix the maven-dependency-plugin error ("plugin execution not covered"), to mark the goal as ignored in your pom.xml. In JBDS 6.0, m2e 1.2 will be installed, so you'll be able to do that on a workspace level instead.

            So your pom.xml should look like :

                   <plugins>
                     ...
                     <plugin>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>${version.compiler.plugin}</version>
                        <configuration>
                           <source>${maven.compiler.source}</source>
                           <target>${maven.compiler.target}</target>
                           <compilerArgument>-Djava.endorsed.dirs=${project.build.directory}/endorsed</compilerArgument>
                        </configuration>
                     </plugin>
                     
                      <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.5</version>
                        <configuration>
                           <!-- Setup the surefire plugin to use the endorsed directory containing
                           the jar for javax.annotation.* classes. Remember that we setup this folder
                           via the maven-dependency-plugin configuration, above. -->
                           <argLine>-Djava.endorsed.dirs=${project.build.directory}/endorsed</argLine>
                        </configuration>
                     </plugin>
                     
                      <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>2.1</version>
                        <executions>
                           <execution>
                              <phase>validate</phase>
                              <goals>
                                 <goal>copy</goal>
                              </goals>
                              <configuration>
                                 <!-- Configure the plugin to copy the jar containing javax.annotation.*
                                    to a folder named "endorsed" within the project's build directory -->
                                 <artifactItems>
                                    <artifactItem>
                                       <groupId>org.jboss.spec.javax.annotation</groupId>
                                       <artifactId>jboss-annotations-api_1.1_spec</artifactId>
                                    </artifactItem>
                                 </artifactItems>
                                 <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
                              </configuration>
                           </execution>
                        </executions>
                     </plugin>
                     ...
                   </plugins>
                  ...
                 <pluginManagement>
                  	<plugins>
                  		<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
                  		<plugin>
                  			<groupId>org.eclipse.m2e</groupId>
                  			<artifactId>lifecycle-mapping</artifactId>
                  			<version>1.0.0</version>
                  			<configuration>
                  				<lifecycleMappingMetadata>
                  					<pluginExecutions>
                  						<pluginExecution>
                  							<pluginExecutionFilter>
                  								<groupId>
                  									org.apache.maven.plugins
                  								</groupId>
                  								<artifactId>
                  									maven-dependency-plugin
                  								</artifactId>
                  								<versionRange>
                  									[2.1,)
                  								</versionRange>
                  								<goals>
                  									<goal>copy</goal>
                  								</goals>
                  							</pluginExecutionFilter>
                  							<action>
                  								<ignore></ignore>
                  							</action>
                  						</pluginExecution>
                  					</pluginExecutions>
                  				</lifecycleMappingMetadata>
                  			</configuration>
                  		</plugin>
                  	</plugins>
                  </pluginManagement>
            

            Fred Bricon added a comment - - edited This is actually covered by JBIDE-11738 . If you follow the workaround described in http://jaitechwriteups.blogspot.fr/2011/02/resource-and-new-lookup-attribute-how.html you just need to : add a <phase> to the maven-dependency-plugin execution. This is a small bug we'll fix in JBDS 6 CR1 right-click on project Maven > Update Project Configuration you might see an error marker on the maven-plugin-compiler plugin if the endorsed lib folder doesn't exist, you can quick fix it http://screencast.com/t/xRjuLJZaYHga also quick fix the maven-dependency-plugin error ("plugin execution not covered"), to mark the goal as ignored in your pom.xml. In JBDS 6.0 , m2e 1.2 will be installed, so you'll be able to do that on a workspace level instead. So your pom.xml should look like : <plugins> ... <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>${version.compiler.plugin}</version> <configuration> <source>${maven.compiler.source}</source> <target>${maven.compiler.target}</target> <compilerArgument>-Djava.endorsed.dirs=${project.build.directory}/endorsed</compilerArgument> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.5</version> <configuration> <!-- Setup the surefire plugin to use the endorsed directory containing the jar for javax.annotation.* classes. Remember that we setup this folder via the maven-dependency-plugin configuration, above. --> <argLine>-Djava.endorsed.dirs=${project.build.directory}/endorsed</argLine> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.1</version> <executions> <execution> <phase>validate</phase> <goals> <goal>copy</goal> </goals> <configuration> <!-- Configure the plugin to copy the jar containing javax.annotation.* to a folder named "endorsed" within the project's build directory --> <artifactItems> <artifactItem> <groupId>org.jboss.spec.javax.annotation</groupId> <artifactId>jboss-annotations-api_1.1_spec</artifactId> </artifactItem> </artifactItems> <outputDirectory>${project.build.directory}/endorsed</outputDirectory> </configuration> </execution> </executions> </plugin> ... </plugins> ... <pluginManagement> <plugins> <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId> org.apache.maven.plugins </groupId> <artifactId> maven-dependency-plugin </artifactId> <versionRange> [2.1,) </versionRange> <goals> <goal>copy</goal> </goals> </pluginExecutionFilter> <action> <ignore></ignore> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin> </plugins> </pluginManagement>

            OP behind the salesforce reference here.

            As to what concerning the "workaround which works fine"

            To resolve for this precedence issue, I followed the trick detailed in [1], meaning:
            Right click on Project -> Build Path -> Configure Build Path... -> then "Order and Export" tab --> move JRE System Library below the Maven dependencies.

            In such a way to have the .classpath file modified to suit ordering as:
            1. Maven
            2. JRE

            In such a way the javax.annotation.Resource will be taken from JavaEE6 libraries instead of the JavaSE Runtime Environment.

            But I agree with the [1] comment author, it seems a dirty approach.

            Thank you very much,
            Ciao,
            Matteo
            [1] https://community.jboss.org/wiki/HackingAS7UsingEclipse#comment-7955

            Matteo Mortari added a comment - OP behind the salesforce reference here. As to what concerning the "workaround which works fine" To resolve for this precedence issue, I followed the trick detailed in [1] , meaning: Right click on Project -> Build Path -> Configure Build Path... -> then "Order and Export" tab --> move JRE System Library below the Maven dependencies. In such a way to have the .classpath file modified to suit ordering as: 1. Maven 2. JRE In such a way the javax.annotation.Resource will be taken from JavaEE6 libraries instead of the JavaSE Runtime Environment. But I agree with the [1] comment author, it seems a dirty approach. Thank you very much, Ciao, Matteo [1] https://community.jboss.org/wiki/HackingAS7UsingEclipse#comment-7955

              fbricon@redhat.com Fred Bricon
              rhn-support-ghu Gary Hu
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: