weblogic - Java ClassLoader Issue or Concurrency Error? -



weblogic - Java ClassLoader Issue or Concurrency Error? -

after weblogic app has been running fine few weeks exception:

<oct 25, 2014 9:31:11 pm edt> <error> <http> <bea-101020> <[servletcontext@60724164[app:whatever3000 module:whatever3000.war path: spec-version:2.5]] servlet failed exception java.lang.exceptionininitializererror

after application defunct noclassdeffounderror until app server restarted.

the total stack trace shows origin of issue concurrentmodificationexception in static initializer.

specifically equivalent / minimized code follows:

package a; import b; public class whatever { void doit() { password p = new password(); } } bundle b; public final class password implements serializable { private static final int param1 = commonstuff.somestaticmethod(); ... } import java.util.properties; public class commonstuff { private static properties prp = new properties(); static { commonstuff.load(); } public static void load() { prp.putall(system.getproperties()); <---fail

this origin of exception:

java.util.concurrentmodificationexception @ java.util.hashtable$enumerator.next(hashtable.java:1017) @ java.util.hashtable.putall(hashtable.java:469) @ b.commonstuff.load(commonstuff.java:55) @ b.commonstuff.<clinit>(commonstuff.java:77) @ b.password.<clinit>(password.java:44) @ a.doit(whatever.java:99)

so seems @ point during runtime of application, weblogic decided reload classes package b when static block runs finds properties object has been modified.

i don't know if it's beingness called concurrently or if it's beingness called multiple times. properties object original instance created when app loaded fresh first time , reloading of commonstuff class trying phone call putall() again.

would help if do:

private static properties prp = null; static { commonstuff.prp = new properties(); commonstuff.load(); }

i cannot seek things blindly because it's in production app @ huge company. i'm trying understand i'm going wrong , how property initialize these variables while classes beingness reloaded in middle of night.

any ideas?

could weblogic classloader issue?

classes/instances cannot access class's members before class initialized. because of no 1 can access newly created prp before static constructor returns. moving prp initializer within on static {} block makes no difference. "old" prp in "old" commonstuff , "new" prp not connected in way (because "old" , "new" commonstuff different classes jvm). create possibility of concurrent modifications of prp pretty weird.

i believe reason in place. notice first line of stack trace: exception thrown enumerator of hashtable. here code of putall method (as in jdk 8, didn't alter many years):

for (map.entry<? extends k, ? extends v> e : t.entryset()) put(e.getkey(), e.getvalue());

here enumerator throws exception - , not prp, argument's enumerator.

so exception related not prp map returned system.getproperties(). reason iterating on scheme properties map not thread safe. seems thread modifying @ same time.

you need initialize prp differently. think clone() simplest way.

java weblogic classloader static-initializer

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -