环境:play-1.2.5
我需要在启动play框架应用程序时将数据放到数据库中,所以我让它在Bootstrap.java中完成。
基本上,我只是为它调用一个Model和一个新实例,并重复地将数据存储到数据库中。如下所示。
{
MagazineType magazineType = new MagazineType();
magazineType.abbreviation = "XX";
magazineType.save();
{
{
MagazineTypeFirstCat magazineTypeFirstCat = new MagazineTypeFirstCat();
magazineTypeFirstCat.name = "XX_First";
magazineTypeFirstCat.magazineType = magazineType;
magazineTypeFirstCat.save();
{
{
MagazineTypeSecondCat magazineTypeSecondCat = new MgazineTypeSecondCat();
magazineTypeSecondCat.name = "XX_Second_1";
magazineTypeSecondCat.magazineTypeFirstCat = magazineTypeFirstCat;
magazineTypeSecondCat.save();
}
{
MagazineTypeSecondCat magazineTypeSecondCat = new MgazineTypeSecondCat();
magazineTypeSecondCat.name = "XX_Second_2";
magazineTypeSecondCat.magazineTypeFirstCat = magazineTypeFirstCat;
magazineTypeSecondCat.save();
}
}
}
}
}
但是数据非常大,所以Bootstrap.java中的代码长度超过了5000行。
当代码长度低于3000行时,火焰就会很好地启动,但如果代码长度超过3000行,则会出现异常。
以下是异常的日志,任何建议都将不胜感激。提前谢谢。
14:42:20,855警告〜你正在玩Play!在DEV模式下 14:42:21,023 INFO~在端口9000上侦听HTTP(等待第一个请求开始)...
14:42:35,275错误〜
@ 6edp5mkl9
请求GET /
的内部服务器错误(500)
糟糕:UnexpectedException
由异常引起的意外错误UnexpectedException:在应用类时 boot.craploading.enhancers.PropertiesEnhancer on Bootstrap
play.exceptions.UnexpectedException:在Bootstrap上应用play.CorePlugin@1f0b7d3时
at play.plugins.PluginCollection.enhance(PluginCollection.java:454)
at play.classloading.ApplicationClasses $ ApplicationClass.enhance (ApplicationClasses.java:208)
at play.classloading.ApplicationClassloader.loadApplicationClass(ApplicationClassloader.java:157)
at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:417)
at play.classloading.ApplicationClassloader.getAssignableClasses(ApplicationClassloader.java:441)
at {module:crud} /app/views/tags/crud/types.tag。(第3行)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:229)
at play.templates.GroovyTemplate $ ExecutableTemplate.invokeTag(GroovyTemplate.java:374)
at {module:crud} / conf / routes。(line:4)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:229)
at play.templates.Template.render(Template.java:26)
at play.templates.GroovyTemplate.render(GroovyTemplate.java:184)
at play.mvc.Router.parse(Router.java:162)
at play.mvc.Router.parse(Router.java:190)
at play.mvc.Router.parse(Router.java:164)
at play.mvc.Router.load(Router.java:50)
at play.mvc.Router.detectChanges(Router.java:219)
在Invocation.HTTP请求(播放!)
引起:play.exceptions.UnexpectedException:在Bootstrap上应用类play.classloading.enhancers.PropertiesEnhancer时
at play.CorePlugin.enhance(CorePlugin.java:296)
at play.plugins.PluginCollection.enhance(PluginCollection.java:451)
at play.classloading.ApplicationClasses $ ApplicationClass.enhance(ApplicationClasses.java:208)
at play.classloading.ApplicationClassloader.loadApplicationClass(ApplicationClassloader.java:157)
at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:417)
at play.classloading.ApplicationClassloader.getAssignableClasses(ApplicationClassloader.java:441)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite $ PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:229)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
在Template_1001 $ _run_closure1.doCall(types.tag:6)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:273)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
在Template_1001 $ _run_closure1.doCall(types.tag)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod (ClosureMetaClass.java:273)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
在groovy.lang.Closure.call(Closure.java:282)
at groovy.lang.Closure.call(Closure.java:277)
at org.codehaus.groovy.runtime.GroovyCategorySupport $ ThreadCategoryInfo.use(GroovyCategorySupport.java:99)
at org.codehaus.groovy.runtime.GroovyCategorySupport $ ThreadCategoryInfo.access $ 300(GroovyCategorySupport.java:61)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:239)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.use(DefaultGroovyMethods.java:333)
at org.codehaus.groovy.runtime.dgm $ 717.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite $ PogoMetaMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:307)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:51)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:153)
在Template_1001.run(types.tag:2)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:229)
at play.templates.GroovyTemplate $ ExecutableTemplate.invokeTag(GroovyTemplate.java:374)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:362)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:161)
在Template_1000 $ _run_closure1.doCall(路线:41)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:273)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
在Template_1000 $ _run_closure1.doCall(路线)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:273)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
在groovy.lang.Closure.call(Closure.java:282)
at groovy.lang.Closure.call(Closure.java:277)
at org.codehaus.groovy.runtime.GroovyCategorySupport $ ThreadCategoryInfo.use(GroovyCategorySupport.java:99)
at org.codehaus.groovy.runtime.GroovyCategorySupport $ ThreadCategoryInfo.access $ 300(GroovyCategorySupport.java:61)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:239)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.use(DefaultGroovyMethods.java:333)
at org.codehaus.groovy.runtime.dgm $ 717.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite $ PogoMetaMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:307)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:51)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:153)
在Template_1000.run(路线:2)
... 9更多
引起:javassist.CannotCompileException:无效的操作码地址
at javassist.expr.ExprEditor.doit(ExprEditor.java:116)
at javassist.CtBehavior.instrument(CtBehavior.java:618)
at play.classloading.enhancers.PropertiesEnhancer.enhanceThisClass(PropertiesEnhancer.java:130)
at play.CorePlugin.enhance(CorePlugin.java:293)
... 83更多
引起:javassist.bytecode.BadBytecode:无效的操作码地址
at javassist.bytecode.CodeIterator.nextOpcode(CodeIterator.java:586)
at javassist.bytecode.CodeIterator.next(CodeIterator.java:157)
在javassist.bytecode.stackmap.Liveness.analyze(Liveness.java:237)
at javassist.bytecode.stackmap.Liveness.computeUsage(Liveness.java:216)
at javassist.bytecode.stackmap.Liveness.compute(Liveness.java:38)
at javassist.bytecode.stackmap.TypedBlock.makeBlocks(TypedBlock.java:54)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:91)
at javassist.bytecode.MethodInfo.rebuildStackMap(MethodInfo.java:404)
at javassist.bytecode.MethodInfo.rebuildStackMapIf6(MethodInfo.java:389)
at javassist.expr.ExprEditor.doit(ExprEditor.java:112)
... 86更多
答案 0 :(得分:3)
Java类大小限制为64 kb,因此您的类可能太大。
对于这样的用例,我更喜欢将所有thi初始化放在sql文件中并在bootstrap中使用sql load脚本,它可以更好地扩展。