geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ajay Panagariya" <apana...@gmail.com>
Subject Question about getting two GBeans to talk with each other
Date Mon, 25 Jun 2007 02:05:01 GMT
Hi,

I'm trying to get two GBeans to talk with eachother. This is the place I got
most of my information from...:
http://cwiki.apache.org/GMOxDEV/gbeansarticle1.html
Some of my code below draws on examples provided in a sample zip file
available on the site, which I was unable to compile.


As I understand it, two GBeans can be made to talk to eachother through an
interface.

So, in my code....
GBeantwo implements an interface(called MyInterface.java) with a single
method called 'doit()'

I would like GBeanone to be able to call doit(). In the toy example I'm
trying to construct for myself, I deploy GBeantwo first (because Gbeanone
has dependency on GBeantwo).


Here is the code for GBeantwo:


public class GBeantwo implements MyInterface {

    public static final GBeanInfo GBEAN_INFO;
    private final ObjectName objectName;


    static {
        GBeanInfoBuilder infoBuilder = new GBeanInfoBuilder("GBeantwo",
GBeantwo.class);

        // attributes
        infoBuilder.addAttribute("objectName", String.class, false);
        //interfaces
        infoBuilder.addInterface(MyInterface.class);
        // constructor
        infoBuilder.setConstructor(new String[]{"objectName"});

        GBEAN_INFO = infoBuilder.getBeanInfo();
    }

    public GBeantwo(String objectName){
        this.objectName = ObjectNameUtil.getObjectName(objectName);
    }


    public static GBeanInfo getGBeanInfo() {
        return GBEAN_INFO;
    }


    public void doit(){
        System.out.println("[GBean2] inside doit()");
        //        Calc.add(2,3);
    }

}




Here is the code for GBeanone:

public class GBeanone{

    public static final GBeanInfo GBEAN_INFO;
    private final ObjectName objectName;
    private final MyInterface myInterface;


    static {
        GBeanInfoBuilder infoBuilder = new GBeanInfoBuilder("GBeanone",
GBeanone.class);

        // attributes
        infoBuilder.addAttribute("objectName", String.class, false);
        //interfaces
        infoBuilder.addReference("MyInterface",MyInterface.class);
        // constructor
        infoBuilder.setConstructor(new
String[]{"objectName","MyInterface"});

        GBEAN_INFO = infoBuilder.getBeanInfo();
    }

    public GBeanone(String objectName,MyInterface myInterface) {

        this.objectName = ObjectNameUtil.getObjectName(objectName);
        this.myInterface = myInterface;
        myInterface.doit();
    }


    public static GBeanInfo getGBeanInfo() {
        return GBEAN_INFO;
    }

}



Here is the code for MyInterface interface:

public interface MyInterface {
    public void doit();
}



And these are the individual deployment plans:

For GBeanone:

<module xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">
  <!--The SharedLib Service-->
  <environment>
    <moduleId>
      <groupId>example1.talking</groupId>
      <artifactId>gbeanone</artifactId>
      <version>2.0-SNAPSHOT</version>
      <type>car</type>
    </moduleId>
    <dependencies>

    </dependencies>
    <hidden-classes/>
    <non-overridable-classes/>
  </environment>
  <gbean name="GBeanOne" class="example1.talking.GBeanone">
  </gbean>
</module>


For GBeantwo:

<module xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">
  <!--The SharedLib Service-->
  <environment>
    <moduleId>
      <groupId>example1.talking</groupId>
      <artifactId>gbeantwo</artifactId>
      <version>2.0-SNAPSHOT</version>
      <type>car</type>
    </moduleId>
    <dependencies>

    </dependencies>
    <hidden-classes/>
    <non-overridable-classes/>
  </environment>
  <gbean name="GBeanTwo" class="example1.talking.GBeantwo">
  </gbean>
</module>





GBeantwo deploys with no problem. But when I deploy GBeanone, the
MyInterface.doit() call causes the following to show up on the console:


$ target/geronimo-tomcat6-jee5-2.0-SNAPSHOT/bin/deploy.bat deploy
gbean1.jarexample1/talking/gbeanone-
plan.xml
Using GERONIMO_BASE:   C:\g\target\geronimo-tomcat6-jee5-2.0-SNAPSHOT
Using GERONIMO_HOME:   C:\g\target\geronimo-tomcat6-jee5-2.0-SNAPSHOT
Using GERONIMO_TMPDIR: var\temp
Using JRE_HOME:        C:\Program Files\Java\jdk1.5.0_12\jre
org.apache.geronimo.kernel.config.LifecycleException: start of
example1.talking/gbeanone/2.0-SNAPSHOT/car failed
        at
org.apache.geronimo.kernel.config.SimpleConfigurationManager.startConfiguration
(SimpleConfigurationManager.java:547)
        at
org.apache.geronimo.kernel.config.SimpleConfigurationManager.startConfiguration
(SimpleConfigurationManager.java:511)
        at
org.apache.geronimo.kernel.config.SimpleConfigurationManager$$FastClassByCGLIB$$ce77a924.invoke
(<generated>)
        at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
        at org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(
FastMethodInvoker.java:38)
        at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(
GBeanOperation.java:127)
        at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(
GBeanInstance.java:863)
        at org.apache.geronimo.kernel.basic.BasicKernel.invoke(
BasicKernel.java:239)
        at org.apache.geronimo.kernel.KernelGBean.invoke(KernelGBean.java
:342)
        at
org.apache.geronimo.kernel.KernelGBean$$FastClassByCGLIB$$1cccefc9.invoke
(<generated>)
        at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
        at org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(
FastMethodInvoker.java:38)
        at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(
GBeanOperation.java:127)
        at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(
GBeanInstance.java:863)
        at org.apache.geronimo.kernel.basic.BasicKernel.invoke(
BasicKernel.java:239)
        at org.apache.geronimo.system.jmx.MBeanGBeanBridge.invoke(
MBeanGBeanBridge.java:168)
        at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(
DynamicMetaDataImpl.java:213)
        at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java
:220)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(
DefaultMBeanServerInterceptor.java:815)
        at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java
:784)
        at javax.management.remote.rmi.RMIConnectionImpl.doOperation(
RMIConnectionImpl.java:1410)
        at javax.management.remote.rmi.RMIConnectionImpl.access$100(
RMIConnectionImpl.java:81)
        at
javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(
RMIConnectionImpl.java:1247)
        at java.security.AccessController.doPrivileged(Native Method)
        at
javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(
RMIConnectionImpl.java:1350)
        at javax.management.remote.rmi.RMIConnectionImpl.invoke(
RMIConnectionImpl.java:784)
        at sun.reflect.GeneratedMethodAccessor115.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java
:294)
        at sun.rmi.transport.Transport$1.run(Transport.java:153)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(
TCPTransport.java:466)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(
TCPTransport.java:707)
        at java.lang.Thread.run(Thread.java:595)
Caused by: org.apache.geronimo.kernel.config.InvalidConfigException: Unknown
start exception
        at
org.apache.geronimo.kernel.config.ConfigurationUtil.startConfigurationGBeans
(ConfigurationUtil.java:508)
        at
org.apache.geronimo.kernel.config.KernelConfigurationManager.start(
KernelConfigurationManager.java:187)
        at
org.apache.geronimo.kernel.config.SimpleConfigurationManager.startConfiguration
(SimpleConfigurationManager.java:530)
        ... 35 more
Caused by: org.apache.geronimo.gbean.InvalidConfigurationException:
Configuration example1.talking/gbeanone/2.0-SNAPSHOT/car failed to
start due to the following reasons:
  The service ServiceModule=example1.talking/gbeanone/2.0-SNAPSHOT/car,j2eeType=GBean,name=GBeanOne
did not start for an unknown reason


        at
org.apache.geronimo.kernel.config.ConfigurationUtil.startConfigurationGBeans
(ConfigurationUtil.java:471)
        ... 37 more
    Error: Operation failed: start of
    example1.talking/gbeanone/2.0-SNAPSHOT/car failed

        Unknown start exception

        Configuration example1.talking/gbeanone/2.0-SNAPSHOT/car failed to
    start due to the following reasons:

      The service
    ServiceModule=example1.talking
/gbeanone/2.0-SNAPSHOT/car,j2eeType=GBean,name=GBeanOne
    did not start for an unknown reason




And the following shows up in the geronimo logfile:

21:24:45,718 INFO  [DirectoryMonitor] Hot deployer notified that an artifact
was removed: example1.talking/gbeanone/2.0-SNAPSHOT/car
21:25:42,062 ERROR [GBeanInstanceState] Error while starting; GBean is now
in the FAILED state: abstractName="example1.talking
/gbeanone/2.0-SNAPSHOT/car?ServiceModule=example1.talking
/gbeanone/2.0-SNAPSHOT/car,j2eeType=GBean,name=GBeanOne"
java.lang.NullPointerException
    at example1.talking.GBeanone.<init>(GBeanone.java:43)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(
NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
    at org.apache.geronimo.gbean.runtime.GBeanInstance.createInstance(
GBeanInstance.java:944)
    at org.apache.geronimo.gbean.runtime.GBeanInstanceState.attemptFullStart
(GBeanInstanceState.java:268)
    at org.apache.geronimo.gbean.runtime.GBeanInstanceState.start(
GBeanInstanceState.java:102)
    at org.apache.geronimo.gbean.runtime.GBeanInstanceState.startRecursive(
GBeanInstanceState.java:124)
    at org.apache.geronimo.gbean.runtime.GBeanInstance.startRecursive(
GBeanInstance.java:551)
    at org.apache.geronimo.kernel.basic.BasicKernel.startRecursiveGBean(
BasicKernel.java:379)
    at
org.apache.geronimo.kernel.config.ConfigurationUtil.startConfigurationGBeans
(ConfigurationUtil.java:442)
    at org.apache.geronimo.kernel.config.KernelConfigurationManager.start(
KernelConfigurationManager.java:187)
    at
org.apache.geronimo.kernel.config.SimpleConfigurationManager.startConfiguration
(SimpleConfigurationManager.java:530)
    at
org.apache.geronimo.kernel.config.SimpleConfigurationManager.startConfiguration
(SimpleConfigurationManager.java:511)
    at
org.apache.geronimo.kernel.config.SimpleConfigurationManager$$FastClassByCGLIB$$ce77a924.invoke
(<generated>)
    at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
    at org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(
FastMethodInvoker.java:38)
    at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(
GBeanOperation.java:127)
    at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(
GBeanInstance.java:863)
    at org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java
:239)
    at org.apache.geronimo.kernel.KernelGBean.invoke(KernelGBean.java:342)
    at
org.apache.geronimo.kernel.KernelGBean$$FastClassByCGLIB$$1cccefc9.invoke
(<generated>)
    at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
    at org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(
FastMethodInvoker.java:38)
    at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(
GBeanOperation.java:127)
    at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(
GBeanInstance.java:863)
    at org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java
:239)
    at org.apache.geronimo.system.jmx.MBeanGBeanBridge.invoke(
MBeanGBeanBridge.java:168)
    at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(
DynamicMetaDataImpl.java:213)
    at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(
DefaultMBeanServerInterceptor.java:815)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java
:784)
    at javax.management.remote.rmi.RMIConnectionImpl.doOperation(
RMIConnectionImpl.java:1410)
    at javax.management.remote.rmi.RMIConnectionImpl.access$100(
RMIConnectionImpl.java:81)
    at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run
(RMIConnectionImpl.java:1247)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(
RMIConnectionImpl.java:1350)
    at javax.management.remote.rmi.RMIConnectionImpl.invoke(
RMIConnectionImpl.java:784)
    at sun.reflect.GeneratedMethodAccessor115.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
    at sun.rmi.transport.Transport$1.run(Transport.java:153)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java
:466)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(
TCPTransport.java:707)
    at java.lang.Thread.run(Thread.java:595)


Does anything look obviously wrong in my GBeans or deployment plans, or is
there a better way for two GBeans to communicate with eachother?

-Ajay

Mime
View raw message