Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MBean for read cache cannot be registered / unregistered #4967

Closed
urugator opened this issue Sep 15, 2015 · 13 comments
Closed

MBean for read cache cannot be registered / unregistered #4967

urugator opened this issue Sep 15, 2015 · 13 comments
Assignees
Labels
Milestone

Comments

@urugator
Copy link

OrientDB 2.1.1

When I redeploy an aplication on WildFly 8.2.0 (standalone full profile) I get an exception:

MBean for read cache cannot be registered: com.orientechnologies.orient.core.exception.OStorageException: Error during registration of read cache MBean

It happens only on the first creation of (remote) graph instance after redeploy, additional requests (I am using OrientGraphFactory) for graph instance don't produce the exception.
I also haven't noticed any consequences so far.
Maybe the MBean cache is not properly unregistered before redeploy (because MBean server is still running), so it can't be registered again after the deployment, but I don't understand these things so I am just speculating.
Even if the exception might not be serious, I would like to get rid of it.
Maybe I could unregister the MBean from MBeanServer manually, during app shutdown, but I am afraid of possible unreleased resources used by MBean cache?
Or maybe OrientDB should check if the MBean cache is not already registered before an attempt to register?

I also get an exception when WildFly is shutting down:

MBean for read cache cannot be unregistered: com.orientechnologies.orient.core.exception.OStorageException: Error during unregistration of read cache MBean.

Fullstacks:

17:24:39,622 SEVERE [com.orientechnologies.orient.core.engine.local.OEngineLocalPaginated] (default task-45) MBean for read cache cannot be registered: com.orientechnologies.orient.core.exception.OStorageException: Error during registration of read cache MBean.
    at com.orientechnologies.orient.core.storage.cache.local.O2QCache.registerMBean(O2QCache.java:530) [orientdb-core-2.1.1.jar:2.1.1]
    at com.orientechnologies.orient.core.engine.local.OEngineLocalPaginated.<init>(OEngineLocalPaginated.java:47) [orientdb-core-2.1.1.jar:2.1.1]
    at com.orientechnologies.orient.core.Orient.startup(Orient.java:224) [orientdb-core-2.1.1.jar:2.1.1]
    at com.orientechnologies.orient.core.Orient.<clinit>(Orient.java:87) [orientdb-core-2.1.1.jar:2.1.1]
    at com.orientechnologies.orient.core.storage.OStorageAbstract.<clinit>(OStorageAbstract.java:54) [orientdb-core-2.1.1.jar:2.1.1]
    at com.orientechnologies.orient.client.remote.OServerAdmin.<init>(OServerAdmin.java:62) [orientdb-client-2.1.1.jar:2.1.1]
    at jplacek.mysite.graphdb.GraphProducer.init(GraphProducer.java:40) [classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_45]
    at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_45]
    at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.invokeMethods(DefaultLifecycleCallbackInvoker.java:98) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.postConstruct(DefaultLifecycleCallbackInvoker.java:81) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.injection.producer.BasicInjectionTarget.postConstruct(BasicInjectionTarget.java:126) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.injection.producer.BeanInjectionTarget.postConstruct(BeanInjectionTarget.java:70) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:153) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:742) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.injection.producer.AbstractMemberProducer.getReceiver(AbstractMemberProducer.java:128) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.injection.producer.AbstractMemberProducer.produce(AbstractMemberProducer.java:148) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:183) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:69) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:742) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.manager.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:840) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:92) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:370) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:381) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.injection.producer.ResourceInjector$1.proceed(ResourceInjector.java:70) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:72) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:121) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:150) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:742) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:107) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:90) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.as.jsf.injection.weld.ForwardingELResolver.getValue(ForwardingELResolver.java:46) [wildfly-jsf-injection-8.2.0.Final.jar:8.2.0.Final]
    at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:188) [jboss-el-api_3.0_spec-1.0.3.Final.jar:1.0.3.Final]
    at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:116) [javax.el-3.0.1-b05.jar:]
    at com.sun.el.parser.AstValue.getBase(AstValue.java:151) [javax.el-3.0.1-b05.jar:]
    at com.sun.el.parser.AstValue.getValue(AstValue.java:200) [javax.el-3.0.1-b05.jar:]
    at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226) [javax.el-3.0.1-b05.jar:]
    at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]
    at com.sun.faces.facelets.el.ELText$ELTextVariable.writeText(ELText.java:238) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.el.ELText$ELTextComposite.writeText(ELText.java:154) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:85) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at org.ocpsoft.rewrite.faces.RewriteViewHandler.renderView(RewriteViewHandler.java:186) [rewrite-integration-faces-2.0.12.Final.jar:2.0.12.Final]
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:205) [rewrite-servlet-2.0.12.Final.jar:2.0.12.Final]
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:197) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:759) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_45]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_45]
Caused by: javax.management.InstanceAlreadyExistsException: com.orientechnologies.orient.core.storage.cache.local:type=O2QCacheMXBean
    at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437) [rt.jar:1.8.0_45]
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898) [rt.jar:1.8.0_45]
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966) [rt.jar:1.8.0_45]
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900) [rt.jar:1.8.0_45]
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324) [rt.jar:1.8.0_45]
    at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522) [rt.jar:1.8.0_45]
    at org.jboss.as.jmx.PluggableMBeanServerImpl$TcclMBeanServer.registerMBean(PluggableMBeanServerImpl.java:1493)
    at org.jboss.as.jmx.PluggableMBeanServerImpl.registerMBean(PluggableMBeanServerImpl.java:896)
    at com.orientechnologies.orient.core.storage.cache.local.O2QCache.registerMBean(O2QCache.java:526) [orientdb-core-2.1.1.jar:2.1.1]
    ... 93 more
02:09:25,998 INFO  [com.orientechnologies.orient.core.Orient] (Thread-1311) - closing storage: test...
02:09:26,001 SEVERE [com.orientechnologies.orient.client.remote.OStorageRemote] (Thread-1311) Removing disconnected network channel '127.0.0.1:2424/test'...
02:09:26,004 SEVERE [com.orientechnologies.orient.core.engine.local.OEngineLocalPaginated] (Thread-314) MBean for read cache cannot be unregistered: com.orientechnologies.orient.core.exception.OStorageException: Error during unregistration of read cache MBean.
    at com.orientechnologies.orient.core.storage.cache.local.O2QCache.unregisterMBean(O2QCache.java:548) [orientdb-core-2.1.1.jar:2.1.1]
    at com.orientechnologies.orient.core.engine.local.OEngineLocalPaginated.shutdown(OEngineLocalPaginated.java:81) [orientdb-core-2.1.1.jar:2.1.1]
    at com.orientechnologies.orient.core.Orient.shutdown(Orient.java:284) [orientdb-core-2.1.1.jar:2.1.1]
    at com.orientechnologies.orient.core.OrientShutdownHook.run(OrientShutdownHook.java:32) [orientdb-core-2.1.1.jar:2.1.1]
Caused by: javax.management.InstanceNotFoundException: com.orientechnologies.orient.core.storage.cache.local:type=O2QCacheMXBean
    at org.jboss.as.jmx.PluggableMBeanServerImpl.findDelegate(PluggableMBeanServerImpl.java:1094)
    at org.jboss.as.jmx.PluggableMBeanServerImpl.unregisterMBean(PluggableMBeanServerImpl.java:1063)
    at com.orientechnologies.orient.core.storage.cache.local.O2QCache.unregisterMBean(O2QCache.java:544) [orientdb-core-2.1.1.jar:2.1.1]
    ... 3 more
@gandesc
Copy link

gandesc commented Sep 18, 2015

same issue for me with wildfly 9.0.1

@lvca
Copy link
Member

lvca commented Sep 18, 2015

@laa could we check if the bean is already registered and remove the previous one? Or is this the case of multiple Orient instances on the same JVM?

@lvca lvca assigned laa Sep 18, 2015
@lvca lvca added the bug label Sep 18, 2015
@lvca lvca added this to the 2.1.x (next hotfix) milestone Sep 18, 2015
@urugator
Copy link
Author

urugator commented Oct 6, 2015

As a workaround I am removing shutdown hook at app startup and shutting down Orient manually at app shutdown. However I haven't tested it enought to claim that there won't be any issues.

Example

@ApplicationScoped
public class AppInit {

  @PostConstruct
  public void init() {
     Orient.instance().removeShutdownHook();
  }

  @PreDestroy
  public void shutdown() {
     Orient.instance().shutdown();
  }
}

@laa
Copy link
Member

laa commented Oct 19, 2015

Hi,
Is it correct that you may reproduce this issue without problems on your side ?
If so may be you will send me a war file so I will reproduce issue ?
Do you use JBoss as a server ?
Could you provide me version and steps to deploy war ?

@urugator
Copy link
Author

Yes, problem occures consistently.

As I stated I use standalone WildFly 8.2.0 Final server (using standalone-full.xml configuration without any modifications).

About the steps, thats a little bit tricky - I use NetBeans 8.0.2 to handle deploy/redeploy/undeploy, but I quess NetBeans simply calls jboss-cli commands.
I will try to reproduce the issue isolated from NetBeans environment (using jboss-cli and deployment scanner) as soon as possible, however I am quite busy currently, so it might take some time.

Nevertheless, I think the issue might be related with a problem described in sources of JCA Plugin from OPS4J:

@Override
public void start(BootstrapContext ctx) throws ResourceAdapterInternalException {
  log.debug("starting OrientResourceAdapter");

  // The VM running the app server may live longer than this adapter,
  // so we cannot use the default shutdown hook.
  // shutdown() is called directly in stop().

  Orient.instance().removeShutdownHook();
}

https://github.com/ops4j/org.ops4j.orient/blob/master/orient-ra/src/main/java/org/ops4j/orient/adapter/impl/OrientResourceAdapter.java

I don't use that plugin, I was just interested about the implementation and this is where I got and inspiration for my workaround.

Btw, official JTA support from Orient would be very much appreciated.

@urugator
Copy link
Author

I quess the whole problem is that OrientDB is not shutted down properly between deploys, because default shutdown hook is "hooked" on JVM shutdown, but it needs to be "hooked" on App shutdown.

@laa
Copy link
Member

laa commented Oct 19, 2015

Yes , do you run shutdown on servlet context listener onShutdown and start
on onStartup or something ?

On Mon, Oct 19, 2015, 18:17 urugator notifications@github.com wrote:

I quess the whole problem is that OrientDB is not shutted don't properly
between deploys, because default shutdown hook is "hooked" on JVM shutdown,
but it needs to be "hooked" on App shutdown.


Reply to this email directly or view it on GitHub
#4967 (comment)
.

@urugator
Copy link
Author

I use CDI container to handle my app lifecycle.
The workaround example I posted is basically what I am currently doing in my application.

https://docs.oracle.com/javaee/7/api/javax/enterprise/context/ApplicationScoped.html
https://docs.oracle.com/javaee/7/api/javax/annotation/PostConstruct.html
http://docs.oracle.com/javaee/7/api/javax/annotation/PreDestroy.html

@urugator
Copy link
Author

As I think about it, you should require the user to call shutdown (possibly even start) manually in any environment and keep JVM shutdown hook only as non standard, last resort way of releasing resources.
You won't be able to provide means for managing Orient instance lifecycle in every possible environment for two reasons:

  1. There is a lot of them (Servlet container, Java EE CDI container, Spring container, ...)
  2. It might be impossible, because of the environment limitations.
    For example how to ensure that that your Orient shutdown ServletContextListener will be called after all operations requiring DB are done - the order of ServletContextListeners invocations must be defined by user. So even though you can provide such listener, you have to force the user to register it.
    Or in CDI environment, you would have to force the user to obtain some orient instance as a dependency, so that it's destroyed (shutted down), only after all dependent classes are destroyed. (You could also probably use some CDI lifecycle listener, but there would be the same problems as with ServletContextListener)

So I really believe that managing Orient instance lifecycle is a user responsibility and in that case, it needs to be well documented somewhere.

However there is a question which needs to be answered: Should I be able to call start and shutdown multiple times on a single JVM instance?

@gandesc
Copy link

gandesc commented Oct 20, 2015

Hey,

I'm uploading a basic Eclipse importable project, as well as the built, deployable war.
The project is a Jersey test.

To see the error, visit: http://localhost:8080/rest/myapp/MyResource then check the log of the server.

I'm using Wildfly 9.0.1.
WAR
Project

@aheintz
Copy link

aheintz commented Dec 21, 2015

I'm experiencing the same exception being thrown/logged. But my scenario is that it is thrown/logged when deploying multiple applications in the same tomcat each instantiating a OPartitionedDatabasePoolFactory. I'm saying logged, because the applications works fine anyway. But I haven't dug into it deeper into it since it still works and cleaning the log haven't been top priority.

@manmohanp
Copy link

I too see same issue, especially when multiple apps deployed on same app server (e.g. tomcat). And like others said, apps seems to be working though not sure any further issue.

Jan 04, 2016 10:59:27 PM com.orientechnologies.common.log.OLogManager log
INFO: OrientDB auto-config DISKCACHE=10,695MB (heap=3,641MB os=16,384MB disk=435,737MB)
Jan 04, 2016 10:59:27 PM com.orientechnologies.common.log.OLogManager log
SEVERE: MBean for read cache cannot be registered
com.orientechnologies.orient.core.exception.OStorageException: Error during registration of read cache MBean.
at com.orientechnologies.orient.core.storage.cache.local.O2QCache.registerMBean(O2QCache.java:530)
at com.orientechnologies.orient.core.engine.local.OEngineLocalPaginated.(OEngineLocalPaginated.java:47)
at com.orientechnologies.orient.core.Orient.startup(Orient.java:224)
at com.orientechnologies.orient.core.Orient.(Orient.java:87)
at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerStringAbstract.(ORecordSerializerStringAbstract.java:52)
at com.orientechnologies.orient.core.serialization.serializer.record.ORecordSerializerFactory.(ORecordSerializerFactory.java:47)
at com.orientechnologies.orient.core.serialization.serializer.record.ORecordSerializerFactory.(ORecordSerializerFactory.java:37)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.(ODatabaseDocumentTx.java:129)
at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.initQueue(OPartitionedDatabasePool.java:386)
at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.(OPartitionedDatabasePool.java:186)
at com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.setupPool(OrientGraphFactory.java:161)
at com.blu.orientdb.OrientGraphClientImpl.(OrientGraphClientImpl.java:40)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:267)

at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

Caused by: javax.management.InstanceAlreadyExistsException: com.orientechnologies.orient.core.storage.cache.local:type=O2QCacheMXBean
at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
at com.orientechnologies.orient.core.storage.cache.local.O2QCache.registerMBean(O2QCache.java:526)
... 84 more

@laa
Copy link
Member

laa commented Feb 16, 2016

@urugator

However there is a question which needs to be answered: Should I be able to call start and shutdown multiple times on a single JVM instance?

Yes , you may do it several times . We do this in our tests without problems.

So I really believe that managing Orient instance lifecycle is a user responsibility and in that case, it needs to be well documented somewhere.

Yes, sorry but that is answer on issue, we can not manage every lifecycle of every container so users should do this manually.

Also I have added warning that system probably was not shutdown correctly if MBean is already registered inside of JVM

laa added a commit that referenced this issue Feb 16, 2016
@laa laa closed this as completed Feb 16, 2016
@laa laa removed the in progress label Feb 16, 2016
laa added a commit that referenced this issue Feb 16, 2016
@robfrank robfrank modified the milestones: 2.1.x (next hotfix), 2.1.12 Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

8 participants