部署时的飞路迁移:检测到对 close() 的非法调用
Flyway migration on deployment: Illegal call to close() detected
我们正在 GlassFish (3.1.2.2b5) 上构建 Java EE 6 .ear
应用程序 运行 并使用 Flyway (3.2.1) 来管理我们的数据库架构。这发生在部署 .ear
时 - 网络上有一篇名为 "Easy Database Migrations using Flyway, Java EE 6 and GlassFish" 的文章很好地概述了如何执行此操作。我们最低限度地采用了迁移器代码,本质上只有 changing/removing 一些日志记录:
@Singleton
@Startup
public class FlywayMigrator {
private final static Logger LOG = Logger.getLogger(FlywayMigrator.class.getName());
@Resource(lookup = "jdbc/myDS")
private DataSource dataSource;
@PostConstruct
private void onStartup() {
if (dataSource == null) {
LOG.severe("Cannot migrate, no datasource configured!");
throw new EJBException("Cannot migrate, no datasource configured!");
}
Flyway flyway = new Flyway();
flyway.setBaselineOnMigrate(true);
flyway.setDataSource(dataSource);
flyway.migrate();
}
}
现在的问题是,这在迁移方面非常有效 - 不能说完美。但是,它确实会导致每次在日志中打印三个相同的警告:
[#|2015-06-08T13:40:23.400+0200|WARNING|glassfish3.1.2|javax.enterprise.system.core.classloading.com.sun.enterprise.loader|_ThreadID=42;_ThreadName=Thread-2;|Illegal call to close() detected
java.lang.Throwable
at com.sun.enterprise.loader.ASURLClassLoader$ProtectedJarFile.close(ASURLClassLoader.java:923)
at org.flywaydb.core.internal.util.scanner.classpath.JarFileClassPathLocationScanner.findResourceNames(JarFileClassPathLocationScanner.java:41)
at org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner.findResourceNames(ClassPathScanner.java:161)
at org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner.scanForResources(ClassPathScanner.java:73)
at org.flywaydb.core.internal.util.scanner.Scanner.scanForResources(Scanner.java:53)
at org.flywaydb.core.internal.callback.SqlScriptFlywayCallback.<init>(SqlScriptFlywayCallback.java:76)
at org.flywaydb.core.Flyway.execute(Flyway.java:1315)
at org.flywaydb.core.Flyway.migrate(Flyway.java:919)
at (...).FlywayMigrator.onStartup(FlywayMigrator.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.ejb.containers.interceptors.BeanCallbackInterceptor.intercept(InterceptorManager.java:1009)
at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:65)
at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:113)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCallback(SystemInterceptorProxy.java:138)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.init(SystemInterceptorProxy.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:964)
at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:65)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:393)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:376)
at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:538)
at com.sun.ejb.containers.AbstractSingletonContainer.access0(AbstractSingletonContainer.java:79)
at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:719)
at com.sun.ejb.containers.AbstractSingletonContainer.instantiateSingletonInstance(AbstractSingletonContainer.java:451)
at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:216)
at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:177)
at org.glassfish.ejb.startup.SingletonLifeCycleManager.doStartup(SingletonLifeCycleManager.java:155)
at org.glassfish.ejb.startup.EjbApplication.start(EjbApplication.java:177)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.execute(CommandRunnerImpl.java:348)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access00(CommandRunnerImpl.java:95)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:745)
|#]
FlywayMigrator 的第 32 行 - 不出所料 - flyway.migrate();
行。
我的问题是:我们怎样才能摆脱那些警告?我找到了 a very similar looking issue which happened on an older version of Glassfish (2.1.1), but no reason or solution is stated there。这不是关键任务,但希望这些警告消失,此外,了解它们的根本原因会非常好。
除了不允许 Flyway 扫描更新脚本之外,您可能无法摆脱讨厌的消息。被调用的代码(由 Flyway)看起来像这样
public void close() {
// nothing
_logger.log(Level.WARNING, "Illegal call to close() detected", new Throwable());
}
如您所见,Flyway 不是这里的罪魁祸首(对此您无能为力)
我们正在 GlassFish (3.1.2.2b5) 上构建 Java EE 6 .ear
应用程序 运行 并使用 Flyway (3.2.1) 来管理我们的数据库架构。这发生在部署 .ear
时 - 网络上有一篇名为 "Easy Database Migrations using Flyway, Java EE 6 and GlassFish" 的文章很好地概述了如何执行此操作。我们最低限度地采用了迁移器代码,本质上只有 changing/removing 一些日志记录:
@Singleton
@Startup
public class FlywayMigrator {
private final static Logger LOG = Logger.getLogger(FlywayMigrator.class.getName());
@Resource(lookup = "jdbc/myDS")
private DataSource dataSource;
@PostConstruct
private void onStartup() {
if (dataSource == null) {
LOG.severe("Cannot migrate, no datasource configured!");
throw new EJBException("Cannot migrate, no datasource configured!");
}
Flyway flyway = new Flyway();
flyway.setBaselineOnMigrate(true);
flyway.setDataSource(dataSource);
flyway.migrate();
}
}
现在的问题是,这在迁移方面非常有效 - 不能说完美。但是,它确实会导致每次在日志中打印三个相同的警告:
[#|2015-06-08T13:40:23.400+0200|WARNING|glassfish3.1.2|javax.enterprise.system.core.classloading.com.sun.enterprise.loader|_ThreadID=42;_ThreadName=Thread-2;|Illegal call to close() detected
java.lang.Throwable
at com.sun.enterprise.loader.ASURLClassLoader$ProtectedJarFile.close(ASURLClassLoader.java:923)
at org.flywaydb.core.internal.util.scanner.classpath.JarFileClassPathLocationScanner.findResourceNames(JarFileClassPathLocationScanner.java:41)
at org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner.findResourceNames(ClassPathScanner.java:161)
at org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner.scanForResources(ClassPathScanner.java:73)
at org.flywaydb.core.internal.util.scanner.Scanner.scanForResources(Scanner.java:53)
at org.flywaydb.core.internal.callback.SqlScriptFlywayCallback.<init>(SqlScriptFlywayCallback.java:76)
at org.flywaydb.core.Flyway.execute(Flyway.java:1315)
at org.flywaydb.core.Flyway.migrate(Flyway.java:919)
at (...).FlywayMigrator.onStartup(FlywayMigrator.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.ejb.containers.interceptors.BeanCallbackInterceptor.intercept(InterceptorManager.java:1009)
at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:65)
at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:113)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCallback(SystemInterceptorProxy.java:138)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.init(SystemInterceptorProxy.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:964)
at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:65)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:393)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:376)
at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:538)
at com.sun.ejb.containers.AbstractSingletonContainer.access0(AbstractSingletonContainer.java:79)
at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:719)
at com.sun.ejb.containers.AbstractSingletonContainer.instantiateSingletonInstance(AbstractSingletonContainer.java:451)
at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:216)
at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:177)
at org.glassfish.ejb.startup.SingletonLifeCycleManager.doStartup(SingletonLifeCycleManager.java:155)
at org.glassfish.ejb.startup.EjbApplication.start(EjbApplication.java:177)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.execute(CommandRunnerImpl.java:348)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access00(CommandRunnerImpl.java:95)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:745)
|#]
FlywayMigrator 的第 32 行 - 不出所料 - flyway.migrate();
行。
我的问题是:我们怎样才能摆脱那些警告?我找到了 a very similar looking issue which happened on an older version of Glassfish (2.1.1), but no reason or solution is stated there。这不是关键任务,但希望这些警告消失,此外,了解它们的根本原因会非常好。
除了不允许 Flyway 扫描更新脚本之外,您可能无法摆脱讨厌的消息。被调用的代码(由 Flyway)看起来像这样
public void close() {
// nothing
_logger.log(Level.WARNING, "Illegal call to close() detected", new Throwable());
}
如您所见,Flyway 不是这里的罪魁祸首(对此您无能为力)