camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Erker (JIRA)" <>
Subject [jira] [Created] (CAMEL-8500) ClassCastException when something other than PropertiesComponent is bound to "properties" JNDI name
Date Tue, 17 Mar 2015 11:09:38 GMT
Carsten Erker created CAMEL-8500:

             Summary: ClassCastException when something other than PropertiesComponent is
bound to "properties" JNDI name
                 Key: CAMEL-8500
             Project: Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 2.13.4
         Environment: Apache Camel 2.13.4 running on JBoss EAP4
            Reporter: Carsten Erker

When starting the DefaultCamelContext, Camel tries to get a PropertiesComponent object from
JNDI under the name "properties" (which is hard-coded in DefaultCamelContextlookupPropertiesComponent()
resp. CamelContextHelperlookupPropertiesComponent() in newer Camel versions).

During start we get the following Error:
org.apache.camel.NoSuchBeanException: Found bean: properties in JNDI Context: javax.naming.InitialContext@a37a18
of type: org.jnp.interfaces.NamingContext expected type was: class
	at org.apache.camel.impl.JndiRegistry.lookupByNameAndType(
	at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookupByNameAndType(
	at org.apache.camel.impl.DefaultCamelContext.lookupPropertiesComponent(
	at org.apache.camel.impl.DefaultCamelContext.doStartCamel(
	at org.apache.camel.impl.DefaultCamelContext.doStart(
	at org.apache.camel.impl.DefaultCamelContext.start(
	at de.bwb.ubi.vs.automat.mbean.CamelStarter.startService(
	at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(
Caused by: java.lang.ClassCastException
	at java.lang.Class.cast(
	at org.apache.camel.impl.JndiRegistry.lookupByNameAndType(
	... 145 more

Our application bind some properties to the name "properties/..." in the JNDI global namespace.

*Proposed Solution*
Camel can manage if it finds nothing under the JNDI name, the problem is just finding something
different than the expected PropertiesComponent instance. Instead of calling JndiRegistry.lookupByNameAndType(String,
Class) -- this is where the cast fails -- we should call JndiRegistry.lookupByName(String
name). If an instance other than a PropertiesComponent is returned here, we should go on as
if nothing was found in the JNDI lookup.

I can provide a pull request for this.

This message was sent by Atlassian JIRA

View raw message