Why is Wildfly looking for a version of my Class ending in a $?
gberish Mar 17, 2016 12:07 AMI have a MDB deployed in and ear package on WildFly Full 9.0.2.Final.
In onMessage() I have this line of code:
Integer sessionType = SessionValuesTK.getSessionForAction (actionType);
It throws this to the server log:
...
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/america3/gotest/server/interfaces/SessionValues$1
at org.america3.gotest.server.messaging.GoMsgBean.delegateToSession(GoMsgBean.java:301)
at org.america3.gotest.server.messaging.GoMsgBean.onMessage(GoMsgBean.java:169)
... more
Caused by: java.lang.ClassNotFoundException: org.america3.gotest.server.interfaces.SessionValues$1 from [Module "deployment.GoTest.ear.GoTest.jar:main
" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)
... more
Everything I read suggests its because my code has an Enum or inner class somewhere, but I don't.
Here's the Class and the interface it implements that go with that line:
Notes:
I pasted the whole Class and Interface code since I couldn't find a way to get a simple example that threw that Exception. The static final int values are int, because I use them an a switch() method and they don't like Integers. BUT ... I took that switch() out when I got the above error.
I no longer think it was such a great idea to create a separate Class to hold the method used to look up Interface variables, and I'd welcome code criticism, BUT ... I right now I'm fixated on why the heck WildFly keeps looking for SessionValues$1.
GoTest.ear definitely contains GoTest.jar, and the jar definitely contains
org.america3.gotest.server.interfaces.SessionValues, and
org.america3.gotest.server.interfaces.SessionValueTK.
Just no SessionValues$1!
THE CLASS that holds the static method:
package org.america3.gotest.server.interfaces;
public class SessionValuesTK implements SessionValues{
//Method that seems to throw the Exception.
static public Integer getSessionForAction (Integer actionType) {
if (actionType == null || !ACTION_SESSION_MAP.keySet().contains(actionType)) {
return BAD_SESSION_TYPE;
}
return ACTION_SESSION_MAP.get(actionType);
}
}
THE INTERFACE:
package org.america3.gotest.server.interfaces;
public interface SessionValues {
static public Integer getTestedSessionType (Integer sessionType) {
if (sessionType == null ||
sessionType.equals (BAD_SESSION_TYPE) ||
!SESSION_NAMES.keySet().contains (sessionType)) {
return BAD_SESSION_TYPE;
} else {
return sessionType;
}
}
static public final int BASE = 6579;
static public final int BAD_SESSION_TYPE = 1 + BASE;
static public final int LOGGER = 1 + BAD_SESSION_TYPE;
static public final int ENROLLER = 1 + LOGGER;
static public final int FILER = 1 + ENROLLER;
static public final int PLAYER = 1 + FILER;
static public final int TESTER = 1 + PLAYER;
static public final HashMap<Integer, String> SESSION_NAMES = new HashMap<Integer, String> () {
public static final long serialVersionUID = 1L;
{ put (BAD_SESSION_TYPE, "Bad Session Type");
put (LOGGER, "Logger");
put (ENROLLER, "Enroller");
put (FILER, "Filer");
put (PLAYER, "Player");}
};
// Map Action type to Session type
static public final HashMap<Integer, Integer> ACTION_SESSION_MAP = new HashMap<Integer, Integer> () {
public static final long serialVersionUID = 1L;
{ put (ActionValues.GAME_DELETE, FILER);
put (ActionValues.ENROLL, ENROLLER);
put (ActionValues.EXIT, LOGGER);
put (ActionValues.GAME_LOAD, FILER);
put (ActionValues.LOG_OUT, LOGGER);
put (ActionValues.LOG_IN, LOGGER);
put (ActionValues.GAME_LOAD, FILER);
put (ActionValues.NOTIFY_SERVER_NEW_STONE, PLAYER);
put (ActionValues.NOTIFY_SERVER_NEW_PASS, PLAYER);
put (ActionValues.GAME_FETCH, FILER);
put (ActionValues.GAME_GET_DELETE_LIST, FILER);
put (ActionValues.GAME_GET_LOAD_LIST, FILER);
put (ActionValues.GAME_SAVE_AS, FILER);}
};
}