Log4j email error “Cannot find java.home ??”

一世执手 提交于 2019-12-20 01:37:59

问题


I'm using log4j under J2SE. I've configured it to use a mailer for a certain type of log event.. When the logger.error triggers I get the following exception:

java.lang.Error: Can't find java.home ??
at sun.net.NetProperties.loadDefaultProperties(NetProperties.java:45)
...
at org.apache.log4j.net.SMTPAppender.sendBuffer(SMTPAppender.java:416)

Anyone run into this before? I have the required mail.jar library included as well.

Any help is appreciated. Thanks, Chris


回答1:


I looked at the source code of NetProperties and the error basically means what it says. The System property called "java.home" is unset. According to the javadoc for System.getProperties(), that property is set automatically by the JVM to the java installation directory.

The only explanation I can think of is that something in your application or some third-party library you are using has explicitly unset that property. That is obviously a bad thing to do ...



来源:https://stackoverflow.com/questions/5359774/log4j-email-error-cannot-find-java-home

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!