[
https://issues.apache.org/jira/browse/ISIS-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14311605#comment-14311605
]
ASF subversion and git services commented on ISIS-1017:
-------------------------------------------------------
Commit 29e53871f0330ad113c1fef140a1b641773d0cff in isis's branch
refs/heads/master from [~mgrigorov]
[ https://git-wip-us.apache.org/repos/asf?p=isis.git;h=29e5387 ]
ISIS-1017 Check for non-null 'system' before trying to shut it down. It is
'null' if the application initialization has failed earlier.
> @PreDestroy annotated method is not called
> ------------------------------------------
>
> Key: ISIS-1017
> URL: https://issues.apache.org/jira/browse/ISIS-1017
> Project: Isis
> Issue Type: Bug
> Components: Core
> Affects Versions: core-1.7.0
> Environment: Windows 7
> Reporter: Peter Brückler
> Assignee: Dan Haywood
> Priority: Critical
> Fix For: core-1.8.0
>
> Attachments: Tracelog1_only_PostConstruct_called.txt,
> Tracelog2_PostConstruct_and_PreDestroy_called_but_with_IsisWicketApplication_error.txt
>
>
> When annotating the DomainService "SimpleObjects" with
> ...
> @PostConstruct
> @Programmatic
> public void init() {
> System.out.println(">>> @PostConstruct init called <<<");
> }
> @PreDestroy
> @Programmatic
> public void shutdown() {
> System.out.println(">>> @PreDestroy shutdown called <<<");
> }
> ...
> only the @PostConstruct method will be called out of the box.
> Unfortunately, the annotated @PreDestroy method not.
> How to reproduce:
> 1) Checkout, build and check that Simpleapp 1.7.0 or 1.8.0-Snapshot is
> running.
> 2) Introduce the mentioned @PostConstruct and @PreDestroy methods
> an go sure, that a message will be logged when message is called.
> 3) build and deploy simpleapp-webapp.war to Tomcat v7.x or Tomcat v8.x
> 4) See log / use breakpoints to see that @PostConstruct method will be
> successfully called.
> 15:40:18,311 [Schema Thread-2 DEBUG] Schema Transaction
> closing with connection
> "org.datanucleus.store.rdbms.datasource.dbcp.PoolingDataSource$PoolGuardConnectionWrapper@74ce8acd"
> >>> @PostConstruct init called <<<
> 15:40:24,504 [Reflections Thread-2 INFO ] Reflections took 3181
> ms to scan 125 urls, producing 9629 keys and 59986 values
> 5) Stop simpleapp-webapp or redeploy it or even stop tomcat
> 6) See log / breakpoints and realize that no @PreDestroy method was called.
> Negativ side effect is, that every associated connection to JMS / Elastic
> Search, ... in @PostConstruct cannot be disconnected easily and cleanly.
> As a workaround I have tried to activate the section in web.xml:
> <!--
> THE FOLLOWING CONFIGURATION IS NOT REQUIRED IF THE WICKET VIEWER IS IN
> USE.
> IF THE WICKET VIEWER CONFIGURATION IS REMOVED, THEN UNCOMMENT
> -->
> <listener>
>
> <listener-class>org.apache.isis.core.webapp.IsisWebAppBootstrapper</listener-class>
> </listener>
> <context-param>
> <param-name>deploymentType</param-name>
> <param-value>SERVER_EXPLORATION</param-value>
> </context-param>
> <context-param>
> <param-name>isis.viewers</param-name>
> <param-value>restfulobjects</param-value>
> </context-param>
> even this is not my scenario. Doing this the annotated methods gets called,
> but I hit the IsisWicketApplication Error:
> Failed to initialize
> com.google.inject.ProvisionException: Guice provision errors:
> 1) Error in custom provider,
> org.apache.isis.core.commons.exceptions.IsisException: Isis Context already
> set up and cannot be replaced
> at
> org.apache.isis.core.runtime.runner.IsisInjectModule.provideIsisSystem(IsisInjectModule.java:132)
> at
> org.apache.isis.core.runtime.runner.IsisInjectModule.provideIsisSystem(IsisInjectModule.java:132)
> while locating org.apache.isis.core.runtime.system.IsisSystem
> for field at
> org.apache.isis.viewer.wicket.viewer.IsisWicketApplication.system(IsisWicketApplication.java:140)
> while locating webapp.SimpleApplication
> The cool thing is, that this time both annotated method are called:
> 16:16:37,713 [Schema Thread-2 DEBUG] Schema Transaction
> closing with connection
> "org.datanucleus.store.rdbms.datasource.dbcp.PoolingDataSource$PoolGuardConnectionWrapper@2339e31f"
> >>> @PostConstruct init called <<<
> 16:16:45,196 [Reflections Thread-2 INFO ] Reflections took 3259
> ms to scan 125 urls, producing 9629 keys and 59986 values
> ...
> INFORMATION: Cleaning up Shiro Environment
> >>> @PreDestroy shutdown called <<<
> 16:16:53,198 [IsisContext main INFO ] closing all instances
> 16:16:53,198 [IsisWebAppBootstrapper main INFO ] server shut down
> Please fix that issue or assist me in creating a workaround.
> Thanks,
> Peter
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)