You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Juergen Weber <we...@gmail.com> on 2009/01/19 13:46:15 UTC

deploy a GBean - how ?

Hi,

I try to encapsulate my JNI calls in a GBean.

I read a lot of docs and articles, wrote my GBean along the sample in this
posting
http://www.nabble.com/POJO-caching-in-geronimo-td16986524s134.html

read this Wiki entry: http://cwiki.apache.org/GMOxDEV/gbeansarticle1.html
Unfortunately the entry does not tell how to install a GBean into the
server.

I guess, you use the deployer or console and deploy a jar together with a
plan, isn't it?

The Wiki entry links this sample from
http://apache.org/~hemapani/docs/gbeans-sample.zip
but it does not work with 2.1.3, console says:

java.lang.ClassNotFoundException:
org.apache.geronimo.upgrade.Upgrade1_0To1_1 in classloader
org.apache.geronimo.plugins/plugin-console-tomcat/2.1.3/car

org.apache.geronimo.kernel.config.MultiParentClassLoader.loadOptimizedClass(MultiParentClassLoader.java:437)

org.apache.geronimo.kernel.config.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:279)
	java.lang.ClassLoader.loadClass(ClassLoader.java:597)

org.apache.geronimo.console.configmanager.DeploymentPortlet.processAction(DeploymentPortlet.java:189)
	org.apache.pluto.core.PortletServlet.dispatch(PortletServlet.java:218)
	org.apache.pluto.core.PortletServlet.doPost(PortletServlet.java:145)

Probably it does not like sample's plan's
<configuration
    xmlns="http://geronimo.apache.org/xml/ns/deployment"
    configId="test/plan2">
    

Then I tried

<?xml version="1.0" encoding="UTF-8"?>
<configuration
    xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2">
    configId="test/plan2">
    
    <gbean name="test:axis=gb1" class="my.JNIGBean">
    </gbean>
    
</configuration>

Now I get 

Deployment failed:
Cannot deploy the requested application module because no deployer is able
to handle it. This can happen if you have omitted the J2EE deployment
descriptor, disabled a deployer module, or if, for example, you are trying
to deploy an EJB module on a minimal Geronimo server that does not have EJB
support installed.

Then, how do I call a GBean method from a web app, is it still like cited in
the posting
http://www.nabble.com/POJO-caching-in-geronimo-td16986524s134.html ?

quoting:
<dependencies>
      <dependency>
        <groupId>com.w.core.geronimo.services</groupId>
        <artifactId>pojo-cache</artifactId>
        <version>1.0</version>
        <type>car</type>
      </dependency>
    </dependencies>
   
    ...
    </environment>  
    <gbean-ref
    xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1">
    <ref-name>cache</ref-name>
    <ref-type>java.util.Map</ref-type>
    <pattern>
      <name>POJOCache</name>
    </pattern>
  </gbean-ref>
 
And get the cache in the following manner

  cache = (Map<String, Template>) new InitialContext()
          .lookup("java:comp/env/cache");

end quote

Thanks,
Juergen




-- 
View this message in context: http://www.nabble.com/deploy-a-GBean---how---tp21542349s134p21542349.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: deploy a GBean - how ?

Posted by Juergen Weber <we...@gmail.com>.
I tried the MyGBean sample from http://cwiki.apache.org/GMOxDEV/gbeans.html
it doesn't deploy either.

I created https://issues.apache.org/jira/browse/GERONIMO-4520

Thanks,
Juergen


Juergen Weber wrote:
> 
> Hi,
> 
> I try to encapsulate my JNI calls in a GBean.
> 
> I read a lot of docs and articles, wrote my GBean along the sample in this
> posting
> http://www.nabble.com/POJO-caching-in-geronimo-td16986524s134.html
> 
> read this Wiki entry: http://cwiki.apache.org/GMOxDEV/gbeansarticle1.html
> Unfortunately the entry does not tell how to install a GBean into the
> server.
> 
> I guess, you use the deployer or console and deploy a jar together with a
> plan, isn't it?
> 
> The Wiki entry links this sample from
> http://apache.org/~hemapani/docs/gbeans-sample.zip
> but it does not work with 2.1.3, console says:
> 
> java.lang.ClassNotFoundException:
> org.apache.geronimo.upgrade.Upgrade1_0To1_1 in classloader
> org.apache.geronimo.plugins/plugin-console-tomcat/2.1.3/car
> 
> org.apache.geronimo.kernel.config.MultiParentClassLoader.loadOptimizedClass(MultiParentClassLoader.java:437)
> 
> org.apache.geronimo.kernel.config.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:279)
> 	java.lang.ClassLoader.loadClass(ClassLoader.java:597)
> 
> org.apache.geronimo.console.configmanager.DeploymentPortlet.processAction(DeploymentPortlet.java:189)
> 	org.apache.pluto.core.PortletServlet.dispatch(PortletServlet.java:218)
> 	org.apache.pluto.core.PortletServlet.doPost(PortletServlet.java:145)
> 
> Probably it does not like sample's plan's
> <configuration
>     xmlns="http://geronimo.apache.org/xml/ns/deployment"
>     configId="test/plan2">
>     
> 
> Then I tried
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <configuration
>     xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2">
>     configId="test/plan2">
>     
>     <gbean name="test:axis=gb1" class="my.JNIGBean">
>     </gbean>
>     
> </configuration>
> 
> Now I get 
> 
> Deployment failed:
> Cannot deploy the requested application module because no deployer is able
> to handle it. This can happen if you have omitted the J2EE deployment
> descriptor, disabled a deployer module, or if, for example, you are trying
> to deploy an EJB module on a minimal Geronimo server that does not have
> EJB support installed.
> 
> Then, how do I call a GBean method from a web app, is it still like cited
> in the posting
> http://www.nabble.com/POJO-caching-in-geronimo-td16986524s134.html ?
> 
> quoting:
> <dependencies>
>       <dependency>
>         <groupId>com.w.core.geronimo.services</groupId>
>         <artifactId>pojo-cache</artifactId>
>         <version>1.0</version>
>         <type>car</type>
>       </dependency>
>     </dependencies>
>    
>     ...
>     </environment>  
>     <gbean-ref
>     xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1">
>     <ref-name>cache</ref-name>
>     <ref-type>java.util.Map</ref-type>
>     <pattern>
>       <name>POJOCache</name>
>     </pattern>
>   </gbean-ref>
>  
> And get the cache in the following manner
> 
>   cache = (Map<String, Template>) new InitialContext()
>           .lookup("java:comp/env/cache");
> 
> end quote
> 
> Thanks,
> Juergen
> 
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/deploy-a-GBean---how---tp21542349s134p21559917.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: deploy a GBean - how ?

Posted by Juergen Weber <we...@gmail.com>.
OK, I finally got my GBean deployed. Correct information is in 
http://www.devx.com/Java/Article/33549/0/page/3

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">
	<environment>
		<moduleId>
			<groupId>...</groupId>
			<artifactId>...</artifactId>
			<version>1.1</version>
		</moduleId>
	</environment>

	<gbean name="..." class="....">
	</gbean>
</module>

Right now I access the GBean from a servlet using (is that the correct way?)

Kernel kernel = KernelRegistry.getSingleKernel();
URI uri = new URI(myuri); 
AbstractName gBeanAN = new AbstractName(uri);
retVal = kernel.invoke(gBeanAN,"myMethod",args,paramTypes);
	
with myuri from the abstractName field of the GBean in JMX Viewer in
Console, which is quite a long uri.

So I tried to bind the GBean into JNDI as suggested in 
http://www.nabble.com/How-to-get-hold-of-a-WorkManager-in-a-web-app--td21400861s134.html

<gbean name="...BeanBinding"
class="org.apache.geronimo.gjndi.binding.GBeanBinding">
        <attribute name="name">...</attribute>
        <attribute name="abstractNameQuery">?name=MyJNIGBean#</attribute>
        <reference name="Context">
            <name>JavaContext</name>
        </reference>
    </gbean>

but then I get Classnotfound for GBeanBinding. How do you specify a
dependency for this class?
and what is the abstractNameQuery for the GBean? the full AbstractName ?

Thanks,
Juergen
-- 
View this message in context: http://www.nabble.com/deploy-a-GBean---how---tp21542349s134p21588188.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.