geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: gbean look up exception
Date Wed, 16 Nov 2005 07:44:38 GMT
I'm rather confused about what you are trying to do.  Here are a couple  
of comments that I hope will be at least a little bit useful.

I recommend putting all your code that does anything in classes rather  
than jsp pages.  It is very difficult to trace problems back to code in  
jsp pages.

If you wish to invoke a gbean, you need to know its complete name.   
ObjectName queries will not work.  Whereever *:name=echoserver came  
from, you need to change it so it supplies the entire object name of  
your gbean.  The easiest way to find out what that name is is to look  
in geronimo.log for notification that it has started.  Search for  
name=echoServer.  The full name has a lot more components.

I believe you are trying to access a gbean in the same geronimo  
instance as your web app.  Using the jmx connector is unnecessary and  
will require a lot of stuff you don't need, such as authenticating  
yourself to your gbean.  You can get the kernel more directly with  
KernelRegistry.getSingleKernel();

thanks
david jencks

On Nov 15, 2005, at 9:37 PM, Ranjan, Rakesh ((Cognizant)) wrote:

> 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(BasicRe 
> gistry.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.invo 
> ke(<generated>)
>  
>         at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
>  
>         at  
> org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodIn 
> voker.java:38)
>  
>         at  
> org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation. 
> java:118)
>  
>         at  
> org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.ja 
> va:795)
>  
>         at  
> org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java: 
> 180)
>  
>         at  
> org.apache.geronimo.kernel.jmx.MBeanServerDelegate.invoke(MBeanServerDe 
> legate.java:117)
>  
>         at  
> mx4j.remote.rmi.RMIConnectionInvoker.invoke(RMIConnectionInvoker.java: 
> 219)
>  
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  
>         at  
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja 
> va:39)
>  
>         at  
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso 
> rImpl.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(RMIConnectionSubjectI 
> nvoker.java:99)
>  
>         at  
> mx4j.remote.rmi.RMIConnectionSubjectInvoker.access$000(RMIConnectionSub 
> jectInvoker.java:31)
>  
>         at  
> mx4j.remote.rmi.RMIConnectionSubjectInvoker$1.run(RMIConnectionSubjectI 
> nvoker.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(RMIConnection 
> SubjectInvoker.java:86)
>  
>         at  
> mx4j.remote.rmi.RMIConnectionSubjectInvoker.invoke(RMIConnectionSubject 
> Invoker.java:80)
>  
>         at $Proxy1.invoke(Unknown Source)
>  
>         at  
> javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl. 
> java:221)
>  
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  
>         at  
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja 
> va:39)
>  
>         at  
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso 
> rImpl.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.j 
> ava: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