Error in deploying CastorJDO Mbean in jboss 3.2.5
mmarcom Jul 16, 2004 11:20 AMhi all,
almost 6 months ago i downloaded from Castor website the CastorJDO Mbean, and i used it successfully with jboss 3.2.2 and jboss 3.2.3.
i recently moved to jboss 3.2.5, and when deploying EXACTLY the same code, i got following exception :
21:11:31,385 WARN [CastorJDOImpl] Unexcepted error accessing MBeanInfo for :ser vice=CastorJDO,name=null
javax.management.InstanceNotFoundException: :service=CastorJDO,name=null is not registered.
at org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegistr
y.java:462)
at org.jboss.mx.server.MBeanServerImpl.getMBeanInfo(MBeanServerImpl.java
:478)
at org.jboss.system.ServiceMBeanSupport.postRegister(ServiceMBeanSupport
.java:418)
at org.jboss.mx.server.AbstractMBeanInvoker.invokePostRegister(AbstractM
BeanInvoker.java:769)
at org.jboss.mx.server.AbstractMBeanInvoker.postRegister(AbstractMBeanIn
voker.java:571)
at org.jboss.mx.server.registry.BasicMBeanRegistry.registerMBean(BasicMB
eanRegistry.java:311)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
java:60)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
java:185)
at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
at org.jboss.mx.server.MBeanServerImpl.registerMBean(MBeanServerImpl.jav
a:1018)
at org.jboss.mx.server.MBeanServerImpl.registerMBean(MBeanServerImpl.jav
a:981)
at
org.jboss.mx.server.MBeanServerImpl.createMBean(MBeanServerImpl.java:
318)
at org.jboss.system.ServiceCreator.install(ServiceCreator.java:98)
at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigura
tor.java:149)
at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java
:114)
at org.jboss.system.ServiceController.install(ServiceController.java:198
)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
java:60)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
java:185)
at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
at $Proxy4.install(Unknown Source)
at org.jboss.deployment.SARDeployer.create(SARDeployer.java:204)
at org.jboss.deployment.MainDeployer.create(MainDeployer.java:790)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:644)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:608)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
java:60)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
java:185)
at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
at $Proxy7.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
tScanner.java:304)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
canner.java:478)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
doScan(AbstractDeploymentScanner.java:201)
at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(A
bstractDeploymentScanner.java:274)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanS
upport.java:271)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB
eanSupport.java:221)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
java:60)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
java:185)
at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
ler.java:837)
at $Proxy0.start(Unknown Source)
at
org.jboss.system.ServiceController.start(ServiceController.java:367)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
java:60)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
java:185)
at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
at $Proxy4.start(Unknown Source)
at org.jboss.deployment.SARDeployer.start(SARDeployer.java:251)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:836)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:645)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:608)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:592)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
java:60)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
java:185)
at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
at $Proxy5.deploy(Unknown Source)
at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:407)
at org.jboss.system.server.ServerImpl.start(ServerImpl.java:311)
at org.jboss.Main.boot(Main.java:145)
at org.jboss.Main$1.run(Main.java:399)
at java.lang.Thread.run(Thread.java:534)
this is the source code of the CastorJDO MBean
********************************
/*
* JBoss, the OpenSource EJB server
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.jdo.castor;
import java.io.PrintWriter;
import java.io.Serializable;
//import java.lang.reflect.InvocationHandler;
//import java.lang.reflect.Proxy;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Hashtable;
import javax.management.*;
import javax.naming.spi.ObjectFactory;
import javax.naming.Referenceable;
import javax.naming.Reference;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.Name;
import javax.naming.NamingException;
import javax.naming.NameNotFoundException;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.exolab.castor.jdo.Database;
import org.exolab.castor.jdo.DataObjects;
import org.exolab.castor.jdo.JDO;
import org.exolab.castor.jdo.DatabaseNotFoundException;
import org.exolab.castor.jdo.PersistenceException;
import org.exolab.castor.persist.spi.LogInterceptor;
import org.exolab.castor.xml.Unmarshaller;
import org.jboss.logging.Logger;
import org.jboss.logging.Log4jLoggerPlugin;
import org.jboss.logging.util.*;
import org.jboss.mx.util.*;
import org.jboss.proxy.compiler.Proxy;
import org.jboss.proxy.compiler.Proxies;
import org.jboss.proxy.compiler.InvocationHandler;
import org.jboss.system.ServiceMBeanSupport;
/**
* @jmx.mbean name="CastorJDOImpl"
* description="Castor JDO MBean"
*
* @jboss.service servicefile="jboss"
* Castor JDO support
* Modified by Marco Mistroni (marco.mistroni0@lycos.com)
* in order to be used with JBoss3.2.1 onward.
* Some classes are in different packages
* in 3.2.1 onward versions.
*
* @author Oleg Nitz (on@ibis.odessa.ua)
* @version $Revision: 1.13 $
*/
public class CastorJDOImpl extends ServiceMBeanSupport
implements DataObjects, ObjectFactory, Referenceable, Serializable,
CastorJDOImplMBean, MBeanRegistration, LogInterceptor {
private String _jndiName;
private String _dbConf;
private JDO _jdo = new JDO();
private String _dataSourceName;
private static HashMap _instances = new HashMap();
private transient PrintWriter writer;
/**
* Do JDO classes should be loader by the global class loader
* (the same class loader as Castor classes)?
*/
private boolean _commonClassPath;
/*
* True if user prefers application-server database pooling.
* False (default) if user wants a new connection for each invocation of
* getDatabase().
*/
private boolean _dbPooling = false;
private boolean _autoStore;
public CastorJDOImpl() {
}
public ObjectName getObjectName(MBeanServer server, ObjectName name)
throws javax.management.MalformedObjectNameException {
return new ObjectName(OBJECT_NAME+",name="+_jndiName);
}
/**
* @jmx.managed-attribute
* access="read-only"
*/
public String getName() {
return "CastorJDO";
}
public void startService() throws Exception {
org.exolab.castor.jdo.conf.Database database;
Unmarshaller unm;
int pos;
Method m;
// Bind in JNDI
bind(new InitialContext(), "java:/" + _jndiName, this);
log.debug("DataObjects factory for " + _dataSourceName + " bound to " + _jndiName);
_jdo.setTransactionManager("java:/TransactionManager");
_jdo.setConfiguration(_dbConf);
unm = new Unmarshaller(org.exolab.castor.jdo.conf.Database.class);
database = (org.exolab.castor.jdo.conf.Database) unm.unmarshal(new InputSource(_dbConf));
_jdo.setDatabaseName(database.getName());
if (database.getJndi() != null) {
_dataSourceName = database.getJndi().getName();
}
// Older Castor versions older don't have these methods,
// we'll use reflection for backward compatibility
//_jdo.setDatabasePooling(_dbpooling);
try {
// 0.9.3
m = _jdo.getClass().getMethod("setDatabasePooling",
new Class[] {boolean.class});
m.invoke(_jdo, new Object[] {new Boolean(_dbPooling)});
} catch (Exception ex) {
log.debug("couldn't invoke setDatabasePooling()");
}
//_jdo.setAutoStore( _autoStore );
try {
m = _jdo.getClass().getMethod("setAutoStore",
new Class[] {boolean.class});
m.invoke(_jdo, new Object[] {new Boolean(_autoStore)});
} catch (Exception ex) {
log.debug("couldn't invoke setAutoStore()");
}
_instances.put(_jndiName, this);
}
public void stopService() {
// Unbind from JNDI
try {
new InitialContext().unbind(_jndiName);
} catch (NamingException e) {
}
}
// CastorJDOImplMBean implementation ---------------------------
public void setJndiName(String jndiName) {
_jndiName = jndiName;
}
/**
* @jmx.managed-attribute
* access="read-only"
* value="BudgetJDO@
*/
public String getJndiName() {
return _jndiName;
}
public void setConfiguration(String dbConf) {
_dbConf = dbConf;
}
/**
* @jmx.managed-attribute
* access="read-write"
* value="C:/Sw/Budget-Project/Framework/src/conf/database.xml"
*/
public String getConfiguration() {
return _dbConf;
}
public void setLockTimeout(int lockTimeout) {
_jdo.setLockTimeout(lockTimeout);
}
/**
* @jmx.managed-attribute
* access="read-write"
* value="10000"
*/
public int getLockTimeout() {
return _jdo.getLockTimeout();
}
public void setLoggingEnabled(boolean loggingEnabled) {
_jdo.setLogInterceptor(loggingEnabled ? this : null);
}
/**
* @jmx.managed-attribute
* access="read-write"
* value="true"
*/
public boolean getLoggingEnabled() {
return (_jdo.getLogInterceptor() != null);
}
public void setCommonClassPath(boolean commonClassPath) {
_commonClassPath = commonClassPath;
}
public boolean getCommonClassPath() {
return _commonClassPath;
}
/*
* True if user prefers to use application server database pools.
* False if user wants a new connection for each call to getDatabase().
*/
public void setDatabasePooling(boolean dbPooling) {
_dbPooling = dbPooling;
}
/**
* @jmx.managed-attribute
* access="read-write"
* value="true"
* Return true if the Database instance uses the application server pooling.
*/
public boolean isDatabasePooling() {
return _dbPooling;
}
public void setAutoStore( boolean autoStore ) {
_autoStore = autoStore;
}
/**
* @jmx.managed-attribute
* access="read-write"
* value="true"
*/
public boolean getAutoStore() {
return _autoStore;
}
// DataObjects implementation ----------------------------------
public Database getDatabase()
throws DatabaseNotFoundException, PersistenceException {
if (_commonClassPath) {
_jdo.setClassLoader(null);
} else {
_jdo.setClassLoader(Thread.currentThread().getContextClassLoader());
}
return _jdo.getDatabase();
}
public void setDescription(String description) {
_jdo.setDescription(description);
}
public String getDescription() {
return _jdo.getDescription();
}
// Referenceable implementation ----------------------------------
public Reference getReference() {
return new Reference(getClass().getName(), getClass().getName(), null);
}
// ObjectFactory implementation ----------------------------------
public Object getObjectInstance(Object obj,
Name name,
Context nameCtx,
Hashtable environment)
throws Exception {
return _instances.get(name.toString());
}
// Private -------------------------------------------------------
private void bind(Context ctx, String name, Object val)
throws NamingException {
// Bind val to name in ctx, and make sure that all intermediate contexts exist
Name n = ctx.getNameParser("").parse(name);
while (n.size() > 1)
{
String ctxName = n.get(0);
try
{
ctx = (Context)ctx.lookup(ctxName);
} catch (NameNotFoundException e)
{
ctx = ctx.createSubcontext(ctxName);
}
n = n.getSuffix(1);
}
ctx.bind(n.get(0), val);
}
// LogInterceptor implementation for Castor 0.8 ----------------------
public void loading(Class objClass, Object identity) {
log.debug( "Loading " + objClass.getName() + " (" + identity + ")" );
}
public void creating(Class objClass, Object identity) {
log.debug( "Creating " + objClass.getName() + " (" + identity + ")" );
}
public void removing(Class objClass, Object identity) {
log.debug( "Removing " + objClass.getName() + " (" + identity + ")" );
}
public void storing(Class objClass, Object identity) {
log.debug( "Storing " + objClass.getName() + " (" + identity + ")" );
}
// LogInterceptor implementation for Castor 0.9 ----------------------
public void loading(Object objClass, Object identity) {
log.debug( "Loading " + objClass + " (" + identity + ")" );
}
public void creating(Object objClass, Object identity) {
log.debug( "Creating " + objClass + " (" + identity + ")" );
}
public void removing(Object objClass, Object identity) {
log.debug( "Removing " + objClass + " (" + identity + ")" );
}
public void storing(Object objClass, Object identity) {
log.debug( "Storing " + objClass + " (" + identity + ")" );
}
// LogInterceptor implementation - the rest part --------------------
public void storeStatement(String statement) {
log.debug(statement);
}
public void queryStatement(String statement) {
log.debug(statement);
}
public void message(String message) {
log.debug(message);
}
public void exception(Exception except) {
log.error(except);
}
public PrintWriter getPrintWriter() {
if (writer == null) {
writer = new CategoryWriter(((Log4jLoggerPlugin)log.getLoggerPlugin ()).getCategory ());
}
return writer;
}
}
**********************************
and this is its jboss descriptor
************************************
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server>
C:/Sw/Budget-Project/Framework/src/conf/database.xml
BudgetJDO
10000
true
false
true
true
anyone can help me in figuring out the problem?
as a wild guess, i would go for the doctype ...but still it was working in
3.2.3..
thanx in advance and regards
marco