Getting error "After parsing a valid expression, there is still more data in the expression: 'lcurly({)'" - spring

I am using Spring-Integration for my project. I am experimenting with reading of the property/constant values from xml file (instead of .properties file).My xml file in which the properties/constants are placed is as below:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<persistence>
<dataSourceName>CS/PowerSTEPP_CSSTEPPQA</dataSourceName>
</persistence>
<customerservice>
<headerNames>
<jobName>jobDesignerJobName</jobName>
</headerNames>
<headerNames>
<originalPayload>originalPayload</originalPayload>
</headerNames>
<headerNames>
<originalPayloadDuplicate>originalPayload</originalPayloadDuplicate>
</headerNames>
<headerNames>
<legacySystem>legacySystem</legacySystem>
</headerNames>
<headerNames>
<businessArea>businessArea</businessArea>
</headerNames>
<routing>
<jobChannel>headers.jobDesignerJobName+'-InputChannel'</jobChannel>
</routing>
<routing>
<jobErrorChannel>headers.jobDesignerJobName+'-XsltTransformInputChannel'</jobErrorChannel>
</routing>
<legacySystem>
<powerstepp>PowerSTEPP</powerstepp>
</legacySystem>
<PQProviderSearch>
<storedProcedureName>PQPRVSCH</storedProcedureName>
</PQProviderSearch>
<PQProviderSearch>
<ROWREQ>00001</ROWREQ>
</PQProviderSearch>
<PQProviderSearch>
<DBGFLG>Y</DBGFLG>
</PQProviderSearch>
<PQProviderSearch>
<SECDAT></SECDAT>
</PQProviderSearch>
<stylesheet>
<PQProviderSearch>classpath:/CustomerServiceRD/spring-integration/stylesheets/PQProviderSearch.xsl</PQProviderSearch>
</stylesheet>
<stylesheet>
<PQProviderSearchCount>classpath:/CustomerServiceRD/spring-integration/stylesheets/PQProviderSearchCount.xsl</PQProviderSearchCount>
</stylesheet>
<resultSet>
<legacySystem>system</legacySystem>
</resultSet>
<resultSet>
<rootNode>results</rootNode>
</resultSet>
<responseXml>
<soapTemplate>CustomerServiceRD/JobDesigner-responseTemplate.xml</soapTemplate>
</responseXml>
<responseXml>
<xmlBodyTag>//PQ</xmlBodyTag>
</responseXml>
<http>
<header>
<ressponseXml>
<contentType>
<value>CustomerServiceRD/JobDesigner-responseTemplate.xml</value>
</contentType>
</ressponseXml>
</header>
</http>
<http>
<header>
<contentType>
<value>CustomerServiceRD/JobDesigner-responseTemplate.xml</value>
</contentType>
</header>
</http>
<error>
<Fault>Fault</Fault>
</error>
<error>
<errorCode>1111</errorCode>
</error>
<headerNames>
<hostAddress>hostAddress</hostAddress>
</headerNames>
<headerNames>
<hostPort>hostPort</hostPort>
</headerNames>
<error>
<Fault>faultcode</Fault>
</error>
<error>
<faultstring>faultstring</faultstring>
</error>
<error>
<faultactor>faultactor</faultactor>
</error>
<error>
<detail>detail</detail>
</error>
<label>
<externalSystem>ExternalSystem</externalSystem>
</label>
</customerservice>
</config>
Now, I am trying to read the above values in spring integration configuration files as below:
<beans
<import resource="spring-integration/Jobs/*.xml"/>
<!-- map of namespace prefix to URI -->
<util:map id="xmlMessageNamespace">
<entry key="SOAP" value="http://schemas.xmlsoap.org/soap/envelope/" />
</util:map>
<int:channel id="jobDesignerInputChannel" />
<int:channel id="cs-exceptionHandlingChannel" />
<bean id="msgHandler" class="com.dsths.cs.awd.jobs.PQMessageHandler" />
<!-- TODO: Following lines are commented out as part of POC.-->
<!--<bean id="xmlAggregator" class="com.dsths.cs.awd.jobs.XmlAggregator" />
<bean id="httpOutboundGatewayHandler" class="com.dsths.cs.awd.jobs.HttpOutboundGatewayHandler" />
<!--<bean id="xmlFilter" class="com.dsths.cs.awd.jobs.XmlFilter" />-->
<int:chain input-channel="jobDesignerInputChannel" >
<int-xml:xpath-header-enricher default-overwrite="true" should-skip-nulls="true" >
<int-xml:header name="${customerservice.headerNames.legacySystem}" xpath-expression="//LegacySystem" evaluation-type="STRING_RESULT" overwrite="true" />
</int-xml:xpath-header-enricher>
<!-- Some of the AWD jobs contain Business Area info under <code> tag, we should not keep that business area info in the
header since it is not required.This will help us in identifying AWD and Non-AWD jobs-->
<int:header-enricher>
<int:header name="${customerservice.headerNames.businessArea}" expression="#xpath(payload, '//businessArea/Code', 'boolean') ? null : #xpath(payload, '//businessArea')"/>
</int:header-enricher>
<int:router expression="${customerservice.routing.jobChannel}"/>
</int:chain>
<int:chain input-channel="cs-exceptionHandlingChannel">
<!-- Service Activator to handle the errors -->
<int:service-activator ref="msgHandler" method="handleError" />
<!-- Router to routing the error messages to appropriate job channel for xsl transormation -->
<int:router expression="${customerservice.routing.jobErrorChannel}"/>
</int:chain>
</beans>
But, unfortunately I am getting the following exception when try to read the properties from the xml file:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.handler.MessageHandlerChain#3': Cannot create inner bean 'org.springframework.integration.handler.MessageHandlerChain#3$child#2.handler' of type [org.springframework.integration.config.RouterFactoryBean] while setting bean property 'handlers' with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.handler.MessageHandlerChain#3$child#2.handler': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'expressionString' threw exception; nested exception is org.springframework.expression.spel.SpelParseException: EL1041E:(pos 1): After parsing a valid expression, there is still more data in the expression: 'lcurly({)'
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:153)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124)
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148)
... 24 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.handler.MessageHandlerChain#3$child#2.handler': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'expressionString' threw exception; nested exception is org.springframework.expression.spel.SpelParseException: EL1041E:(pos 1): After parsing a valid expression, there is still more data in the expression: 'lcurly({)'
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1396)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270)
... 42 more
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'expressionString' threw exception; nested exception is org.springframework.expression.spel.SpelParseException: EL1041E:(pos 1): After parsing a valid expression, there is still more data in the expression: 'lcurly({)'
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
... 46 more
Anybody have any idea where I am doing wrong?
Please let me know if my question is not clear.

According to the StackTrace your issue is here:
<int:router expression="${customerservice.routing.jobChannel}"/>
Before to use such a difficult configuration you should be sure that your customerservice really returns all desired options.
Would be great, if you had shown how does that object look from Java perspective, rather than XML background

Related

BeanCreationException:Error creating bean

mvc-dispatcher-servlet.xml
<bean class="com.springframework.BlogController">
<property name="formView" value="Welcome" />
<property name="successView" value="Home" />
<!-- Mapping validator -->
<property name="validator">
<bean class="com.springframework.BloggerValidator" />
</property>
Error:
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping#0' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.springframework.BlogController] for bean with name 'com.springframework.BlogController#0' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]; nested exception is java.lang.ClassNotFoundException: com.springframework.BlogController
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.springframework.BlogController] for bean with name 'com.springframework.BlogController#0' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]; nested exception is java.lang.ClassNotFoundException: com.springframework.BlogController
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
Cannot find class [com.springframework.BlogController] for bean with name 'com.springframework.BlogController'
No class called com.springframework.BlogController on your webapp's classpath.
Check if the qualified classname is correct in /WEB-INF/"*".xml
Or, check if /WEB-INF/classes directory in missing.

'circle' defined in class path resource [Spring.xml]: Initialization of bean failed; nested exception is java.lang.IllegalAccessError

Below is the XMl file.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd ">
<!-- bean definition & AOP specific configuration -->
<aop:aspectj-autoproxy/>
<bean name = "circle" class = "com.SpringAOP.Model.Circle">
<property name = "name" value = "circle name"/>
</bean>
<bean name = "triangle" class = "com.SpringAOP.Model.Triangle">
<property name = "name" value = "triangle name"/>
</bean>
<bean name = "shapeservice" class ="com.SpringAOP.Service.ShapeService" autowire = "byName"/>
<bean name = "loggingaspect" class = "com.SpringAOP.Aspect.LoggingAspect"/>
</beans>
Im getting the below execption while running the application and the above xml was able to create the bean without the AOP tag. please let me know is it something related to the jars.
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'circle' defined in class path resource [Spring.xml]: Initialization of bean failed; nested exception is java.lang.IllegalAccessError
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
at com.SpringAOP.AOPMain.main(AOPMain.java:10)
Even i tried the same code and was getting the same error.
I resolved it by using the correct aopalliance-1.0. jar.
The jar mentioned in the link of the above code was throwing an error. and hence i dowloaded it individually.
Also I was using the cglib version 3.1 so i changed it to 2.2.2.
It worked.
Sonal

Mule - Store datasource on jndi

I am trying to follow the instructions in link1
and link2 to store datasources in jndi so that every mule app can access it without re-defining it.
I've been helped by #David Dossot, and following #Spina suggestions I made this bean:
import java.util.Map;
import java.util.Map.Entry;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.jndi.JndiTemplate;
public class JndiExporter implements InitializingBean {
private final JndiTemplate template = new JndiTemplate();
private Map<String, Object> jndiMapping = null;
#Override
public void afterPropertiesSet() throws Exception {
for(Entry<String, Object> addToJndi: jndiMapping.entrySet()){
template.bind(addToJndi.getKey(), addToJndi.getValue());
}
}
public void setJndiMapping(Map<String, Object> jndiMapping) {
this.jndiMapping = jndiMapping;
}
}
and then a simple mule application:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:context="http://www.springframework.org/schema/context" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<jdbc-ee:oracle-data-source name="Oracle_Data_Source" user="user" password="pass" url="jdbc:oracle:thin:#xxxxxx" doc:name="Oracle Data Source" transactionIsolation="UNSPECIFIED"/>
<jdbc-ee:connector name="jdbcConnectorTest" dataSource-ref="Oracle_Data_Source" validateConnections="true" queryTimeout="-1" doc:name="Database" pollingFrequency="0">
</jdbc-ee:connector>
<spring:beans>
<spring:bean id="jndiExportera" class="JndiExporter" name="jndiExporterBean">
<spring:property name="jndiMapping">
<spring:map>
<spring:entry key="jdbcConnectorTest" value="jdbcConnectorTest" />
</spring:map>
</spring:property>
</spring:bean>
</spring:beans>
<flow name="jndiConnectionFlow1" doc:name="jndiConnectionFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
<logger level="INFO" doc:name="Logger"/>
</flow>
</mule>
Unfortunately it does not work, it gives the following error on startup:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.bind(Unknown Source)
at org.springframework.jndi.JndiTemplate$2.doInContext(JndiTemplate.java:198)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
at org.springframework.jndi.JndiTemplate.bind(JndiTemplate.java:196)
at JndiExporter.afterPropertiesSet(JndiExporter.java:18)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.mule.config.spring.SpringRegistry.doInitialise(SpringRegistry.java:89)
at org.mule.registry.AbstractRegistry.initialise(AbstractRegistry.java:109)
at org.mule.config.spring.SpringXmlConfigurationBuilder.createSpringRegistry(SpringXmlConfigurationBuilder.java:119)
at org.mule.config.spring.SpringXmlConfigurationBuilder.doConfigure(SpringXmlConfigurationBuilder.java:73)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:46)
at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
at org.mule.config.builders.AutoConfigurationBuilder.autoConfigure(AutoConfigurationBuilder.java:101)
at org.mule.config.builders.AutoConfigurationBuilder.doConfigure(AutoConfigurationBuilder.java:57)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:46)
at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:84)
at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:207)
at org.mule.module.launcher.application.ApplicationWrapper.init(ApplicationWrapper.java:64)
at org.mule.module.launcher.DefaultMuleDeployer.deploy(DefaultMuleDeployer.java:47)
at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:127)
INFO 2013-09-27 11:53:22,774 [main] org.mule.module.launcher.application.DefaultMuleApplication: App 'jndiconnection' never started, nothing to dispose of
Exception in thread "main" org.mule.module.launcher.DeploymentInitException: NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:219)
at org.mule.module.launcher.application.ApplicationWrapper.init(ApplicationWrapper.java:64)
at org.mule.module.launcher.DefaultMuleDeployer.deploy(DefaultMuleDeployer.java:47)
at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:127)
Caused by: org.mule.api.config.ConfigurationException: Error creating bean with name 'jndiExportera' defined in URL [file:/C:/Users/enrico.curiotto/MuleStudio/workspace/.mule/apps/jndiconnection/jndiConnection.xml]: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial (org.mule.api.lifecycle.InitialisationException) (org.mule.api.config.ConfigurationException)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:52)
at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:84)
at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:207)
... 3 more
Caused by: org.mule.api.config.ConfigurationException: Error creating bean with name 'jndiExportera' defined in URL [file:/C:/Users/enrico.curiotto/MuleStudio/workspace/.mule/apps/jndiconnection/jndiConnection.xml]: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial (org.mule.api.lifecycle.InitialisationException)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:52)
at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
at org.mule.config.builders.AutoConfigurationBuilder.autoConfigure(AutoConfigurationBuilder.java:101)
at org.mule.config.builders.AutoConfigurationBuilder.doConfigure(AutoConfigurationBuilder.java:57)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:46)
... 6 more
Caused by: org.mule.api.lifecycle.InitialisationException: Error creating bean with name 'jndiExportera' defined in URL [file:/C:/Users/enrico.curiotto/MuleStudio/workspace/.mule/apps/jndiconnection/jndiConnection.xml]: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at org.mule.registry.AbstractRegistry.initialise(AbstractRegistry.java:117)
at org.mule.config.spring.SpringXmlConfigurationBuilder.createSpringRegistry(SpringXmlConfigurationBuilder.java:119)
at org.mule.config.spring.SpringXmlConfigurationBuilder.doConfigure(SpringXmlConfigurationBuilder.java:73)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:46)
... 10 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jndiExportera' defined in URL [file:/C:/Users/enrico.curiotto/MuleStudio/workspace/.mule/apps/jndiconnection/jndiConnection.xml]: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.mule.config.spring.SpringRegistry.doInitialise(SpringRegistry.java:89)
at org.mule.registry.AbstractRegistry.initialise(AbstractRegistry.java:109)
... 13 more
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.bind(Unknown Source)
at org.springframework.jndi.JndiTemplate$2.doInContext(JndiTemplate.java:198)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
at org.springframework.jndi.JndiTemplate.bind(JndiTemplate.java:196)
at JndiExporter.afterPropertiesSet(JndiExporter.java:18)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
... 24 more
Any ideas?
Thank you!
°°°°°°°°°°°°°°°°°°°°
UPDATE
°°°°°°°°°°°°°°°°°°°°
After #Genjosanzo answer my spring beans became:
<spring:beans>
<spring:bean id="systemJndiPrereqs"
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<spring:property name="targetObject" value="#{#systemProperties}" />
<spring:property name="targetMethod" value="putAll" />
<spring:property name="arguments">
<!-- The new Properties -->
<util:properties>
<spring:prop key="#{ T(javax.naming.Context).URL_PKG_PREFIXES }">org.apache.naming</spring:prop>
</util:properties>
</spring:property>
</spring:bean>
<spring:bean id="jndiExportera" name="jndiExporterBean"
class="JndiExporter">
<spring:property name="jndiMapping">
<spring:map>
<spring:entry key="jdbcConnectorTest" value="jdbcConnectorTest" />
</spring:map>
</spring:property>
</spring:bean>
</spring:beans>
but unfortunately the error I get is the same as before.
The error you are getting means that you have to set a system property to enable jndiContext.
If you want to do it within your spring configuration you should add a bean like the following
<bean id="systemJndiPrereqs" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" value="#{#systemProperties}" />
<property name="targetMethod" value="putAll" />
<property name="arguments">
<!-- The new Properties -->
<util:properties>
<prop key="#{ T(javax.naming.Context).URL_PKG_PREFIXES }">org.apache.naming</prop>
</util:properties>
</property>
</bean>

Error Caused by: org.hibernate.HibernateException: Could not instantiate connection provider [org.connection.C3P0ConnectionProvider]

I have an error in Hibernate 4.1.2.FINAL, JBoss 7.1.1,and Spring 3.1.0.RELEASE,like this:
12:10:50,853 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-2)
Context initialization failed: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'departamentoDao' defined in URL [vfs:/opt/jboss-as-7.1.1.Final/standalone/deployments/projvehimerc.war/WEB-INF/classes/META-INF/spring/spring-hibernate.xml]:Cannot resolve reference to bean 'hibernateTemplate' while setting bean property 'hibernateTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'hibernateTemplate' defined in URL [vfs:/opt/jboss-as-7.1.1.Final/standalone/deployments/projvehimerc.war/WEB-INF/classes/META-INF/spring/spring-hibernate.xml]:
Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory' defined in URL [vfs:/opt/jboss-as-7.1.1.Final/standalone/deployments/projvehimerc.war/WEB-INF/classes/META-INF/spring/spring-hibernate.xml]:
Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
Caused by:
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'hibernateTemplate' defined in URL
[vfs:/opt/jboss-as-7.1.1.Final/standalone/deployments/projvehimerc.war/WEB-INF/classes/META-INF/spring/spring-hibernate.xml]:
Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory' defined in URL
[vfs:/opt/jboss-as-7.1.1.Final/standalone/deployments/projvehimerc.war/WEB-INF/classes/META-INF/spring/spring-hibernate.xml]:
Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
and :
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory' defined in URL [vfs:/opt/jboss-as-7.1.1.Final/standalone/deployments/projvehimerc.war/WEB-INF/classes/META-INF/spring/spring-hibernate.xml]: Invocation of init method failed; nestwared exception is org.hibernate.service.spi.ServiceException:
Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]
>>Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service
>>Caused by: org.hibernate.HibernateException: Could not instantiate connection provider [org.connection.C3P0ConnectionProvider]
and my spring-hibernate configuration:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<!-- Hibernate SessionFactory -->
<bean class="org.springframework.orm.hibernate4.HibernateExceptionTranslator"/>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
p:dataSource-ref="vehicDataSource">
<!-- p:lobHandler-ref="defaultLobHandler"-->
<property name="annotatedClasses">
<list>
<!-- Procedimientos -->
<value>com.reglamb.projvehimerc.domain.HabilitacionVehicular_Inscripcion</value>
<!-- Main Properties -->
<value>com.reglamb.projvehimerc.domain.Transportista</value>
<value>com.reglamb.projvehimerc.domain.Ubigeo</value>
<value>com.reglamb.projvehimerc.domain.TransportistaNatural</value>
<value>com.reglamb.projvehimerc.domain.TransportistaJuridico</value>
<value>com.reglamb.projvehimerc.domain.Conductor</value>
<!-- Transportista's Ubigeo -->
<value>com.reglamb.projvehimerc.domain.ubigeo.Departamento</value>
<value>com.reglamb.projvehimerc.domain.ubigeo.Distrito</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=${hibernate.dialect}
hibernate.default_schema=${hibernate.default_schema}
hibernate.jdbc.batch_size=${hibernate.jdbc.batch_size}
hibernate.c3p0.max_size=${hibernate.c3p0.max_size}
hibernate.c3p0.min_size=${hibernate.c3p0.min_size}
hibernate.c3p0.timeout=${hibernate.c3p0.timeout}
hibernate.c3p0.max_statements=${hibernate.c3p0.max_statements}
hibernate.c3p0.idle_test_period=${hibernate.c3p0.idle_test_period}
hibernate.c3p0.acquire_increment=${hibernate.c3p0.acquire_increment}
<!--hibernate.c3p0.validate=${hibernate.c3p0.validate}-->
<!--hibernate.cache.provider_class=${hibernate.cache.provider_class}-->
hibernate.connection.provider_class=${hibernate.connection.provider_class}
hibernate.show_sql=${hibernate.show_sql}
hibernate.hbm2ddl.auto=${hibernate.hbm2ddl.auto}
hibernate.id.new_generator_mappings=${hibernate.id.new_generator_mappings}
<!-- Auto Generated Schemas and tables not good for production
hibernate.hbm2ddl.auto=update-->
<!--hibernate.cache.use_second_level_cache=true-->
<!--hibernate.cache.use_query_cache=true-->
</value>
</property>
</bean>
<!-- Transaction Config -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager"
p:sessionFactory-ref="sessionFactory"/>
<!-- Hibernate Template -->
<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate"
p:sessionFactory-ref ="sessionFactory"/>
<!-- Injectores Procedimiento -->
<bean id="inscriptransportistaDao"
class="com.reglamb.projvehimerc.dao.hibernate.HabilitacionVehicular_InscripcionDaoHibernate" >
<property name="hibernateTemplate" ref ="hibernateTemplate" />
</bean>
<!-- Injectores Ubigeo -->
<bean id="ubigeoDao"
class="com.reglamb.projvehimerc.dao.hibernate.UbigeoDaoHibernate" >
<property name="hibernateTemplate" ref ="hibernateTemplate" />
</bean>
<bean id="departamentoDao"
class="com.reglamb.projvehimerc.dao.hibernate.ubigeo.DepartamentoDaoHibernate" >
<property name="hibernateTemplate" ref ="hibernateTemplate" />
</bean>
<bean id="distritoDao"
class="com.reglamb.projvehimerc.dao.hibernate.ubigeo.DistritoDaoHibernate" >
<property name="hibernateTemplate" ref ="hibernateTemplate" />
</bean><
<bean name="inscripcionHabilitacionVehicFacade" class="com.reglamb.projvehimerc.service.HabilitacionVehicular_InscripcionFacadeImpl" />
<tx:annotation-driven transaction-manager="transactionManager"/>
</beans>
What's the error ? thnks.
It looks like you set hibernate.connection.provider_class to org.connection.C3P0ConnectionProvider.
It should be org.hibernate.connection.C3P0ConnectionProvider instead.

Spring expression language not working with spring aop

<bean id="eddie" class="com.springinaction.Instrumentalist">
<property name="instrument" value="#{violin}"></property>
<property name="song" value="#{kenny.song}"></property>
</bean>
<bean id="violin" class="com.springinaction.Violin">
</bean>
<bean id="kenny" class="com.springinaction.Instrumentalist">
<property name="song" value="Kenny is a star,kenny is a star"></property>
<property name="instrument" ref="saxopone"></property>
</bean>
<aop:config>
<aop:aspect ref="audience">
<aop:before pointcut="execution(* com.springinaction.Performer.perform(..))" method="takeSeats()"/>
<aop:after-throwing method="demandRefund" pointcut="execution(* com.springinaction.Performer.perform(..))"/>
</aop:aspect>
</aop:config>
In the above code,I am injecting song , instrument property of eddie bean using spring expression language. But, song property not injected properly..and i am getting the below error:
Exception in thread "main"
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'eddie'
defined in class path resource
[spring-config.xml]: Initialization of
bean failed; nested exception is
org.springframework.beans.factory.BeanExpressionException:
Expression parsing failed; nested
exception is
org.springframework.expression.spel.SpelEvaluationException:
EL1008E:(pos 6): Field or property
'song' cannot be found on object of
type '$Proxy4' at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
at
org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at
org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
at
com.springinaction.Main.main(Main.java:10)
Instrument property is injected properly where as song property is not injected and this is happening because of aop only..
when i comment out <aop:config> it is working fine..
Anything wrong?
Did you try
<aop:config proxy-target-class="true">
...
</aop:config>
This way you get a dynamic subclass and the property should be available in the proxy created via Spring AOP.
The default behaviour of Spring AOP is to create a Java proxy for the interfaces, so the properties of any classes won't be accessible through the proxy.

Resources