Search code examples
javaspringmuleclassnotfoundexception

Java error: java.lang.ClassNotFoundException:


Let me preface this by saying I'm not a Java developer, but rather a Python developer who needs to leverage a small portion of Java code for a project. :-)

That being said, I'm receiving the following error:

Caused by: java.lang.ClassNotFoundException: CustomSecurePropertyPlaceholderModule

using the following code:

<?xml version="1.0" encoding="UTF-8"?>


<domain:mule-domain xmlns="http://www.mulesoft.org/schema/mule/core"
                    xmlns:domain="http://www.mulesoft.org/schema/mule/ee/domain"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xmlns:spring="http://www.springframework.org/schema/beans"
                    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
                    xmlns:mule-ss="http://www.mulesoft.org/schema/mule/spring-security"
                    xmlns:context="http://www.springframework.org/schema/context"
                    xmlns:tls="http://www.mulesoft.org/schema/mule/tls"
                    xmlns:ss="http://www.springframework.org/schema/security"
                    xmlns:http="http://www.mulesoft.org/schema/mule/http"
                    xmlns:secure-property-placeholder="http://www.mulesoft.org/schema/mule/secure-property-placeholder"
                    xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
                                        http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
                                        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
                                        http://www.mulesoft.org/schema/mule/ee/domain http://www.mulesoft.org/schema/mule/ee/domain/current/mule-domain-ee.xsd
                                        http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
                                        http://www.mulesoft.org/schema/mule/tls http://www.mulesoft.org/schema/mule/tls/current/mule-tls.xsd
                                        http://www.mulesoft.org/schema/mule/secure-property-placeholder http://www.mulesoft.org/schema/mule/secure-property-placeholder/current/mule-secure-property-placeholder.xsd
                                        http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-3.0.xsd">


    <spring:beans>
        <spring:bean id="secure-property-placeholder" class="CustomSecurePropertyPlaceholderModule">
            <spring:property name="encryptionAlgorithm" value="AES" />
            <spring:property name="encryptionMode" value="CBC" />
            <spring:property name="keyFilePath" value="keyfile.properties" />
            <spring:property name="locations" value="secure.properties"/>
            <spring:property name="ignoreResourceNotFound" value="true" />
            <spring:property name="ignoreUnresolvablePlaceholders" value="true" />
        </spring:bean>
    </spring:beans>


</domain:mule-domain>

I've ensured src/main/java is on the build path within the run config (the file CustomSecurePropertyPlaceholderModule resides there). I also see that shared_resources/target/classes is set as the output folder in the run config as well. Any ideas why I'm still receiving this error?


Solution

  • In Java, classes are usually in packages.

    Like, com.yourself.CustomSecurePropertyPlaceholderModule

    Try putting your class (I hope you have it) into src/main/java/com/yourself, prepend with package com.yourself; and use

    <spring:bean id="secure-property-placeholder" class="com.yourself.CustomSecurePropertyPlaceholderModule">