0

I am trying to do some development and I am using log4j to log some events into our database. I made a subclass of the JDBC appender so we can properly interface with our database.

The log4j.properties file is located at src/main/resources.

However, when I run off of MuleStudio, I get this output:

log4j:ERROR Could not instantiate class [com.mycompany.mule.log.appender.MySuperAppender].
java.lang.ClassNotFoundException: com.mycompany.mule.log.appender.MySuperAppender
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.apache.log4j.helpers.Loader.loadClass(Loader.java:198)
    at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:326)
    at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
    at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:752)
    at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:735)
    at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:639)
    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:504)
    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:547)
    at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:483)
    at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
    at org.apache.log4j.Logger.getLogger(Logger.java:117)
    at org.mule.module.logging.LoggerReferenceHandler.<init>(LoggerReferenceHandler.java:28)
    at org.mule.module.logging.MuleLogFactory.<init>(MuleLogFactory.java:41)
    at org.apache.commons.logging.LogFactory.<clinit>(LogFactory.java:32)
    at org.mule.module.launcher.DefaultMuleDeployer.<init>(DefaultMuleDeployer.java:33)
    at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:87)
log4j:ERROR Could not instantiate appender named "DBappender".

I also have other appenders specified in the log4j.properties and those load fine.

I did some research (about three/four hours) and it seems to be an issue with the classloader. I tried overriding the classloader as per the documentation but without success. I edited the mule-deploy.properties file directly (I couldn't find the "proper" way to do it from MuleStudio)

loader.override=com.mycompany.mule.log.appender.MySuperAppender

I am a bit baffled as to why it would not work in MuleStudio, but when I deploy the application in a Mule-standalone instance, it works fine. Any thoughts?

Randy
  • 55
  • 8
  • Is your custom appender JAR on the project build path? – David Dossot Mar 30 '14 at 23:32
  • Hi David, My custom appender is not JAR'd and is built as part of the Mule project. I tried putting the appender in a JAR and then adding it to the project's build path (via right-click, configure build path, Libraries tab, add external JAR) but that didn't work either. – Randy Apr 01 '14 at 14:35
  • Maybe try moving the JAR to the Bootstrap entries of the Run Configuration? – David Dossot Apr 01 '14 at 19:35
  • I tried adding the JAR to the Bootstrap entries by right-click on project in Package explorer, Run As, Run configurations, Classpath tab, and added external JAR to the Bootstrap Entries. It gives the same error. – Randy Apr 02 '14 at 13:38
  • I'm sorry Randy, I don't know what else to propose. Try the MuleSoft forums? – David Dossot Apr 02 '14 at 16:40
  • Thanks for stopping by and giving a few suggestions! I'll report back when I figure it out. – Randy Apr 02 '14 at 20:44
  • Did you ever figure this out? I'm having very similar problems and am stuck on where to go next. – Tad Jun 09 '14 at 14:24
  • Hi Tad, I haven't found out the answer yet as I had to move onto working other features. When I go back to bug fixing then I will look into this again. – Randy Jun 11 '14 at 06:24

0 Answers0