Java 如何在 Weblogic Admin Console 中设置属性文件的类路径?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22501220/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set the classpath of properties file in Weblogic Admin Console?
提问by Nigel Thomas
I am using Apache Tomcat Server.
我正在使用 Apache Tomcat 服务器。
While the application is loading it reads from a properties file and the file will be usuall placed in the lib folder of Tomcat server.
当应用程序加载时,它从一个属性文件中读取,该文件通常放在 Tomcat 服务器的 lib 文件夹中。
Since I am using Windows 7 and I need to test the application on Weblogic Server 10.3.5
由于我使用的是 Windows 7,我需要在Weblogic Server 10.3.5上测试应用程序
While running the application it cannot deploy the application to the server because the server cannot find the properties file.
在运行应用程序时,它无法将应用程序部署到服务器,因为服务器找不到属性文件。
I tried giving the path of the properties file in
我尝试给出属性文件的路径
Servers > AdminServer > Server Start > Class Path
服务器 > AdminServer > 服务器开始 > 类路径
and tried to put the propertues file in the Weblogic Server HOME
并尝试将属性文件放在 Weblogic Server HOME 中
C:\ORA_WL\MIDDLEWARE\user_projects\domains\base_domain\lib
C:\ORA_WL\MIDDLEWARE\user_projects\domains\base_domain\lib
But still it is giving the error
但它仍然给出错误
java.lang.Exception: java.lang.NoClassDefFoundError: Could not initialize class com.bonsai.webutility.properties.SystemProperties
java.lang.Exception: java.lang.NoClassDefFoundError: 无法初始化类 com.bonsai.webutility.properties.SystemProperties
采纳答案by Display Name is missing
Where does your class attempt to find the properties file? Using a relative path?
您的班级在哪里尝试找到属性文件?使用相对路径?
The Server Start
tab only applies to servers started with the node manager, not with the startWebLogic
script. So if your application is running on the admin server, you probably need to edit the startWeblogic
script itself to put the properties file on your classpath.
该Server Start
选项卡仅适用于使用节点管理器启动的服务器,而不适用于使用startWebLogic
脚本启动的服务器。因此,如果您的应用程序在管理服务器上运行,您可能需要编辑startWeblogic
脚本本身以将属性文件放在您的类路径中。
A better option is to package the properties file directly in your .war/.ear. Reference the solution here: Java: Accessing properties file inside a war
更好的选择是将属性文件直接打包在 .war/.ear 中。参考这里的解决方案:Java: Accessing properties file inside a war