Bug 270090 - ClassCastException in JavaEEArchiveUtilities when publishing
Summary: ClassCastException in JavaEEArchiveUtilities when publishing
Status: ASSIGNED
Alias: None
Product: WTP Java EE Tools
Classification: WebTools
Component: jst.j2ee (show other bugs)
Version: 3.0.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: Future   Edit
Assignee: Rob Stryker CLA
QA Contact: Chuck Bridgham CLA
URL:
Whiteboard:
Keywords: helpwanted
: 249594 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-03-26 05:25 EDT by Thomas CLA
Modified: 2015-05-05 12:43 EDT (History)
5 users (show)

See Also:


Attachments
Mavenized project to setup the eclipse project. (45.77 KB, application/zip)
2009-03-26 05:25 EDT, Thomas CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas CLA 2009-03-26 05:25:48 EDT
Created attachment 129944 [details]
Mavenized project to setup the eclipse project.

Build ID: M20090211-1700

Steps To Reproduce:
1.Download the attached zip-file and unpack it to c:\project\ (or change the workspace entry in the outermost pom, then run mvn install eclipse:eclipse eclipse:add-maven-repo
2.Download Eclipse version: 3.4.2, and install plugin JBoss Tools 3.0.
3.Start Eclipse and select the workspace where the arplab project resides. 4.Import the project. Add a JBoss server.
5.Add the project to the server and try to publish.
The following error message occur:
Could not publish to the server.
org.eclipse.jst.j2ee.application.internal.impl.ApplicationImpl cannot be cast to org.eclipse.jst.javaee.application.Application

And in the log:

java.lang.ClassCastException:
org.eclipse.jst.j2ee.application.internal.impl.ApplicationImpl cannot be cast
to org.eclipse.jst.javaee.application.Application
        at
org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities.refineForJavaEE(JavaEEArchiveUtilities.java:334)
        at
org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities.openArchive(JavaEEArchiveUtilities.java:304)
        at
org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities.openArchive(JavaEEArchiveUtilities.java:143)
        at
org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper$ArchiveCache.openArchive(JavaEEBinaryComponentHelper.java:471)
        at
org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper.openArchive(JavaEEBinaryComponentHelper.java:343)
        at
org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper.getUniqueArchive(JavaEEBinaryComponentHelper.java:332)
        at
org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper.getArchive(JavaEEBinaryComponentHelper.java:325)
        at
org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper.getJavaEEQuickPeek(JavaEEBinaryComponentHelper.java:54)
        at
org.eclipse.jst.j2ee.internal.deployables.J2EEFlexProjDeployable.isNestedJ2EEModule(J2EEFlexProjDeployable.java:654)
        at
org.eclipse.jst.j2ee.internal.deployables.J2EEFlexProjDeployable.shouldIncludeUtilityComponent(J2EEFlexProjDeployable.java:157)
        at
org.eclipse.wst.web.internal.deployables.ComponentDeployable.addUtilMembers(ComponentDeployable.java:353)
        at
org.eclipse.jst.j2ee.internal.deployables.J2EEFlexProjDeployable.members(J2EEFlexProjDeployable.java:263)
        at
org.eclipse.wst.server.core.internal.ModulePublishInfo.fill(ModulePublishInfo.java:398)
        at
org.eclipse.wst.server.core.internal.ServerPublishInfo.fill(ServerPublishInfo.java:361)
        at
org.eclipse.wst.server.core.internal.Server$13.visit(Server.java:2502)
        at
org.eclipse.wst.server.core.internal.Server.visitModule(Server.java:2381)
        at org.eclipse.wst.server.core.internal.Server.visit(Server.java:2365)
        at
org.eclipse.wst.server.core.internal.Server.publishImpl(Server.java:2499)
        at
org.eclipse.wst.server.core.internal.Server$PublishJob.run(Server.java:270)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

My application.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<application 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/application_5.xsd"
             version="5">
             
    <display-name>Seam Registration</display-name>
    
    <module>
        <web>
            <web-uri>webapp-1.0-SNAPSHOT.war</web-uri>
            <context-root>/arplab</context-root>
        </web>
    </module>
   
    <module>
        <ejb>arp-1.0-SNAPSHOT.jar</ejb>
    </module>
    
     <module>
        <ejb>jboss-seam-2.1.1.CR1.jar</ejb>
    </module>
    
   </application>

Note, if a remove the seam module entry it will publish, but then I manually have to add this entry where the file has been published. Any module that has a reference to a jar that is not a part of the project won't work.

Version of jst: org.eclipse.jst.j2ee_1.1.206.v200902052030.jar

Best regards,
Thomas
Comment 1 Stefan Franke CLA 2009-04-02 03:59:05 EDT
this is a duplicate of bug 249594

https://bugs.eclipse.org/bugs/show_bug.cgi?id=249594
Comment 2 Jason Sholl CLA 2009-04-02 11:04:41 EDT
*** Bug 249594 has been marked as a duplicate of this bug. ***
Comment 3 Stefan Franke CLA 2009-04-02 13:59:57 EDT
note that a suggested fix is filed under bug 249594!
Comment 4 Carl Anderson CLA 2009-05-20 22:02:26 EDT
3.0.5 is shut down - moving to the next open development stream, which is
3.1.1.
Comment 5 Carl Anderson CLA 2010-02-04 02:08:05 EST
Moving to WTP 3.2, but a lot of work has been done in this area.  Is this still a problem?
Comment 6 Thomas CLA 2010-02-04 02:44:50 EST
(In reply to comment #5)
> Moving to WTP 3.2, but a lot of work has been done in this area.  Is this still
> a problem?

I'll upgrade and check if it still a problem during the day.
Comment 7 Stefan Franke CLA 2010-02-04 04:51:06 EST
This is still a problem.

It occurs if your JEE modules are using descriptors for different JEE versions.

This should cause that bug:

application.xml
<application 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee/application_5.xsd" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    version="1.5"
>

ejb-jar.xml
<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0">
Comment 8 Rob Stryker CLA 2010-06-02 04:54:37 EDT
I'm assigning this to jsholl as he's much more familiar with the IArchive stuff than I am.
Comment 9 Jason Sholl CLA 2010-06-08 09:37:52 EDT
This fell off my radar.  This appears to be a simple mismatch of the archive version.  The fix should be simple; something along the lines as mentioned in  bug 249594.  Targeting for WTP 3.2.1
Comment 10 Jason Sholl CLA 2010-08-31 11:45:20 EDT
Routing over to you Rob.  Seems that this is not reproducible without the JBoss Tools and I'm not sure what the licensing implications are for me to install those.  This may have already been fixed in 3.2 with bug 296342
Comment 11 Thomas CLA 2010-09-13 04:28:35 EDT
I have elaborated with this bug and I have located and fixed the problem for OUR project setup. The classcastexception is one issue, but fixing this by adding an instanceof check in the if statement only results in that we don't get a classcastexception, the jars still doesn't get published. I looked a bit deeper into it, and to publish our ejb jars that don't is a part of the project I never call the refineForJavaEE method. I no too little to be able to file a proper patch, but if I can help you in any other way, I'm glad to do so.
Comment 12 Carl Anderson CLA 2010-09-23 14:06:34 EDT
Rob, since 3.2.2 is declaring, I am retargetting to 3.2.3.  Please retarget as appropriate.
Comment 13 Rob Stryker CLA 2011-01-20 15:24:18 EST
Retargeting bugs that won't make it into 3.2 maintenance
Comment 14 Rob Stryker CLA 2011-03-29 15:32:38 EDT
Since some people are still experiencing this problem, I thought it'd be a good idea to point out comment 7 still has the relevant information here.

This bug is caused when your project's facet version differs from the version specified in the descriptor of your module. 

So if your module is a web 2.5 project or has the jst.web 2.5 facet, and it has a web.xml that says version="2.4", this bug will occur. 

As comment 11 stated, the code here is really complicated and the previous master of the responsible code has been mostly re-assigned. This is a hard one to patch, but since there's still a workaround available, this isn't a priority for us to fix unless someone contributes a patch.

Even if someone could provide a valid usecase where they require a 2.5 facet and a 2.4-versioned descriptor (doubtful, I believe), I'm afraid this bug probably still won't get resolved without a contributor patch.
Comment 15 Rob Stryker CLA 2011-06-02 03:40:23 EDT
Sad to say, but without community assistance or further input, this is being delayed indefinitely.
Comment 16 Edoz BAR CLA 2015-05-05 12:43:32 EDT
Same problems here 

java.lang.ClassCastException: org.eclipse.jst.j2ee.application.internal.impl.ApplicationImpl cannot be cast to org.eclipse.jst.javaee.application.Application
	at org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil.getPotentialComponentClasspathDependencies(ClasspathDependencyUtil.java:220)
	at org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator.validateInJob(ClasspathDependencyValidator.java:93)
	at org.eclipse.wst.validation.internal.operations.ValidatorJob.run(ValidatorJob.java:78)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)


eclipse.buildId=M20130204-1200
java.version=1.6.0_22
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=it_IT
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.jee.product