geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aaron Mulder" <ammul...@alumni.princeton.edu>
Subject Re: KernelRegistry does not return a reference to Kernel + class loader issue
Date Tue, 21 Mar 2006 16:24:25 GMT
For the kernel problem, what kind of code is calling
Kernel.getSingleKernel?  When you say it returns null and you don't
get any exception on the server side, it makes it sound like a client
is calling Kernel.getSingleKernel, which we would not expect to work. 
That method will probably only work within the server VM.  There is a
way to get a remote Kernel, but it's more complex (you can look at how
it's done in the deploy tool, for example).

So here's what looks like the key part of the class loading problem:

java.lang.NoClassDefFoundError: javax/management/ObjectName
       at
com..ojb.transaction.WebSphereCETransactionManagerFactory.getTransaction
Manager(WebSphereCETransactionManagerFactory.java:48)
       at
org.apache.ojb.broker.core.PersistenceBrokerFactorySyncImpl.<init>(Unkno
wn Source)

Did you abbreviate that 2nd line?  I think that's an important one. 
Something related to OJB cannot find the JMX classes...  But it
doesn't look like that's actually an OJB class since it starts with
"com." -- we need to figure out who's providing that class.  Maybe
com.xmeta?  Is that actually your code?

As far as classloaders go, it looks like CoreRepositoryFactory is
creating a new class, and then PersistenceBrokerFactoryFactory is
trying to create a class, and then PersistenceBrokerFactorySyncImpl is
trying to call WebSphereCETransactionManagerFactory.getTransactionManager
and that's got the wrong class loader.  So they key will be idenfiying
what CL is used at each step and where it goes wrong.

Also, how are OJB and xmeta packaged in your application?  Are they
included in WEB-INF/lib, for example, or in a JAR in the Geronimo
repository, or what?

Thanks,
    Aaron

On 3/21/06, Siraj Mohamed <Siraj@virtusa.com> wrote:
> Thanks Aaron for a reply.
>
> Let me explain what I am really doing. We have an EJB application (EAR)
> which is running on WebSphere and I am currently migrating this into
> WASCE.
>
> This is the back end service called 'xmeta' which let user perform any
> database activities through Apache OJB and EMF (Eclipse Modeling
> Framework).  The xmeta EAR contains many EJBs with public interface
> methods so that end user could use it to perform 'insert', 'delete',
> 'update' operations on the target database through ORM. The OJB
> configuration is provided with a jar named ojb-conf.jar which has
> information about data source reference, ORM mappings and a java class
> which is used to get a TransactionManager of the application server. For
> example, Apache provides
> org.apache.ojb.broker.transaction.tm.JBossTransactionManagerFactory for
> Jboss and
> org.apache.ojb.broker.transaction.tm.WebSphereTransactionManagerFactory
> for Websphere. My intention is to write a java class
> (WebSphereCETransactionManagerFactory) same as websphere and jboss to
> get a reference of the TransactionManager so that I can specify this
> class name in the OJB.properties (it is bundled in the ojb-conf.jar) and
> the class name is specified with a key JTATransactionManagerClass= in
> same the property file. My original mail refers this java class and I
> just wanted to test my code. I ran this class through eclipse but
> following code returns null.
>
> kernel = KernelRegistry.getSingleKernel();
>
> I do not get any exception in the server side and it just returns me a
> null. That was my first problem and I am not sure why am I getting null.
> Do I need any additional code to get a connection to the WASCE before
> getting Kernel? My class path has the jndi.properties for WASCE.
>
> This is my 2nd problem and it seems to be a class loader problem. I
> could able to deploy my xmeta application (EAR) successfully on WASCE
> and I also successfully created a data source with MySQL as back end. My
> next step is to see whether I could talk to database through OJB by
> invoking a method of a service of xmeta application (say
> SandboxAdminService). I bundled my written java class in a jar and
> copied it to the WASCE_HOME\lib\endorsed folder and also copied
> ojb-conf.jar to the same folder. The ojb-conf.jar will be read by
> SandboxAdminService EJB to get information such as data source name and
> the java class name which is used to get a reference of the
> TransactionManager and other ORM mappings.
>
> At end, when I invoke client, I am getting following
> NoClassDefFoundError:
>
> 17:00:17,861 INFO  [RepositoryPersistor] OJB Descriptor Repository:
> jar:file:/C:/IBM/WebSphere/AppServerCommunityEdition/lib/endorsed/ojb-co
> nf.jar!/repository.xml
> 17:00:17,861 INFO  [RepositoryPersistor] Building repository from
> :jar:file:/C:/IBM/WebSphere/AppServerCommunityEdition/lib/endorsed/ojb-c
> onf.jar!/repository.xml
> 17:00:18,268 INFO  [RepositoryPersistor] Read class descriptors took 407
> ms
> 17:00:18,268 INFO  [RepositoryPersistor] OJB Descriptor Repository:
> jar:file:/C:/IBM/WebSphere/AppServerCommunityEdition/lib/endorsed/ojb-co
> nf.jar!/repository.xml
> 17:00:18,268 INFO  [RepositoryPersistor] Building repository from
> :jar:file:/C:/IBM/WebSphere/AppServerCommunityEdition/lib/endorsed/ojb-c
> onf.jar!/repository.xml
> 17:00:18,377 INFO  [RepositoryPersistor] Read connection repository took
> 109 ms
> 17:00:18,424 INFO  [PersistenceBrokerFactoryDefaultImpl] Create
> PersistenceBroker instance pool, pool configuration was
> {whenExhaustedAction=2, maxIdle=-1, maxActive=100, maxWait=2000,
> removeAbandoned=false, numTestsPerEvictionRun=10, testWhileIdle=false,
> minEvictableIdleTimeMillis=1000000, testOnReturn=false,
> logAbandoned=false, removeAbandonedTimeout=300,
> timeBetweenEvictionRunsMillis=-1, testOnBorrow=false}
> 17:00:18,424 INFO  [WebSphereCETransactionManagerFactory]
> WebSphereCETransactionManagerFactory +++++++++ 1
> 17:00:18,424 WARN  [SystemExceptionInterceptor] SandboxAdminService
> java.lang.NoClassDefFoundError: javax/management/ObjectName
>         at
> com..ojb.transaction.WebSphereCETransactionManagerFactory.getTransaction
> Manager(WebSphereCETransactionManagerFactory.java:48)
>         at
> org.apache.ojb.broker.core.PersistenceBrokerFactorySyncImpl.<init>(Unkno
> wn Source)
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
>         at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorA
> ccessorImpl.java(Compiled Code))
>         at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCons
> tructorAccessorImpl.java(Compiled Code))
>         at
> java.lang.reflect.Constructor.newInstance(Constructor.java(Compiled
> Code))
>         at java.lang.Class.newInstance3(Class.java(Compiled Code))
>         at java.lang.Class.newInstance(Class.java(Compiled Code))
>         at org.apache.ojb.broker.util.ClassHelper.newInstance(Unknown
> Source)
>         at
> org.apache.ojb.broker.core.PersistenceBrokerFactoryFactory.init(Unknown
> Source)
>         at
> org.apache.ojb.broker.core.PersistenceBrokerFactoryFactory.<clinit>(Unkn
> own Source)
>         at
> com.xmeta.persistence.orm.impl.ojb.JBossOjbPersistenceBrokerFactory.crea
> tePersistenceBroker(JBossOjbPersistenceBrokerFactory.java:47)
>         at
> com.xmeta.persistence.orm.impl.ojb.AbstractOjbPersistenceBrokerFactory.c
> reateBroker(AbstractOjbPersistenceBrokerFactory.java:50)
>         at
> com.xmeta.persistence.orm.impl.ojb.OjbObjectPersistence.getBroker(OjbObj
> ectPersistence.java:72)
>         at
> com.xmeta.persistence.orm.impl.ojb.OjbPersistentEObjectPersistence.getBr
> oker(OjbPersistentEObjectPersistence.java:162)
>         at
> com.xmeta.persistence.orm.impl.ojb.OjbPersistentEObjectPersistenceRegist
> ry.getBroker(OjbPersistentEObjectPersistenceRegistry.java:301)
>         at
> com.xmeta.persistence.orm.impl.ojb.OjbPersistentEObjectPersistenceRegist
> ry.loadPackageCache(OjbPersistentEObjectPersistenceRegistry.java:350)
>         at
> com.xmeta.persistence.orm.impl.ojb.OjbPersistentEObjectPersistenceRegist
> ry.initialize(OjbPersistentEObjectPersistenceRegistry.java:131)
>         at
> com.xmeta.persistence.orm.impl.ojb.OjbPersistentEObjectPersistence.initi
> alize(OjbPersistentEObjectPersistence.java:318)
>         at
> com.xmeta.persistence.impl.basic.BasicPersistence.initialize(BasicPersis
> tence.java:369)
>         at
> com.xmeta.persistence.impl.basic.BasicPersistenceManager.initialize(Basi
> cPersistenceManager.java:75)
>         at
> com.xmeta.repository.core.impl.DefaultSandboxAdmin.<init>(DefaultSandbox
> Admin.java:124)
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
>         at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorA
> ccessorImpl.java(Compiled Code))
>         at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCons
> tructorAccessorImpl.java(Compiled Code))
>         at
> java.lang.reflect.Constructor.newInstance(Constructor.java(Compiled
> Code))
>         at java.lang.Class.newInstance3(Class.java(Compiled Code))
>         at java.lang.Class.newInstance(Class.java(Compiled Code))
>         at
> com.xmeta.repository.core.CoreRepositoryFactory.createSandboxAdmin(CoreR
> epositoryFactory.java:153)
>         at
> com.xmeta.service.repository.core.SandboxAdminServiceBean.<init>(Sandbox
> AdminServiceBean.java:115)
>         at
> com.xmeta.service.repository.core.SandboxAdminServiceBean$$FastClassByCG
> LIB$$d9825d07.newInstance(<generated>)
>         at net.sf.cglib.reflect.FastClass.newInstance(FastClass.java:91)
>         at
> org.openejb.EJBInstanceFactoryImpl.newInstance(EJBInstanceFactoryImpl.ja
> va:76)
>         at
> org.openejb.sfsb.StatefulInstanceContextFactory.newInstance(StatefulInst
> anceContextFactory.java:119)
>         at
> org.openejb.sfsb.StatefulInstanceFactory.createInstance(StatefulInstance
> Factory.java:86)
>         at
> org.openejb.sfsb.StatefulInstanceInterceptor.getInstanceContext(Stateful
> InstanceInterceptor.java:144)
>         at
> org.openejb.sfsb.StatefulInstanceInterceptor.invoke(StatefulInstanceInte
> rceptor.java:92)
>         at
> org.openejb.transaction.ContainerPolicy$TxNotSupported.invoke(ContainerP
> olicy.java:89)
>         at
> org.openejb.transaction.TransactionContextInterceptor.invoke(Transaction
> ContextInterceptor.java:80)
>         at
> org.openejb.SystemExceptionInterceptor.invoke(SystemExceptionInterceptor
> .java:82)
>         at
> org.openejb.GenericEJBContainer.invoke(GenericEJBContainer.java:238)
>         at
> org.openejb.server.ejbd.EjbRequestHandler.invoke(EjbRequestHandler.java:
> 297)
>         at
> org.openejb.server.ejbd.EjbRequestHandler.doEjbHome_CREATE(EjbRequestHan
> dler.java:342)
>         at
> org.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandl
> er.java:205)
>         at org.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:150)
>         at org.openejb.server.ejbd.EjbServer.service(EjbServer.java:87)
>         at
> org.openejb.server.ejbd.EjbServer$$FastClassByCGLIB$$d379d2ff.invoke(<ge
> nerated>)
>         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:800)
>         at
> org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
>         at
> org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperation
> Invoker.java:36)
>         at
> org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyM
> ethodInterceptor.java:96)
>         at
> org.activeio.xnet.ServerService$$EnhancerByCGLIB$$81781c7d.service(<gene
> rated>)
>         at org.activeio.xnet.ServicePool$2.run(ServicePool.java:67)
>         at org.activeio.xnet.ServicePool$3.run(ServicePool.java:90)
>         at
> org.apache.geronimo.pool.ThreadPool$ContextClassLoaderRunnable.run(Threa
> dPool.java:138)
>         at
> EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown
> Source)
>         at java.lang.Thread.run(Thread.java:570)
>
>
> The exception is occurred at my newly written java class but the class
> javax/management/ObjectName is bundled with mx4j-3.0.1.jar which is
> available at WASCE_HOME\lib. It seems that WASCE class loader is not
> visible to either to EJB or 'endrosed' folder? I am not sure I was right
> that LIB folder is parent class loader and the endorsed is a child of
> lib?
>
> Please appreciate your help to resolve this problem.
>
> FYI: I have bundled all dependency Jars into EAR and this is my
> deployment plan
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <application
>      xmlns="http://geronimo.apache.org/xml/ns/j2ee/application"
>      configId="RXMeta"
>    parentId="geronimo/j2ee-server/1.0/car"
>      >
> </application>
>
> This is my openejb-jar.xml
>
> <?xml version="1.0"?>
>
> <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar"
> configId="ejb-RXMeta"
> parentId="geronimo/j2ee-server/1.0/car">
>
> <enterprise-beans>
>       <session>
>          <ejb-name>ImportService</ejb-name>
>          <jndi-name>ImportService</jndi-name>
>
>       </session>
>
>       <session>
>          <ejb-name>SandboxService</ejb-name>
>          <jndi-name>SandboxService</jndi-name>
>
>          <resource-ref>
>             <ref-name>xmeta_defaultDS</ref-name>
>             <resource-link>ASB</resource-link>
>          </resource-ref>
>
>       </session>
>
>       <session>
>          <ejb-name>ObjectDifferencingService</ejb-name>
>          <jndi-name>ObjectDifferencingService</jndi-name>
>
>
>       </session>
>
>       <session>
>          <ejb-name>GlobalSessionService</ejb-name>
>          <jndi-name>GlobalSessionService</jndi-name>
>
>       </session>
>
>       <session>
>          <ejb-name>DSImpactAnalysisService</ejb-name>
>          <jndi-name>DSImpactAnalysisService</jndi-name>
>       </session>
>
>       <session>
>          <ejb-name>OperationalRepositoryService</ejb-name>
>          <jndi-name>OperationalRepositoryService</jndi-name>
>
>          <resource-ref>
>             <ref-name>xmeta_defaultDS</ref-name>
>             <resource-link>ASB</resource-link>
>          </resource-ref>
>
>       </session>
>       <session>
>          <ejb-name>ExportService</ejb-name>
>          <jndi-name>ExportService</jndi-name>
>
>       </session>
>       <session>
>          <ejb-name>ImpactAnalysisService</ejb-name>
>          <jndi-name>ImpactAnalysisService</jndi-name>
>
>       </session>
>       <session>
>          <ejb-name>MetabrokerAdminService</ejb-name>
>          <jndi-name>MetabrokerAdminService</jndi-name>
>
>       </session>
>       <session>
>          <ejb-name>ObjectMergeService</ejb-name>
>          <jndi-name>ObjectMergeService</jndi-name>
>
>       </session>
>       <session>
>          <ejb-name>ImportDecodeService</ejb-name>
>          <jndi-name>ImportDecodeService</jndi-name>
>
>       </session>
>       <session>
>          <ejb-name>OperationalRepositoryAdminService</ejb-name>
>          <jndi-name>OperationalRepositoryAdminService</jndi-name>
>
>          <resource-ref>
>             <ref-name>xmeta_defaultDS</ref-name>
>             <resource-link>ASB</resource-link>
>          </resource-ref>
>
>       </session>
>       <session>
>          <ejb-name>StaticDataLineageService</ejb-name>
>          <jndi-name>StaticDataLineageService</jndi-name>
>
>       </session>
>       <session>
>          <ejb-name>SandboxAdminService</ejb-name>
>          <jndi-name>SandboxAdminService</jndi-name>
>
>          <resource-ref>
>             <ref-name>xmeta_defaultDS</ref-name>
>             <resource-link>ASB</resource-link>
>          </resource-ref>
>
>
>       </session>
>
> </enterprise-beans>
>
> </openejb-jar>
>
>
> Thanks & Regards,
> Siraj
>
>
>
>
>
>
>
>
>
>
>
>
>
> -----Original Message-----
> From: ammulder@gmail.com [mailto:ammulder@gmail.com] On Behalf Of Aaron
> Mulder
> Sent: Monday, March 20, 2006 10:10 PM
> To: user@geronimo.apache.org
> Subject: Re: KernelRegistry does not return a reference to Kernel
>
> If you're working on application code, is there a reason you're trying
> to use a TransactionManager instead of getting a UserTransaction from
> JNDI?  If you're writing a GBean you should have the
> TransactionManager injected (configured as a reference) instead of
> looking it up.
>
> In any case, it would generally help if you post the stack trace and
> double-check to be absolutely sure that it's definitely the
> getSingleKernel method that's returning null and not some surrounding
> code.  In this particular case I'm not sure how much a stack trace
> will help since I'm not sure what SVN revision of Geronimo the WASCE
> code is based on and what IBM might have changed, but it's certainly
> the case that you don't have much of a chance of a better diagnosis
> *without* the stack trace.  :)
>
> Thanks,
>     Aaron
>
> On 3/20/06, Siraj Mohamed <Siraj@virtusa.com> wrote:
> >
> >
> >
> > Hi All,
> >
> >
> >
> > I am using WASCE 1.0.0.1 version and I am trying to get a reference to
> the
> > TransactionManger from a Java class. This is the segment of my java
> class.
> >
> >
> >
> > TransactionManager tm = null;
> >
> > try
> >
> > {
> >
> >             ObjectName TM_NAME = new
> >
> >
> >
> ObjectName("geronimo.server:J2EEApplication=null,J2EEModule=geronimo/j2e
> e-server/1.0/car,J2EEServer=geronimo,j2eeType=TransactionManager,name=Tr
> ansactionManager");
> >
> >
> >
> >
> >
> >             Kernel kernel = KernelRegistry.getSingleKernel();
> >
> >             tm =
> > (TransactionManager)kernel.getProxyManager().createProxy(TM_NAME,
> >
> >             TransactionManager.class);
> >
> >
> >
> > }catch (Exception e)
> >
> > {
> >
> >             throw new
> > TransactionManagerFactoryException(e.getMessage());
> >
> > }
> >
> >
> >
> > This code does not work for me and I get a null return value when
> trying to
> > get the Kernel (KernelRegistry.getSingleKernel()).
> >
> >
> >
> > Am I missing some thing else? My WASCE application server is running
> up and
> > down.
> >
> >
> >
> > Please help me if any one knows the solution.
> >
> >
> >
> > Thanks and Regards,
> >
> > Siraj
>

Mime
View raw message