geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ranjan, Rakesh \(Cognizant\)" <Rakesh.Ran...@cognizant.com>
Subject gbean look up exception
Date Wed, 16 Nov 2005 05:37:25 GMT

Hi all,



I have deployed a GBean. Then I am trying to look up that GBean through
Jsp page. But I am getting exception :







GBean exception occurred during
initializationorg.apache.geronimo.kernel.GBeanNotFoundException:
*:name=echoserver not found



org.apache.geronimo.kernel.GBeanNotFoundException: *:name=echoserver not
found



        at
org.apache.geronimo.kernel.basic.BasicRegistry.getGBeanInstance(BasicReg
istry.java:110)



        at
org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:179
)



        at
org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:175
)



        at
org.apache.geronimo.kernel.KernelGBean.invoke(KernelGBean.java:121)



        at
org.apache.geronimo.kernel.KernelGBean$$FastClassByCGLIB$$1cccefc9.invok
e(<generated>)



        at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)



        at
org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInv
oker.java:38)



        at
org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.j
ava:118)



        at
org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.jav
a:795)



        at
org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:180
)



        at
org.apache.geronimo.kernel.jmx.MBeanServerDelegate.invoke(MBeanServerDel
egate.java:117)



        at
mx4j.remote.rmi.RMIConnectionInvoker.invoke(RMIConnectionInvoker.java:21
9)



        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)



        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)



        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)



        at java.lang.reflect.Method.invoke(Method.java:324)



        at
mx4j.remote.rmi.RMIConnectionProxy.invoke(RMIConnectionProxy.java:34)



        at
mx4j.remote.rmi.RMIConnectionSubjectInvoker.chain(RMIConnectionSubjectIn
voker.java:99)



        at
mx4j.remote.rmi.RMIConnectionSubjectInvoker.access$000(RMIConnectionSubj
ectInvoker.java:31)



        at
mx4j.remote.rmi.RMIConnectionSubjectInvoker$1.run(RMIConnectionSubjectIn
voker.java:90)



        at java.security.AccessController.doPrivileged(Native Method)



        at javax.security.auth.Subject.doAsPrivileged(Subject.java:500)



        at
mx4j.remote.MX4JRemoteUtils.subjectInvoke(MX4JRemoteUtils.java:163)



        at
mx4j.remote.rmi.RMIConnectionSubjectInvoker.subjectInvoke(RMIConnectionS
ubjectInvoker.java:86)



        at
mx4j.remote.rmi.RMIConnectionSubjectInvoker.invoke(RMIConnectionSubjectI
nvoker.java:80)



        at $Proxy1.invoke(Unknown Source)



        at
javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.j
ava:221)



        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)



        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)



        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)



        at java.lang.reflect.Method.invoke(Method.java:324)



        at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)



        at sun.rmi.transport.Transport$1.run(Transport.java:148)



        at java.security.AccessController.doPrivileged(Native Method)



        at sun.rmi.transport.Transport.serviceCall(Transport.java:144)



        at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)



        at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.ja
va:701)



        at java.lang.Thread.run(Thread.java:534)







GBean code

public class EchoServer implements GBeanLifecycle {



    private static final GBeanInfo GBEAN_INFO;

    private final String objectName;

    private int port;

    private ServerSocket serversocket;

    private boolean started = false;



    static {



        GBeanInfoBuilder infoFactory =

            new GBeanInfoBuilder(EchoServer.class.getName(),
EchoServer.class);

        // attributes

        infoFactory.addAttribute("objectName", String.class, false);

        infoFactory.addAttribute("port", int.class, true);

        // operations

        infoFactory.setConstructor(new String[] { "objectName", "port"
});

        GBEAN_INFO = infoFactory.getBeanInfo();

    }

    public EchoServer(String objectName, int port) {

        this.objectName = objectName;

        this.port = port;

    }

    public EchoServer() {

        objectName = null;

    }

    /**

     * Method doFail

     */

    public void doFail() {

        System.out.println("Axis GBean has failed");

    }

    /**

     * Method doStart

     *

     * @throws WaitingException

     * @throws Exception

     */

    public void doStart() throws WaitingException, Exception {

        System.out.println("[EchoServer, port = " + port + "] GBean " +
objectName + " Started");

        serversocket = new ServerSocket(port);

        started = true;

        Thread thread1 = new Thread(new Runnable() {

            public void run() {

                while (started) {

                    try {

                        Socket socket = serversocket.accept();

                        InputStream in = socket.getInputStream();

                        OutputStream out = socket.getOutputStream();

                        BufferedReader reader = new BufferedReader(new
InputStreamReader(in));

                        out.write(reader.readLine().getBytes());

                        reader.close();

                        out.close();

                        socket.close();

                    } catch (IOException e) {

                        // TODO Auto-generated catch block

                        e.printStackTrace();

                    }

                }

            }

        });

        thread1.start();

    }

    /**

     * Method doStop

     *

     * @throws WaitingException

     * @throws Exception

     */

    public void doStop() throws WaitingException, Exception {

        started = false;

        System.out.println("GBean " + objectName + " Stoped");

        serversocket.close();

    }

    /**

     * Method getGBeanInfo

     *

     * @return

     */

    public static GBeanInfo getGBeanInfo() {

        return GBEAN_INFO;

    }



    Public int getPort() {

       Return port;

    }

}





Configuration xml file is :



<?xml version="1.0" encoding="UTF-8"?>

<configuration xmlns="http://geronimo.apache.org/xml/ns/deployment"
configId="deployment/echoserver">

    <dependency>

      <uri>sample/jars/samples.jar</uri>

      </dependency>

    <gbean name="echoserver" class="com.Echoserver" >

           <attribute name="port" type="int">2345</attribute>

    </gbean>   

</configuration>

Jsp Page

<%

   String output = "";

   //Kernel kernel = new Kernel();

   //kernel.boot();

   String
uri="deployer:geronimo:jmx:rmi:///jndi/rmi://localhost:1099/JMXConnector
";

   String URI_PREFIX = "deployer:geronimo:";

   ObjectName on =null;

   Kernel kernel = null;

   try {

         uri = uri.substring(URI_PREFIX.length());

         Map environment = new HashMap();

         String[] credentials = new String[]{"system", "manager"};

         environment.put(JMXConnector.CREDENTIALS, credentials);

         JMXServiceURL address = new JMXServiceURL("service:" + uri);

         JMXConnector jmxConnector =
JMXConnectorFactory.connect(address, environment);

         MBeanServerConnection
mbServerConnection=jmxConnector.getMBeanServerConnection();

         //JMXDeploymentManager manager = new
JMXDeploymentManager(jmxConnector);

         kernel = new KernelDelegate(mbServerConnection);

     }catch(Exception e){

       System.err.println("Exception 1");

      }

       try{

         String name="*:name=echoserver,*";

         on = ObjectName.getInstance(name);

      }

      catch(Exception e){ System.err.println("Exception 2"); }

      finally{ System.out.println("object Name instanciation
succesfull");}

       try{

         GBeanData gbd = new GBeanData(on,EchoServer.getGBeanInfo());

         Int port = (EchoServer)kernel.invoke(on,"getport");

%>





This e-mail and any files transmitted with it are for the sole use of the intended recipient(s)
and may contain confidential and privileged information.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy
all copies of the original message.
Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of
this email or any action taken in reliance on this e-mail is strictly
prohibited and may be unlawful.

  Visit us at http://www.cognizant.com
Mime
View raw message