14 Replies Latest reply on Jul 15, 2014 2:11 AM by maxandersen

    When I update the project (Maven > update project (Alt+F5)) I get some weird facets/natures added

    mr_and_mrs_d

      System:

       

      Eclipse Java EE IDE for Web Developers.

      Version: Luna M7 Release (4.4.0M7)

      Build id: 20140508-1440

      JBossAS Tools    3.0.0.Beta1-v20140408-1231-B31

       

      When I hit Alt+F5 I get:

      diff.jpg

      (heck I tried _hard_ to post the git diff but I have no luck with the editor)

       

      My pom:

       

      <project xmlns="http://maven.apache.org/POM/4.0.0"

          xmlns:xsi=

          "http://www.w3.org/2001/XMLSchema-instance"

          xsi:schemaLocation=

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

          <modelVersion>4.0.0</modelVersion>

          <groupId>gr.uoa.di.regas.monitoring.server</groupId>

          <artifactId>DataCollectionServlet</artifactId>

          <version>0.0.1-SNAPSHOT</version>

          <packaging>war</packaging>

          <properties>

              <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

          </properties>

          <dependencies>

              <dependency>

                  <groupId>org.glassfish.web</groupId>

                  <artifactId>javax.servlet.jsp.jstl</artifactId>

                  <version>1.2.1</version>

                  <scope>provided</scope>

              </dependency>

              <dependency>

                  <groupId>ch.qos.logback</groupId>

                  <artifactId>logback-classic</artifactId>

                  <version>1.1.2</version>

              </dependency>

              <dependency>

                  <groupId>net.lingala.zip4j</groupId>

                  <artifactId>zip4j</artifactId>

                  <version>1.3.1</version>

              </dependency>

          </dependencies>

          <build>

              <sourceDirectory>src</sourceDirectory>

              <plugins>

                  <plugin>

                      <artifactId>maven-compiler-plugin</artifactId>

                      <version>3.1</version>

                      <configuration>

                          <source>1.7</source>

                          <target>1.7</target>

                      </configuration>

                  </plugin>

                  <plugin>

                      <artifactId>maven-war-plugin</artifactId>

                      <version>2.4</version>

                      <configuration>

                          <warSourceDirectory>WebContent</warSourceDirectory>

                          <failOnMissingWebXml>false</failOnMissingWebXml>

                      </configuration>

                  </plugin>

              </plugins>

          </build>

      </project>

       

       

      So what are those

       

      +  <installed facet="jst.jaxrs" version="1.1"/>

      +  <installed facet="jst.jsf" version="2.1"/>

       

      and

       

       

      +        <nature>org.jboss.tools.jst.web.kb.kbnature</nature>

      +        <nature>org.jboss.tools.jsf.jsfnature</nature>

       

      and why are they added ?

       

      Thanks

        • 1. Re: When I update the project (Maven > update project (Alt+F5)) I get some weird facets/natures added
          maxandersen

          the natures are what enables tooling to provide content assist for your web project.

          The facets are added because its detected either jaxrs or jsf features are used in the project.

           

          Are you seeing this as not relevant for your project ?

          1 of 1 people found this helpful
          • 2. Re: When I update the project (Maven > update project (Alt+F5)) I get some weird facets/natures added
            mr_and_mrs_d

            Thanks!

             

            yes I see the facets as not relevant for my project - the particular project is a vanilla servlet/jsp project - no java EE - why have jsf/jaxrs (web services ?) added to it ?

             

            Not sure who implements Alt+F5 - is it the Jboss tools or m2e ?

             

            Here is the commit on git hub:

             

            https://github.com/Utumno/DataCollectionServlet/commit/659aa9673ad359e55e7d0a7663e3ceaa2a65d95e

             

            The project runs fine in eclipse (RClick > Run as > Run on server without those facets/natures)

             

            Any links on the natures ?

             

            this was an old servlet jsp project I am trying to mavenize to use with openshift - I am new to maven

             

            EDIT: I forgot to say I'd seen this: [JBIDE-5162] Add KB builder/nature to web projects in our Project Examples. - JBoss Issue Tracker - but I think this should only be applicable to the example projects (I have installed those too IIRC) - but not to users projects ?

            • 3. Re: When I update the project (Maven > update project (Alt+F5)) I get some weird facets/natures added
              mr_and_mrs_d

              Well - the jaxrs entries were added by the m2e-wtp - unchecking the Java EE configurators here:

               

              Clipboard02.jpg

               

              I got rid of them - counterintuitive and probably a bug - I did not need them in my web project

               

              On the other hand I think that the <name>org.jboss.tools.jst.web.kb.kbbuilder</name> was not installed because I did not install the "projects" from the Jboss tools update site in my final Luna install I had previously:

               

              - JBoss Maven Project Examples (1.6.0.Beta1-v20140408-0006-B27)

              - Project Examples (1.6.0.Beta1-v20140408-0006-B27)

               

              Now - I still do not get why those got installed in the first place - any clarification on this ?

              • 4. Re: When I update the project (Maven > update project (Alt+F5)) I get some weird facets/natures added
                xcoulon

                Hello Palmer,

                 

                JBoss Tools provides users with m2e-wtp extensions that trigger extra configuration in your project when some maven dependencies are detected in your project. So, in your case, the JAX-RS Facet will be added in your project if your project classpath contains some known JAX-RS classes or annotations (instead of relying on the name of the jar). If you had the JBoss Tools Web Services component installed, then the JBoss Tools JAX-RS nature (and project builder) would have been installed in cascade.

                The goal of this Maven integration is to ease the project configuration, in such a way that the user only needs to add Maven dependencies, without having to further configure the project in Eclipse.

                 

                HTH.

                 

                Best regards,

                Xavier

                • 5. Re: When I update the project (Maven > update project (Alt+F5)) I get some weird facets/natures added
                  mr_and_mrs_d

                  Hello Xavier,

                   

                  Unticking the Java EE configurators in the picture I made it stop adding the  JAX-RS facet. I think the heuristics could be improved - my project had nothing to do with  JAX-RS.

                   

                  On the other hand when I removed the:

                   

                  - JBoss Maven Project Examples (1.6.0.Beta1-v20140408-0006-B27)

                  - Project Examples (1.6.0.Beta1-v20140408-0006-B27)

                   

                  also the :

                   

                  <nature>org.jboss.tools.jst.web.kb.kbnature</nature>

                  <nature>org.jboss.tools.jsf.jsfnature</nature>

                   

                  were removed as well as <name>org.jboss.tools.jst.web.kb.kbbuilder</name>.

                   

                  Why exactly were those added ?

                   

                  In all I found the additions to my classpath distracting - maybe display a dialog and ask the user ? Or should I bug them at m2e-wtp ?

                   

                  Although at least the:

                   

                  <nature>org.jboss.tools.jst.web.kb.kbnature</nature>

                  <nature>org.jboss.tools.jsf.jsfnature</nature>

                   

                  are from the JBoss tools in particular

                   

                  NB:.classpath etc are versioned

                   

                  Cheers

                  • 6. Re: When I update the project (Maven > update project (Alt+F5)) I get some weird facets/natures added
                    xcoulon

                    Palmer,

                     

                    Looking again at your pom.xml, I can't see any JAX-RS, CDI or JSF dependencies, but by any chance, did you configure add your 'server runtime library' in your  'project build path' ? that could explain why the m2e-wtp integration extension found some JAX-RS/CDI/JSF classes and then added the natures you reported.

                    If it is the case, please avoid doing this way, but instead, add the maven dependencies with a 'provided' scope in your pom.xml, this is much better/safer (for example if you want to build your project from the command line on a CI system).

                     

                    Aside from the extra natures added, did you notice anything wrong in Eclipse once those natures were added ?

                     

                    Thanks

                    Best regards,

                    Xavier

                    • 7. Re: When I update the project (Maven > update project (Alt+F5)) I get some weird facets/natures added
                      fbricon

                      Palmer, your classpath contains references to 2 server runtimes (DataCollectionServlet/.classpath at 6bdf1d393b5aba86155c0449d61466916cff15f3 · Utumno/DataCollectionServlet · GitHub)

                      Since JAX-RS, JSF, CDI classes are available via these classpath entries, the configurators add the relevant facets.

                       

                      As Xavier said, you should totally avoid that. If you depend on a class provided by the runtime, then it'll compile in Eclipse but not in Maven CLI builds. Moreover, this kind of classpath entry is not portable, i.e you can not guarantee someone else working on the project will use the exact same runtime names in the workspace. They're definitely not required to build the project and provide absolutely zero benefit when using Maven.

                       

                      And adding pop-ups during project configuration wouldn't scale when multiple projects are imported and would likely disrupt the whole user experience.

                       

                      In case you want to make sure the JAX-RS, JSF, JPA configurators never mess up with your project, you can add maven properties to your pom, see https://wiki.eclipse.org/M2E-WTP/New_and_Noteworthy/1.0.0#Enable.2FDisable_the_JAX-RS.2FJPA.2FJSF_Configurators_at_the_p…

                      1 of 1 people found this helpful
                      • 8. Re: When I update the project (Maven > update project (Alt+F5)) I get some weird facets/natures added
                        mr_and_mrs_d

                        Thanks a lot for the interest, Xavier and Fred

                         

                        Re: JAX-RS (solved - not JBoss Tools)

                        I am new to maven (but not to eclipse) so my .classpath is a work in progress at the moment trying various options (btw the version I hit Alt-F5 on is: DataCollectionServlet/.classpath at 661eb4cb7047da86cde2b735874c3200e1c41dd3 · Utumno/DataCollectionServlet · GitHub) - I have _not_ yet removed the runtimes but Alt+F5 does not add the JAX-RS facet anymore _cause I unchecked the items in the preferences_. So this (adding the JAX-RS etc) is not a JBoss Tools issue rather a m2e-wtp one - will report there as their heuristics should be improved (detect the runtime server container and be smarter on what they add to the project, based on imports ?).

                         

                        The runtimes not being portable seems like an oversight (I had filled a bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=416308) - at least in JBoss we will soon be able to specify execution environments for the server runtime : Assign Java SE7 Execution environment in JBoss 7.1 server runtime - a step in the right direction

                        I do understand maven can do this for me - and will clean the .classpath up eventually

                         

                        @Fred: Thanks for the m2e-wtp links, will go through!

                         

                        Re:

                         

                        <nature>org.jboss.tools.jst.web.kb.kbnature</nature>

                        <nature>org.jboss.tools.jsf.jsfnature</nature>

                         

                        I still need some info on those to close this - are they added when I add

                         

                        - JBoss Maven Project Examples (1.6.0.Beta1-v20140408-0006-B27)

                        - Project Examples (1.6.0.Beta1-v20140408-0006-B27)

                         

                        as I think ?

                         

                        Cheers

                        • 9. Re: When I update the project (Maven > update project (Alt+F5)) I get some weird facets/natures added
                          fbricon

                          m2e-wtp's JSF Configurator, when active, detects JSF classes in the classpath hence adds the JSF Facet. JBoss Tools JSF tooling listens to this event and adds these natures to enhance JSF tooling.

                          The Project Examples feature has a transitive dependency on JBoss Tools JSF Tooling which causes that behavior.


                          JBoss Maven Project Examples is an extension to Project Examples. So you can install just Project Examples, but if you select Maven Project Examples only, Project Examples will be dragged in as a required dependency anyway.

                          Those features are not critical to do any development as, as their name suggest, they only bring project examples to you IDE. Which can be a good thing if you want to learn more about some JBoss or Java EE technologies and Maven



                          • 10. Re: When I update the project (Maven > update project (Alt+F5)) I get some weird facets/natures added
                            mr_and_mrs_d

                            Ok - thanks!

                             

                            I still believe that hose natures shouldn't be added to the .project file - or at least have a comment added that explains what they are - or elaborate in the description in the "install new software" dialog for the JBoss Maven Project Examples. User would expect that installing example projects would do just that: install those projects - but not mess with the .project/.classpath files of existing projects on Alt+F5.

                             

                            @Xavier - I would like to mark your answer as helpful but do not seem to be able.

                            • 11. Re: When I update the project (Maven > update project (Alt+F5)) I get some weird facets/natures added
                              xcoulon

                              Hello Palmer,

                               

                              No worries, I'm glad we could help you here ;-)

                              • 12. Re: When I update the project (Maven > update project (Alt+F5)) I get some weird facets/natures added
                                maxandersen

                                Palmer, just to conclude this - the intent is that you do *not* need to commit the .project file to your source control if you are using pom.xml/maven. Thus you should not need to care. You also don't see comments for what the jdt and other builders are.

                                 

                                Of course if we make things worse then we would like to know - but intent is that you do not have to manually enable features, but if you don't like it to auto-enabled can disable the auto-enablement.

                                 

                                We did that because we realized many users didn't even know we had improved support for jsp,xhtml, etc. editing when they used maven which does not typically have .project files committed.

                                • 13. Re: When I update the project (Maven > update project (Alt+F5)) I get some weird facets/natures added
                                  mr_and_mrs_d

                                  Well the .project file was committed to source control before I mavenized the project - and it should not make any difference - it just makes the project straightforward to open in eclipse

                                   

                                  My comment on comments was just an idea - the point is that this <nature>org.jboss.tools.jsf.jsfnature</nature> and <nature>org.jboss.tools.jst.web.kb.kbnature</nature> just turn up there - on a non JSF project for the jsfnature (it just saw the server runtime libs and added JSF + jaxrs) and _more importantly_ the kbnature is enabled I think when I have the example projects added. I still do not quite grok why it should add this nature to my project. As I say above:

                                   

                                  > User would expect that installing example projects would do just that: install those projects - but not mess with the .project/.classpath files of existing projects on Alt+F5.

                                   

                                  Well I personally managed to keep my project files clean - not sure though if I disabled the "improved support for jsp,xhtml, etc. editing" while doing so (?)

                                   

                                  Thanks for interest - I will certainly bug you again if I run across anything I don't understand

                                  • 14. Re: When I update the project (Maven > update project (Alt+F5)) I get some weird facets/natures added
                                    maxandersen

                                    if you do not have these in the eclipse project you simply wont get the extra contentassist and open-on navigation or find references support jboss tools provide for things like JSF and CDI beans.

                                     

                                    They are added as Fred explains because you have references to a runtime that provides CDI/JSF classpath entries to your project.  If you do not need those dependencies I suggest you remove them and these entries to provide the additional support won't be there.