The best place to ask programming/development questions, imo. UPDATE: stackoverflow is the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but a great reference for finding answers.

My Music (Nickleus)


jboss 8 wildfly startup errors (WARN), jrebel 5.5.2 and how to debug/resolve: Failed to define class X, Failed to link X, NoClassDefFoundError, ClassNotFoundException

at work we're in the process of migrating from jboss 7 to 8 (wildfly/undertow) and i've had trouble starting the server when "JRebel agent" is enabled (v5.5.2). i get tons of WARN msgs like this:

15:08:21,372 WARN  [org.jboss.modules] (MSC service thread 1-8) Failed to define class net.sourceforge.barbecue.BarcodePortlet in Module "deployment.myApp.ear:main" from Service Module Loader: java.lang.LinkageError: Failed to link net/sourceforge/barbecue/BarcodePortlet (Module "deployment.myApp.ear:main" from Service Module Loader)
    Caused by: java.lang.NoClassDefFoundError: javax/portlet/GenericPortlet
    Caused by: java.lang.ClassNotFoundException: javax.portlet.GenericPortlet from [Module "deployment.takecargo.ear:main" from Service Module Loader]


using the above WARN as an example, open a java file in your project and write something like this:
BarcodePortlet a = null;



if it resolves (adds an import line), then you have a library somewhere in your project that has that class file.

put the cursor on the class name, BarcodePortlet, then hit f3 to find the jar library, e.g.:

in eclipse project settings:
"Java Build Path" > "Libraries" (tab) > select "barbecue-1.5-alpha2.jar" and hit "Remove" > "OK"

if you get errors in the "Markers" tab, under "Java Problems", then you need the library.
if you don't get any errors, then search your project in *.java and *.xml files to see if the class or package is referenced there. if you still don't find anything then you *probably* don't need it and can delete it from your project.

in my case, some classes were using "barbecue-1.5-alpha2.jar", so then we look at the next related stack trace element in the output console in eclipse:

Caused by: java.lang.NoClassDefFoundError: javax/portlet/GenericPortlet

there wasn't any module in the jboss wildfly modules folders for "javax/portlet":


so i needed to find a jar library, by googling, that has the class "javax.portlet.GenericPortlet", e.g. here:

i added "portlet-api-2.0.jar" to my eclipse project's "lib" folder (or wherever you place your jars to be bundled in your ear)

refreshed the "lib" folder in eclipse

added the jar to the "Libraries" tab:
"Java Build Path" > "Libraries" (tab) > "Add JARs..." > selected "portlet-api-2.0.jar" from the "lib" folder > "OK"

the project rebuilds automatically and no errors occurred from adding the jar, so we're good.

if you rebuild your project and start up wildfly, then that "WARN" should be gone from the output.

No comments:

Post a Comment