0
votes

I am using Eclipse for Java EE and AWS Toolkit for Eclipse v2. I'm on a macOS Mojave Version 10.14.5. I have Java 8 installed.

I get errors when I first create an AWS Java Web Project that say "JavaServer Faces 2.2 can not be installed : One or more constraints have not been satisfied." and "JavaServer Faces 2.2 requires Dynamic Web Module 2.5 or newer." as seen in this screenshot:

enter image description here

Here is webproject01/pom.xml:

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.amazonaws.beanstalk</groupId>
  <artifactId>webproject01</artifactId>
  <packaging>war</packaging>
  <version>1.0.0</version>
  <name>archetype-web-app Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-api</artifactId>
      <version>7.0</version>
    </dependency>

    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-ec2</artifactId>
    </dependency>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-s3</artifactId>
    </dependency>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-dynamodb</artifactId>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-bom</artifactId>
        <version>1.11.104</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
</project>

Here's webproject01/bin/pom.xml:

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.amazonaws.beanstalk</groupId>
  <artifactId>webproject01</artifactId>
  <packaging>war</packaging>
  <version>1.0.0</version>
  <name>webproject01 Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>webproject01</finalName>
  </build>
</project>

Here is the web.xml file:

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <display-name>Archetype Created Web Application</display-name>
</web-app>

I would like to get to the point where I can deploy my AWS Java Web Project to AWS via AWS Elastic Beanstalk right from Eclipse.

I have looked at other similar posts on stackoverflow and tried their solutions, but none of them work. They were older posts.

2
Not sure what AWS toolkit has to do with this, but you have to fix your pom.xml to use/include javax.servlet version higher than 2.5. Probably should post that here. If you don't have a pom.xml then you need to edit the project properties but you will be much better off starting with a reasonable maven archetype.K.Nicholas
@K.Nicholas I've tried that as instructed by other posts similar to this one. It looks like I might have to learn more about Maven. I don't even know what an archetype means. I just followed instructions to use Eclipse for Java with AWS Toolkit.Daniel Brower
@K.Nicholas I just put the pom.xml files in the original post. That is before I tried adding other content in them to try to fix the problem.Daniel Brower
Well, your javaee-api dependency should have scope provided. I don't see anything in the AWS-Eclipse-Toolkit about Java EE so I think you are trying something that will ultimately just continue to give you troubles. If you want to play with cloud and Java EE I recommend you open a free account at openshift.com and play there. It will be very Java EE oriented.K.Nicholas
The second one = scope provided.K.Nicholas

2 Answers

2
votes

Maybe someone will be useful.

In case you are using JBoss Tools, then instead of setting the JSF facet for the project

Properties -> Project Facets -> JavaServer Faces (2.3)

it is better to use another option:

Properties -> JBoss Tools Knowledge Base -> JBoss Tools Knowledge Base Support

If you enable this option, then Eclipse auto-completion (content assist) for XHTML (JSF) pages will work fine.

1
votes

You need to upgrade your web.xml to present a newer version:

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
</web-app>

You're currently saying that your web app is a servlet version 2.3 app.