Rythm エンジンを使用していますが、散発的に以下のエラーが発生し続けます。90% の確率で正常に動作します。スレッドごとに 1 つのインスタンスを作成します
INFO | jvm 1 | 2017/02/14 11:01:12 | java.lang.ClassFormatError: Incompatible magic value 3405691594 in class file C0a10f69e_cfb4_390e_ac5d_bbf66958669e__R_T_C__
INFO | jvm 1 | 2017/02/14 11:01:12 | at java.lang.ClassLoader.defineClass1(Native Method)
INFO | jvm 1 | 2017/02/14 11:01:12 | at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
INFO | jvm 1 | 2017/02/14 11:01:12 | at org.rythmengine.internal.compiler.TemplateClassLoader.loadTemplateClass(TemplateClassLoader.java:297)
INFO | jvm 1 | 2017/02/14 11:01:12 | at org.rythmengine.internal.compiler.TemplateClassLoader.loadClass(TemplateClassLoader.java:254)
INFO | jvm 1 | 2017/02/14 11:01:12 | at org.rythmengine.internal.compiler.TemplateClass.getJavaClass(TemplateClass.java:371)
INFO | jvm 1 | 2017/02/14 11:01:12 | at org.rythmengine.internal.compiler.TemplateClass.templateInstance_(TemplateClass.java:387)
INFO | jvm 1 | 2017/02/14 11:01:12 | at org.rythmengine.internal.compiler.TemplateClass.asTemplate(TemplateClass.java:413)
INFO | jvm 1 | 2017/02/14 11:01:12 | at org.rythmengine.internal.compiler.TemplateClass.asTemplate(TemplateClass.java:419)
INFO | jvm 1 | 2017/02/14 11:01:12 | at org.rythmengine.RythmEngine.getTemplate(RythmEngine.java:924)
INFO | jvm 1 | 2017/02/14 11:01:12 | at org.rythmengine.RythmEngine.getTemplate(RythmEngine.java:945)
INFO | jvm 1 | 2017/02/14 11:01:12 | at org.rythmengine.RythmEngine.render(RythmEngine.java:1019)
これがエンジンを作成する方法です
public class RythmEngineUtil {
/**
* clear the rythm Pre compiled data
*/
static{
try {
File dir = new File("./", "__rythm");
if(!dir.exists()){
dir.mkdir();
}else{
deleteDirAndChildren(dir);
}
}catch(Exception e){
e.printStackTrace();
}
}
private static void deleteDirAndChildren(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
new File(dir, children[i]).delete();
}
}
}
/**
* Initilize Rythm Engine
*/
private static ThreadLocal<RythmEngine> rythmEngine = new ThreadLocal<RythmEngine>() {
protected RythmEngine initialValue() {
Map<String, Object> conf = new HashMap<String, Object>();
conf.put("rythm.codegen.compact", false);
conf.put("engine.precompile_mode", true);
conf.put("engine.load_precompiled", true);
conf.put("home.template","xyz/some");
conf.put("home.precompiled.dir", new File("./", "__rythm"));
RythmEngine engine = new RythmEngine(conf);
System.out.println("Got new RythmEngine -" + engine.getId());
return engine;
}
};
public static RythmEngine getEngine() {
return rythmEngine.get();
}
private RythmEngineUtil() {
}
private static RythmEngineUtil _instance = new RythmEngineUtil();
public static RythmEngineUtil getInstance() {
return _instance;
}
}
そして、それを次のように使用します
RythmEngineUtil.getEngine()