[jboss-user] [Beginners Corner] - Re: java.lang.ClassCastException: org.jnp.interfaces.NamingC

tamscot do-not-reply at jboss.com
Mon Nov 26 19:20:04 EST 2007


When debugging in Eclipse...

when entering the sendMessage() method of the servlet...the 

  | QueueConnection qConnection = 
  | 			AsyncJujitsuFacadeUtil.getQueueConnection();
  | 
eventually stepping into...

  | java.lang.Object objRef = initialContext.lookup(CONNECTION_FACTORY_JNDI_NAME);
  | 
in the xdoclet generated class AsyncJujitsufacadeUtil.

When the following method is called...

  | cachedConnectionFactory = (javax.jms.QueueConnectionFactory) objRef;
  | 
we step into the class ClassLoader method below

  | // This method is invoked by the virtual machine to load a class.
  |     private synchronized Class loadClassInternal(String name)
  | 	throws ClassNotFoundException
  |     {
  | 	return loadClass(name);
  |     }
  | 

which I take is the
javax.jms.QueueConnectionFactory 
The next method stepped into is

  |     public Class<?> loadClass(String name) throws ClassNotFoundException {
  | 	return loadClass(name, false);
  |     }
  | 

The next method I think causes the exception...

  |     private void checkPackageAccess(Class cls, ProtectionDomain pd) {
  | 	final SecurityManager sm = System.getSecurityManager();
  | 	if (sm != null) {
  | 	    final String name = cls.getName();
  |             final int i = name.lastIndexOf('.');
  | 	    if (i != -1) {
  |                 AccessController.doPrivileged(new PrivilegedAction() {
  |                     public Object run() {
  | 		        sm.checkPackageAccess(name.substring(0, i));
  | 		        return null;
  |                     }
  |                 }, new AccessControlContext(new ProtectionDomain[] {pd}));
  | 	    }
  | 	}
  | 	domains.add(pd);
  |     }
  | 

When it gets to the comarison for sm != null, sm = null so goes to domain.add() then from there to the ClassCastException creation method.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4107902#4107902

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4107902



More information about the jboss-user mailing list