SAML module and Log4J

0
Hi, I have the SAML module in my application and for some custom Java actions I added the Log4j library to userlib. It results in the error/stack trace below. I have two questions: What is your opinion on having the Log4J library in userlib; is this by all means a no-go (for production)? In case I have to keep the Log4J library, what would be the easiest to solve the error? On sources like Stackoverflow I see solutions like adjusting the Java code to set logging to null instead of velocity.log or use an external "property file".   org.apache.velocity.exception.VelocityException: Error initializing log: Failed to initialize an instance of org.apache.velocity.runtime.log.Log4JLogChute with the current runtime configuration. at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:875) at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:262) at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:646) at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:116) at saml20.implementation.common.HTTPUtils.getEngine(HTTPUtils.java:39) at saml20.implementation.SAMLRequestHandler.<init>(SAMLRequestHandler.java:70) at saml20.implementation.SAMLRequestHandler.getInstance(SAMLRequestHandler.java:56) at saml20.implementation.SSOServerConfiguration.start(SSOServerConfiguration.java:18) at saml20.actions.StartSSO.executeAction(StartSSO.java:31) at saml20.actions.StartSSO.executeAction(StartSSO.java:19) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49) at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:260) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:248) at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:188) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32) at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:194) at com.mendix.core.component.InternalCore.execute(InternalCore.java:386) at com.mendix.modules.microflowengine.actions.actioncall.JavaAction.execute(JavaAction.scala:52) at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:47) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:192) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:149) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49) at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:260) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:248) at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:188) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32) at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:194) at com.mendix.core.component.InternalCore.executeSync(InternalCore.java:468) at com.mendix.modules.microflowengine.actions.SubMicroflowAction.execute(SubMicroflowAction.scala:43) at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:47) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:192) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:149) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49) at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:260) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:248) at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:188) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32) at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:194) at com.mendix.core.component.InternalCore.executeSync(InternalCore.java:468) at com.mendix.modules.microflowengine.actions.SubMicroflowAction.execute(SubMicroflowAction.scala:43) at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:47) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:192) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:149) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49) at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:260) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:248) at com.mendix.core.actionmanagement.CustomActionMonitorImpl$$anonfun$run$1.apply(CustomMonitoredAction.scala:14) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2$$anon$1.execute(ActionDispatching.scala:145) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2.apply(ActionDispatching.scala:147) at scala.util.Try$.apply(Try.scala:191) at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(ActionDispatching.scala:141) at akka.actor.Actor$class.aroundReceive(Actor.scala:465) at com.mendix.core.session.Worker.aroundReceive(ActionDispatching.scala:137) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516) at akka.actor.ActorCell.invoke(ActorCell.scala:487) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238) at akka.dispatch.Mailbox.run(Mailbox.scala:220) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) Caused by: org.apache.velocity.exception.VelocityException: Failed to initialize an instance of org.apache.velocity.runtime.log.Log4JLogChute with the current runtime configuration. at org.apache.velocity.runtime.log.LogManager.createLogChute(LogManager.java:220) at org.apache.velocity.runtime.log.LogManager.updateLog(LogManager.java:269) at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:871) ... 62 more Caused by: java.lang.RuntimeException: Error configuring Log4JLogChute : at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.apache.velocity.util.ExceptionUtils.createWithCause(ExceptionUtils.java:67) at org.apache.velocity.util.ExceptionUtils.createRuntimeException(ExceptionUtils.java:45) at org.apache.velocity.runtime.log.Log4JLogChute.initAppender(Log4JLogChute.java:133) at org.apache.velocity.runtime.log.Log4JLogChute.init(Log4JLogChute.java:85) at org.apache.velocity.runtime.log.LogManager.createLogChute(LogManager.java:157) ... 64 more Caused by: java.io.FileNotFoundException: velocity.log (Permission denied) at java.io.FileOutputStream.open0(Native Method) at java.io.FileOutputStream.open(FileOutputStream.java:270) at java.io.FileOutputStream.<init>(FileOutputStream.java:213) at java.io.FileOutputStream.<init>(FileOutputStream.java:133) at org.apache.log4j.FileAppender.setFile(FileAppender.java:294) at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:207) at org.apache.log4j.FileAppender.<init>(FileAppender.java:110) at org.apache.log4j.RollingFileAppender.<init>(RollingFileAppender.java:79) at org.apache.velocity.runtime.log.Log4JLogChute.initAppender(Log4JLogChute.java:118) ... 66 more   Regards, Paul  
asked
1 answers
0

I've used Log4J in production on occassion, though admittedly always on-premise at a client.

As you've probably already spotted, it looks like the core problem is this:

Caused by: java.io.FileNotFoundException: velocity.log (Permission denied)

 When running from the modeller, I would get similar errors when I had 'emulate cloud security' set to 'true'. 

Both your initial solutions seem valid, but I'd also get in touch with Mendix and see if they are willing/able to adjust the standard cloud security settings. 

answered