IBM Support

ClassCastException when performing Java EE related tasks

Troubleshooting


Problem

IBM Rational Application Developer for WebSphere Software reports ClassCastExceptions in a popup window at startup, or in the Error log when trying to perform Java EE related tasks, such as adding modules to an EAR, configuring Utility modules or setting Module Dependencies. These errors prevent you from compiling or building your projects.

Symptom

Java EE related tasks fail, and error messages similar to the following are seen in the workspace and or Error logs:

java.lang.ClassCastException: org.eclipse.jst.j2ee.application.internal.impl.ApplicationImpl cannot be cast to org.eclipse.jst.javaee.application.Application

If you are using Maven to import projects, the error message may look like this:

!ENTRY org.eclipse.core.jobs

!MESSAGE An internal error occurred during: "Updating Maven Configuration".

!STACK 0

java.lang.ClassCastException: org.eclipse.jst.j2ee.application.internal.impl.ApplicationImpl incompatible with org.eclipse.jst.javaee.application.Application
at org.maven.ide.eclipse.wtp.EarProjectConfiguratorDelegate.updateLibDir(Unknown Source)

at
org.maven.ide.eclipse.wtp.EarProjectConfiguratorDelegate.setModuleDependencies(Unknown Source)

Cause

The problem is caused if there is a mismatch between the EAR version configuration, and the EAR facet version installed in the project. This can happen if you use automated tasks to create and/or configure your projects.

Diagnosing The Problem

  1. Click on "View Menu" in the Enterprise explorer and select "Filters". Uncheck ".* resources" and press OK

  2. Open the files org.eclipse.wst.common.project.facet.core.xml and org.eclipse.wst.common.component in the .settings folder of your EAR project.

  3. Compare this line in org.eclipse.wst.common.project.facet.core.xml:

    <installed facet="jst.ear" version="5.0"/>

    with this line in org.eclipse.wst.common.component:

    <project-modules id="moduleCoreId" project-version="1.5.0">

Resolving The Problem

Ensure that the Installed Facet version compares to the Project Version.

Review the following table for reference.

To change the installed facet:

  1. Right-click on your EAR project
  2. Select Properties > Project Facets
  3. Change the EAR version number by using the drop down menu.

org.eclipse.wst.common.project.facet.core.xmlorg.eclipse.wst.common.component
<installed facet="jst.ear" version="6.0"/><project-modules id="moduleCoreId" project-version="1.6.0">
<installed facet="jst.ear" version="5.0"/><project-modules id="moduleCoreId" project-version="1.5.0">
<installed facet="jst.ear" version="1.4"/><project-modules id="moduleCoreId" project-version="1.4.0">
<installed facet="jst.ear" version="1.3"/><project-modules id="moduleCoreId" project-version="1.3.0">

[{"Product":{"code":"SSRTLW","label":"Rational Application Developer for WebSphere Software"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"J2EE Tooling","Platform":[{"code":"PF033","label":"Windows"}],"Version":"8.0;7.5.5","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
16 June 2018

UID

swg21474288