Re: CGLIB Related error (Full Code)
Hi Aaron, Thanks for your reply. You are right, it seems not to be a CGLIB-related issue. Anyway, here is the full code for the project I am working on: package mytask; import java.lang.*; import javax.management.ObjectName; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoBuilder; import org.apache.geronimo.gbean.GBeanLifecycle; import org.apache.geronimo.gbean.WaitingException; import org.apache.geronimo.kernel.jmx.JMXUtil; //import EDU.oswego.cs.dl.util.concurrent.*; import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; /** * Class MyGBean */ public class MyGBean implements GBeanLifecycle { private static Log log = LogFactory.getLog(MyGBean.class); private static final GBeanInfo GBEAN_INFO; private final ObjectName objectName; private MyThreadPool Pool; private APrinterGBean APrinter; private BPrinterGBean BPrinter; private boolean started = false; static { GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic (MyGBean.class, NameFactory.GERONIMO_SERVICE); // attributes infoFactory.addAttribute(objectName, String.class, false); // references infoFactory.addReference(Pool,MyThreadPool.class,NameFactory.GERONIMO_SERVICE); infoFactory.addReference(APrinter,APrinterGBean.class,NameFactory.GERONIMO_SERVICE); infoFactory.addReference(BPrinter,BPrinterGBean.class,NameFactory.GERONIMO_SERVICE); // operations infoFactory.addOperation(runPrinterA); infoFactory.addOperation(runPrinterB); infoFactory.addOperation(stopPrinters); //infoFactory.addOperation(getPool); infoFactory.setConstructor(new String[]{objectName}); //pool = new PooledExecutor(10); GBEAN_INFO = infoFactory.getBeanInfo(); } public void setPool( MyThreadPool Pool ) { this.Pool = Pool; } public void setAPrinter( APrinterGBean APrinter ) { this.APrinter = APrinter; } public void setBPrinter( BPrinterGBean BPrinter ) { this.BPrinter = BPrinter; } /** * Constructor MyGBean * * @param name @param objectName */ public MyGBean(String objectName ) { this.objectName = JMXUtil.getObjectName(objectName); } /** * Method doFail */ public void doFail() { System.out.println( objectName + failed); log.info(My GBean has failed); } /** * Method doStart * * @throws WaitingException * @throws Exception */ public void doStart() throws WaitingException, Exception { started = true; System.out.println(GBean: + objectName + has started); log.info(My GBean has started); log.info(objectName); log.info( bean1 = + APrinter); log.info( bean2 = + BPrinter); log.info( bean3 = + Pool); runPrinterA(); runPrinterB(); //log.info( Pool size is = + pool.getPoolSize() ); } /** * Method doStop * * @throws WaitingException * @throws Exception */ public void doStop() throws WaitingException, Exception { log.info(MyGBean has stopped); } public void stopPrinters(){ started = false; //this will stop the printers log.info(stopPrinters invocation!!!); } /** * @return Returns the thread pool. */ /*public MyThreadPool getPool() { return Pool; }*/ public void runPrinterA(){ //Run printer A in its own thread /*try{ pool.execute( new Runnable() { public void run() { while (started) { APrinter.print(); } } }); }catch(java.lang.InterruptedException e ){ System.out.println(I/O exception while running thread); }*/ } public void
CGLIB Related error (take a look at it)
Hi, I am getting the following error: 19:59:38,203 ERROR [GBeanInstanceState] Error while starting; GBean is now in the FAILED state: objectName=geronimo.server:J2EEApplication=null,J2EEModule=ibmtask/IBMTask,J2EEServer=geronimo,j2eeType=GBean,name=MyGBean java.lang.IllegalArgumentException: Cannot find matching method/constructor at ibmtask.MyThreadPool$$EnhancerByCGLIB$$55781bab$$FastClassByCGLIB$$3d9cb692.newInstance(generated) at net.sf.cglib.reflect.FastClass.newInstance(FastClass.java:91) at org.apache.geronimo.kernel.basic.BasicProxyManager$ManagedProxyFactory.createProxy(BasicProxyManager.java:211) at org.apache.geronimo.kernel.basic.BasicProxyManager.createProxy(BasicProxyManager.java:108) at org.apache.geronimo.gbean.runtime.GBeanSingleReference.start(GBeanSingleReference.java:79) at org.apache.geronimo.gbean.runtime.GBeanInstance.createInstance(GBeanInstance.java:863) at org.apache.geronimo.gbean.runtime.GBeanInstanceState.attemptFullStart(GBeanInstanceState.java:325) at org.apache.geronimo.gbean.runtime.GBeanInstanceState.start(GBeanInstanceState.java:110) at org.apache.geronimo.gbean.runtime.GBeanInstance.start(GBeanInstance.java:520) at org.apache.geronimo.gbean.runtime.GBeanSingleReference.attemptFullStart(GBeanSingleReference.java:154) at org.apache.geronimo.gbean.runtime.GBeanSingleReference.targetAdded(GBeanSingleReference.java:127) at org.apache.geronimo.gbean.runtime.AbstractGBeanReference.addTarget(AbstractGBeanReference.java:242) at org.apache.geronimo.gbean.runtime.GBeanSingleReference$1.running(GBeanSingleReference.java:163) at org.apache.geronimo.kernel.basic.BasicLifecycleMonitor.fireRunningEvent(BasicLifecycleMonitor.java:155) at org.apache.geronimo.kernel.basic.BasicLifecycleMonitor.access$300(BasicLifecycleMonitor.java:38) at org.apache.geronimo.kernel.basic.BasicLifecycleMonitor$RawLifecycleBroadcaster.fireRunningEvent(BasicLifecycleMonitor.java:231) at org.apache.geronimo.gbean.runtime.GBeanInstanceState.attemptFullStart(GBeanInstanceState.java:350) at org.apache.geronimo.gbean.runtime.GBeanInstanceState.start(GBeanInstanceState.java:110) at org.apache.geronimo.gbean.runtime.GBeanInstanceState.startRecursive(GBeanInstanceState.java:132) at org.apache.geronimo.gbean.runtime.GBeanInstance.startRecursive(GBeanInstance.java:537) at org.apache.geronimo.kernel.basic.BasicKernel.startRecursiveGBean(BasicKernel.java:208) at org.apache.geronimo.kernel.config.Configuration.startRecursiveGBeans(Configuration.java:315) at org.apache.geronimo.kernel.config.Configuration$$FastClassByCGLIB$$7f4b4a9b.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:118) at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:835) at org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:178) at org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:173) at org.apache.geronimo.kernel.config.ConfigurationManagerImpl.start(ConfigurationManagerImpl.java:142) at org.apache.geronimo.kernel.config.ConfigurationManagerImpl$$FastClassByCGLIB$$fbed85d2.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:118) at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:835) at org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:178) at org.apache.geronimo.kernel.KernelGBean.invoke(KernelGBean.java:125) 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:118) at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:835) at org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:178) at org.apache.geronimo.kernel.jmx.MBeanServerDelegate.invoke(MBeanServerDelegate.java:117) at mx4j.remote.rmi.RMIConnectionInvoker.invoke(RMIConnectionInvoker.java:219) at sun.reflect.GeneratedMethodAccessor176.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at
Patterns dont match
Hi all, I am trying to run a sample application and I get the following error on the log file: 00:17:18,234 INFO [BPrinterGBean] BPrinterGBean has started 00:17:18,234 INFO [BPrinterGBean] geronimo.server:J2EEApplication=null,J2EEModule=sampleTask/Sample,J2EEServer=geronimo,j2eeType=GBean,name=gbean2 00:17:18,250 DEBUG [GBeanSingleReference] Waiting to start geronimo.server:J2EEApplication=null,J2EEModule=sampleTask/Sample,J2EEServer=geronimo,j2eeType=GBean,name=MyGBean because no targets are running for reference Executor matching the patterns geronimo.server:J2EEApplication=null,J2EEModule=sampleTask/Sample,J2EEServer=geronimo,j2eeType=null,name=DTP 00:17:18,250 DEBUG [GBeanSingleReference] Waiting to start geronimo.server:J2EEApplication=null,J2EEModule=sampleTask/Sample,J2EEServer=geronimo,j2eeType=GBean,name=MyGBean because no targets are running for reference APrinter matching the patterns geronimo.server:J2EEApplication=null,J2EEModule=sampleTask/Sample,J2EEServer=geronimo,j2eeType=null,name=gbean1 00:17:18,250 DEBUG [GBeanSingleReference] Waiting to start geronimo.server:J2EEApplication=null,J2EEModule=sampleTask/Sample,J2EEServer=geronimo,j2eeType=GBean,name=MyGBean because no targets are running for reference BPrinter matching the patterns geronimo.server:J2EEApplication=null,J2EEModule=sampleTask/Sample,J2EEServer=geronimo,j2eeType=null,name=gbean2 00:17:18,250 INFO [APrinterGBean] APrinterGBean has started 00:17:18,250 INFO [APrinterGBean] geronimo.server:J2EEApplication=null,J2EEModule=sampleTask/Sample,J2EEServer=geronimo,j2eeType=GBean,name=gbean1 As you can see, clearly the patterns dont match because in one case we have j2eeType=null and in the other we have j2eeType=GBean. How can I set the j2eeType to GBean so that the patter can be matched ? Also, how can I be sure that the GBeans get loaded in the proper order ? In this case, the MyGBean has references to the three other GBeans: BPrinterGBean, APrinterGBean and DTP (Default Thread Pool). As you can read in the log file, only two GBeans (AprinterGBean and BPrinterGBean) get loaded and started, but not DTP and MyGBean. The plan looks as follows: ?xml version=1.0 encoding=UTF-8? configuration xmlns=http://geronimo.apache.org/xml/ns/deployment; configId=sampleTask/Sample dependency groupIdsamples/groupId artifactIdsampleTask/artifactId version1.0/version /dependency gbean name=gbean1 class=sampleTask.APrinterGBean /gbean gbean name=gbean2 class=sampleTask.BPrinterGBean /gbean gbean name=DTP class=org.apache.geronimo.pool.ThreadPool attribute name=keepAliveTime15000/attribute attribute name=poolSize10/attribute attribute name=poolNameDTP/attribute /gbean gbean name=MyGBean class=sampleTask.MyGBean reference name=APrinter namegbean1/name /reference reference name=BPrinter namegbean2/name /reference reference name=Executor nameDTP/name /reference /gbean /configuration BTW, is there a better place to post this issue ? Any help is appreciated! Thanks, Nelson. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Dealing with multiple GBeans
Hi All, With you help I have been developing a small application. The goal is very simple, we have 3 GBeans: MyGBean, APrinterGBean and BPrinterGBean. MyGBean invokes a print operation on the two printers which it references and gets via dependency injection. MyGBean prints MyGBean when started. For the other two GBeans, they have public print operations that when invoked (by MyGBean in this case) they output APrinterGBean and BPrinterGBean respectively. So, if all were working correctly, we would see the sequence: MyGBean APrinterGBean BPrinterGBean If I run MyGBean without referencing any of the printer GBeans, I get the correct message: MyGBean. However, when I do handle the references for APrinterGBean and BPrinterGBean, I am able to compile and deploy the configuratiion plan successfuly, but only APrinterGBean and BPrinterGBean get started and as a result nothing gets printed. It is puzzling that it seems to be working fine, but MyGBean just doesn't get started, because if it were, we would see the sequence of the three messages: MyGBean APrinterGBean BPrinterGBean Any idea on why this is happening ? It all seems to be done properly, so I am a bit surprised. The configuration plan that I am using is: ?xml version=1.0 encoding=UTF-8? configuration xmlns=http://geronimo.apache.org/xml/ns/deployment; configId=task/SampleTask dependency groupIdsamples/groupId artifactIdtask/artifactId version1.0/version /dependency gbean name=gbean1 class=task.APrinterGBean /gbean gbean name=gbean2 class=task.BPrinterGBean /gbean !-- gbean name=DefaultThreadPool class=org.apache.geronimo.pool.ThreadPool attribute name=keepAliveTime15000/attribute attribute name=poolSize30/attribute attribute name=poolNameDefaultThreadPool/attribute /gbean -- gbean name=MyGBean class=task.MyGBean !-- reference name=ExecutornameDefaultThreadPool/name/reference -- reference name=APrinter nameAPrinterGBean/name /reference reference name=BPrinter nameBPrinterGBean/name /reference /gbean !-- gbean name=PrintStopper class=task.PrintStopper / /gbean -- /configuration The MyGBean looks as follows: public class MyGBean implements GBeanLifecycle { ... private APrinterGBean APrinter; private BPrinterGBean BPrinter; ... public void setAPrinter( APrinterGBean APrinter ) { this.APrinter = APrinter; } public void setBPrinter( BPrinterGBean BPrinter ) { this.BPrinter = BPrinter; } ... infoFactory.addReference(APrinter,APrinterGBean.class); infoFactory.addReference(BPrinter,BPrinterGBean.class); ... public void doStart() throws WaitingException, Exception { System.out.println(GBean: + objectName + has started); log.info(My GBean has started); log.info(objectName); log.info( bean1 = + APrinter); log.info( bean2 = + BPrinter); print(); //prints: MyGBean APrinter.print(); //prints: APrinterGBean BPrinter.print(); //prints: BPrinterGBean } Clearly, the doStart() of MyGBean operation is not being executed, but I dont get any error messages related to MyGBean on the console nor on the log files. So, the issue here is that the configuration plan is deployed correctly, APrinterGBean and BPrinterGBean get started, but MyGBean is not getting started. Finally, in the next step of my little project I will make both APrinterGBean and BPRinterGBean run each on a ThreadPool. Each will run an infinite loop and I will create a fourth GBean whose sole purpose will be to stop the two printers. You can see the beginnings of this in the commented sections of my config plan above. After I am done, I can post the whole project, so that others can learn from it. The Internet is full of examples with code that does not compile, so I am sure this my code will be useful to others. Thanks, NP. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Proper use of reference tags in configuration plans
Hi all, I am developing a configuration plan involving multiple GBeans. One of them, MainGBean, will make use of the other GBeans. I am specifying the dependencies as follows: ?xml version=1.0 encoding=UTF-8? configuration xmlns=http://geronimo.apache.org/xml/ns/deployment; configId=task/SampleGBean dependency groupIdsamples/groupId artifactIdtask/artifactId version1.0/version /dependency gbean name=gb1 class=task.APrinterGBean /gbean gbean name=gb2 class=task.BPrinterGBean /gbean gbean name=MainGBean class=task.MyGBean reference name=Aprintergb1/reference reference name=Bprintergb2/reference /gbean /configuration The idea is that MainGBean references gb1 and gb2 and makes use of them. However, I get errors related to the reference tags and as a result it cant be deployed. If I remove the reference tags, then it can be deployed but NullPointerExceptions are thrown at run-time when MainGBean tries to make use of these two GBeans that it references. Any help on the proper use of the reference tag will be appreciated. Thanks, NP. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Invalid ObjectName Issue
Hi All, I get the following error while trying to deploy my sample application: (Apache Geronimo is running on another console) Error: Unable to distribute mygbean.xml: Invalid ObjectName: geronimo.example1.name=Simple GBean Invalid value; geronimo.example1:name=Simple GBean The configuration plan that I am using looks as follows: ?xml version=1.0 encoding=UTF-8? configuration xmlns=http://geronimo.apache.org/xml/ns/deployment; configId=example1/MyGBean dependency groupIdsamples/groupId artifactIdmygbean/artifactId version1.0/version /dependency gbean name=geronimo.example1:name=Simple GBean class=example1.MyGBean / /configuration and the GBean is just: ( sample taken from Wiki: http://wiki.apache.org/geronimo/GBeans) package example1; import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoBuilder; public class MyGBean { public static final GBeanInfo GBEAN_INFO; static { GBeanInfoBuilder infoBuilder = new GBeanInfoBuilder(MyGBean, MyGBean.class); GBEAN_INFO = infoBuilder.getBeanInfo(); } public static GBeanInfo getGBeanInfo() { return GBEAN_INFO; } } My build file is: project name=geronimo-mygbean-sample default=build property name=geronimo.home value=../ path id=geronimo.classpath fileset dir=${geronimo.home}/repository include name=**/*.jar/ /fileset /path target name=init mkdir dir=build/ mkdir dir=build/classes/ /target target name=build depends=init javac srcdir=src destdir=build/classes classpath= classpath refid=geronimo.classpath/ /javac mkdir dir=${geronimo.home}/repository/samples/jars/ jar jarfile=mygbean-1.0.jar basedir=build/classes/ copy file=mygbean-1.0.jar tofile=${geronimo.home}/repository/samples/jars/mygbean-1.0.jar/ /target /project This is an example as simple as it can get. I am now NOT getting the Missing Dependency Exception thanks to advice from Aaron Mulder on how to specify properly the URI. Yet, this new issue is preventing me from running this simple GBean. Any help on this new issue will be appreciated. Thanks! NP. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com