Return-Path: X-Original-To: apmail-deltaspike-users-archive@www.apache.org Delivered-To: apmail-deltaspike-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1D8CC174F3 for ; Fri, 26 Sep 2014 19:51:15 +0000 (UTC) Received: (qmail 19856 invoked by uid 500); 26 Sep 2014 19:51:15 -0000 Delivered-To: apmail-deltaspike-users-archive@deltaspike.apache.org Received: (qmail 19824 invoked by uid 500); 26 Sep 2014 19:51:15 -0000 Mailing-List: contact users-help@deltaspike.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@deltaspike.apache.org Delivered-To: mailing list users@deltaspike.apache.org Received: (qmail 19812 invoked by uid 99); 26 Sep 2014 19:51:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Sep 2014 19:51:14 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,LOTS_OF_MONEY,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lightguard.jp@gmail.com designates 209.85.220.182 as permitted sender) Received: from [209.85.220.182] (HELO mail-vc0-f182.google.com) (209.85.220.182) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Sep 2014 19:51:10 +0000 Received: by mail-vc0-f182.google.com with SMTP id le20so10026826vcb.27 for ; Fri, 26 Sep 2014 12:50:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=NdWfcquPpPFkMQNt/KXeOJeJLfaA80JGn/MZI06Zbgs=; b=oYjqqZEJBlVKudukw7jHqB+SZTnqeoNrwjreOKrzqd5TH6yUlgg4BCEKtElZWEg65D QKYLXrbF4WNgqo5lY7RijQ7JgR+gm7aSBW55mSRhercT3BCrhvr4h8/oR0ymgmW61pNh trRurN1ehGQ9eW7kF3fwEdzPGy5RO1oRpl4GDrAUKUjq1N1V70H3QjMVBqkdH9dsMTQX WANM04JU2M6GBPhA1k0ZhG+boaBS+Vky9n5s5p7v7R+MZBCrybezVRlzrrGq6We3bDrt Fqm2hed4joJTXOAAS6MBCLFO/hXvL90UBk8bG9a97n/gbu+Z+zLra9O5G+f6gVPj59+I VAUw== X-Received: by 10.220.79.132 with SMTP id p4mr1823436vck.36.1411761048986; Fri, 26 Sep 2014 12:50:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.21.19 with HTTP; Fri, 26 Sep 2014 12:50:28 -0700 (PDT) In-Reply-To: References: From: Jason Porter Date: Fri, 26 Sep 2014 13:50:28 -0600 Message-ID: Subject: Re: problem trying to use DeltaSpike JMX annotations in a standalone main application To: "users@deltaspike.apache.org" Content-Type: multipart/alternative; boundary=047d7b3a9264d541260503fd3b50 X-Virus-Checked: Checked by ClamAV on apache.org --047d7b3a9264d541260503fd3b50 Content-Type: text/plain; charset=UTF-8 Please make sure that ds-test-control is not on the classpath of the main app. On Fri, Sep 26, 2014 at 1:33 PM, Pablo Pita wrote: > The JMX beans are @ApplicationScoped. > > In the main method, I placed the statement to start of the @RequestScope > context because the exception I got was referring to the @RequestScope. > Just in case it would have fix something (it did not). > > So, the question is if with a CDI container SE edition + DeltaSpike, is it > easy to have the JMX Beans registered? Any example? I might have wrong the > dependencies in Eclipse, and I was trying to run the main method by using > the menu option Run as Java Application within eclipse. > > Pablo > > On Fri, Sep 26, 2014 at 7:20 PM, Gerhard Petracek < > gerhard.petracek@gmail.com> wrote: > > > the test-control module should be only on the classpath once you run > tests > > and not in production mode (see e.g. [1]). > > > > regards, > > gerhard > > > > [1] https://github.com/os890/javase-cdi-ds-project-template > > > > http://www.irian.at > > > > Your JSF/JavaEE powerhouse - > > JavaEE Consulting, Development and > > Courses in English and German > > > > Professional Support for Apache MyFaces > > > > 2014-09-26 19:10 GMT+02:00 Pablo Pita : > > > > > My original idea was to emulate a normal Java application with a main > > > method using Weld version for Java SE as CDI container. There, I would > > > bootstrap the CDI container, and voila, the CDI JMX beans should be > > > registered by DeltaSpike infrastructure. > > > > > > Running unit tests with the @RunWith(CdiTestRunner.class) works (no > > > deployment to JBoss, or Arquillian, just Weld SE in the test class > path). > > > As well, the JMX registration works OK when deploying the application > to > > > JBoss. I can work with the JMX Console with the JMX beans. > > > > > > So the code for a normal main method bootstraping the CDI Container is > > not > > > that simple, is it? > > > > > > Pablo > > > > > > > > > > > > On Fri, Sep 26, 2014 at 6:43 PM, Jason Porter > > > > wrote: > > > > > > > Pablo, > > > > > > > > Does your code, looks like it's a test, start and register the MBean? > > Are > > > > you accessing the MBeam from a running JBoss AS7 instance or > > something? I > > > > feel like I'm missing some information. > > > > > > > > The cause is that the Request scope isn't active when you're > accessing > > > the > > > > MBean. > > > > > > > > On Fri, Sep 26, 2014 at 3:46 AM, Pablo Pita > > > wrote: > > > > > > > > > Hello all, > > > > > > > > > > I am having a problem trying to use DeltaSpike JMX annotations in a > > > > > standalone main application. > > > > > > > > > > For my tests, I have taken MyMBean from DS sources. When looking > into > > > the > > > > > JMX console JConsole, I see that MyMBean is registered but when > > trying > > > to > > > > > access the counter attribute, this exception comes: > > > > > > > > > > 26.09.2014 11:18:20 > > > > > org.apache.deltaspike.core.impl.jmx.DynamicMBeanWrapper > > > > > getAttribute > > > > > SCHWERWIEGEND: can't get counter value > > > > > java.lang.reflect.InvocationTargetException > > > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > > > > at > > > > > > > > > > > > > > > > > > > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > > > > > at > > > > > > > > > > > > > > > > > > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > > > > > at java.lang.reflect.Method.invoke(Method.java:597) > > > > > at > > > > > > > > > > > > > > > > > > > > org.apache.deltaspike.core.impl.jmx.AttributeAccessor.get(AttributeAccessor.java:46) > > > > > at > > > > > > > > > > > > > > > > > > > > org.apache.deltaspike.core.impl.jmx.DynamicMBeanWrapper.getAttribute(DynamicMBeanWrapper.java:249) > > > > > at > > > > > > > > > > > > > > > > > > > > com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:666) > > > > > at > > > > > > > > > > > > > > > > > > > > com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:638) > > > > > at > > > > > > > > > > > > > > > > > > > > javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1431) > > > > > at > > > > > > > > > > > > > > > > > > > > javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:74) > > > > > at > > > > > > > > > > > > > > > > > > > > javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1295) > > > > > at > > > > > > > > > > > > > > > > > > > > javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1387) > > > > > at > > > > > > > > > > > > > > > > > > > > javax.management.remote.rmi.RMIConnectionImpl.getAttribute(RMIConnectionImpl.java:630) > > > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > > > > at > > > > > > > > > > > > > > > > > > > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > > > > > at > > > > > > > > > > > > > > > > > > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > > > > > at java.lang.reflect.Method.invoke(Method.java:597) > > > > > at > > > > sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:303) > > > > > at sun.rmi.transport.Transport$1.run(Transport.java:159) > > > > > at java.security.AccessController.doPrivileged(Native Method) > > > > > at sun.rmi.transport.Transport.serviceCall(Transport.java:155) > > > > > at > > > > > > > > > sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535) > > > > > at > > > > > > > > > > > > > > > > > > > > sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790) > > > > > at > > > > > > > > > > > > > > > > > > > > sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649) > > > > > at > > > > > > > > > > > > > > > > > > > > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) > > > > > at > > > > > > > > > > > > > > > > > > > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) > > > > > at java.lang.Thread.run(Thread.java:662) > > > > > Caused by: org.jboss.weld.context.ContextNotActiveException: > > > WELD-001303 > > > > No > > > > > active contexts for scope type > javax.enterprise.context.RequestScoped > > > > > at > > > > > > > > > > > > > > > org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:608) > > > > > at > > > > > > > > > > > > > > > > > > > > org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:71) > > > > > at > > > > > > > > > > > > > > > > > > > > org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:104) > > > > > at > > > > > > > > > > > > > > > > > > > > org.jboss.weld.proxies.DynamicMockManager$-427240798$Proxy$_$$_WeldClientProxy.getMock(DynamicMockManager$-427240798$Proxy$_$$_WeldClientProxy.java) > > > > > at > > > > > > > > > > > > > > > > > > > > org.apache.deltaspike.testcontrol.impl.mock.MockAwareInjectionTargetWrapper.produce(MockAwareInjectionTargetWrapper.java:59) > > > > > at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:296) > > > > > at > > > > org.jboss.weld.context.AbstractContext.get(AbstractContext.java:103) > > > > > at > > > > > > > > > > > > > > > > > > > > org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:90) > > > > > at > > > > > > > > > > > > > > > > > > > > org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79) > > > > > at > > > > > > > > > > > > > > > > > > > > com.jmx.ds.MyMBean$Proxy$_$$_WeldClientProxy.getCounter(MyMBean$Proxy$_$$_WeldClientProxy.java) > > > > > ... 27 more > > > > > > > > > > I wonder if there is something I am missing to properly setup this > > > case. > > > > I > > > > > am on Windows running JDK 6 and Weld 1.1.18. > > > > > > > > > > > > > > > The main program I am using is as follows: > > > > > > > > > > public static void main(String[] args) throws Exception { > > > > > > > > > > CdiContainer cdiContainer = > > > CdiContainerLoader.getCdiContainer(); > > > > > cdiContainer.boot(); > > > > > > > > > > // Starting the application-context and request-context > > allows > > > to > > > > > use > > > > > // @ApplicationScoped and @RequestScoped beans > > > > > ContextControl contextControl = > > > cdiContainer.getContextControl(); > > > > > contextControl.startContext(ApplicationScoped.class); > > > > > contextControl.startContext(RequestScoped.class); > > > > > > > > > > // we can use CDI here > > > > > while (running) { > > > > > int i = 0; > > > > > i = i + 1; > > > > > Thread.sleep(50); > > > > > } > > > > > cdiContainer.shutdown(); > > > > > } > > > > > > > > > > Thanks for any feedback, > > > > > -- > > > > > Pablo Pita Leira > > > > > > > > > > > > > > > > > > > > > -- > > > > Jason Porter > > > > http://en.gravatar.com/lightguardjp > > > > > > > > > > > > > > > > -- > > > Pablo Pita Leira > > > > > > > > > -- > Pablo Pita Leira > -- Jason Porter http://en.gravatar.com/lightguardjp --047d7b3a9264d541260503fd3b50--