How to make my facet appears under "Web Application" category !

Hi

I have developed a basic classes for a new facet and it appears on facets lists on "New Module..." dialogue and works fine. But my facet is a type of web facet and should appear under "Web Application" category (like Struts or JSF). As I know, I should override getPrecedingFrameworkProviderIds on my implementation of FacetTypeFrameworkSupportProvider class. I have already overriden this method and it returns new String[]{getProviderId(WebFacet.ID)};
(just like struts facet source code)

Also, I have added <depends>com.intellij.javaee</depends> to my plugin.xml file. (mentioned at Web Facet thread)

But when I run my project and select "New Module..." from file menu, nothing happens and I give following exception:

java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:89)
at com.intellij.facet.impl.ui.FacetTypeFrameworkSupportProvider.getProviderId(FacetTypeFrameworkSupportProvider.java:6)
.
.
.
.

How can I fix this problem? What's wrong with my code :(

4 comments
Comment actions Permalink

please, use WebFacet.ID for 4th parameter of your facet type constructor.

public class MyFacetType extends FacetType<MyFacet, MyFacetConfiguration>

MyFacetType() {
super(ID, "myFacet", "My Facet", WebFacet.ID);
}
...




0
Comment actions Permalink

Thanks Sergey

I have already passed WebFacet.ID as fourth parameter. But it doesn't work. Also I commented my implementation of getPrecedingFrameworkProviderIds and tried just constructor method alone (and also combined with getPrecedingFrameworkProviderIds ), but it gives me the same exception.

0
Comment actions Permalink

Actually 'getPrecedingFrameworkProviderIds' method should be used if your facet has optional dependencies to another frameworks. In your case it
should be sufficient to pass WebFacet.ID as 'underlyingFacetType' parameter in FacetType constructor.

Looks like in your case JavaEE plugin wasn't properly loaded. Please add the following statements in your code in such a way it will be called before
the exception occurs:

for (FacetTypeId id : FacetTypeRegistry.getInstance().getFacetTypeIds()) {
System.out.println(id);
}

What will be printed in console?

Thanks Sergey

I have already passed WebFacet.ID as fourth parameter. But it doesn't work. Also I commented my implementation of getPrecedingFrameworkProviderIds and tried just constructor method alone (and also combined with getPrecedingFrameworkProviderIds ), but it gives me the same exception.



--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Dear Nikolay

I've already tested this method. It prints javaee as well as all other facets.
My problem was due to my libraries/classpath. I had a depends tag to com.intellij.javaee on my plugin.xml and also I had javaeeimpl jar file on my plugin modules classpath. When I removed this jar file from my library, exception vanished and my facet has listed under web application nicely.

Thnak for your advise.

0

Please sign in to leave a comment.