0

I am trying to connect with oracle database by using camel-jasypt generated encrypted password and username by keeping the generated values in .properties file.But, unfortunately i facing errors like username and password are incorrect. I am providing the camel context of my program.

    <bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent"/>
        <property name="location" value="classpath:DB.properties"/>
        <property name="propertiesParser" ref="jasypt"/>
    </bean>
       <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
        <property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:xe"/>
        <property name="username" value="${db.username}"/>
        <property name="password" value="${db.password}"/>
         </bean>
       </beans>

And i am placing all my username,password,oracle jdbc driver and url to connect to database in .properties file.I encrypted my username and password by using camel-jasypt jar in Apache camel software distribution and i have a doubt like, i can encrypt both username and password or only one either username or password but i tried with both encrypted.My properties file is

            db.driverClassName=oracle.jdbc.driver.OracleDriver
            db.url=jdbc:oracle:thin:@127.0.0.1:1521:xe
            db.username=ENC(/leiK3jiyKe1y87A8i743g==)
            db.password=ENC(3bwhRqBKu1Pye4Z+gBz9mm9q5Nxgah0n)

When i am trying to connect with oracle database with encrypted values in .properties file i am facing the errors the following errors

[ERROR] Error occurred while running main from: org.apache.camel.spring.Main
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'properties' defined in file [C:\Users\761285\workspace\camel-jasyp\target\classes\META-INF\spring\camelContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camel-1': Invocation of init method failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'dataSource' defined in file [C:\Users\rahul\workspace\camel-jasyp\target\classes\META-INF\spring\camelContext.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:529)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)
(ClassPathXmlApplicationContext.java:93)
neshkeev
  • 6,280
  • 3
  • 26
  • 47
Rahul
  • 149
  • 4
  • 11

1 Answers1

0

Based on the exception:

nested exception is 
  org.springframework.beans.factory.CannotLoadBeanClassException: 
    Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean 
    with name 'dataSource' 

Your application can't find this class you have to add apache-common.jar to your either pom or classpath or wherever you store your libraries.

neshkeev
  • 6,280
  • 3
  • 26
  • 47