jeasyopc放在tomcat上不能获取配置信息,折腾了好久,是原代码中的一个问题,tomcat下找不到系统路径,所以导致找不到配置文件。</span>
你需要修改jeasyopc.jar下的javafish.clients.opc.property.PropertyLoader.java
/**
* Get properties for class (propsName)
*
* @param propsName class package
* @return properties Properties
*/
public static Properties loadProperties(final String propsName) {
Properties props = null;
InputStream in = null;
try {
ClassLoader cl = <span style="color:#ff6666;">ClassLoader.getSystemClassLoader();</span>
String name = propsName.replace('.', '/').concat(".properties");
in = cl.getResourceAsStream(name);
if (in != null) {
props = new Properties();
props.load(in);
}
}
catch (Exception e) {
props = null;
}
finally {
if (props == null) {
System.err.print("Property file " + propsName + " doesn't exist. System terminated.");
System.exit(0);
}
}
将源文件javafish.clients.opc.property.PropertyLoader.java的ClassLoader cl = ClassLoader.getSystemClassLoader();改成ClassLoader cl = Thread.currentThread().getContextClassLoader();即可。
然后重新编译成class覆盖掉原来的class文件,然后在tomcat的bin中添加 lib/JCustomOpc.dll 文件就可以运行起来了
如果是eclipse插件tomcat的形式开发,只需要将 lib/JCustomOpc.dll 文件拷贝到你使用的jdk/bin目录中就OK了。