近期将一java网站布署到新浪云上,系统采用的MiinCMP,网站布布署上去后,发现网站无法正常加载Gres UI库,网站即时乱成一堆。
把gresc源码找来看下,发现是在jetty服务器下的路径获取方式导致gresc无法正常加载配置文件所致。
MiinCMP GresC UI错误信息:
加载 gresc配置文件:/data1/jetty_work/588/juusoft/jetty-0.0.0.0-11679-juusoft.war- _1_juusoft-any-/webappWEB-INF/classes/gres-config.properties更新gresc配置失败: /data1/jetty_work/588/juusoft/jetty-0.0.0.0-11679-juusoft.war-_1_juusoft-any-/webappWEB-INF/classes/gres-config.properties (No such file or directory)
错误原因:路径问题
gresc是一个java web程序调用UI共享库gres的客户端软件,该错误导致MiinCMP在新浪等平台上无法加载UI组件得模板。
详细原因:可能是jetty与Tomcat对realpath不同处理所致。
Tomcat下返回:/tomcat/webapps/ROOT/
在jetty下,即变成/tomcat/webapps/ROOT
结果导致GresC无法正确获取UI。
目前该BUG已修改,MiinCMP等程序可正常布署到新浪SAE云平台。
Juuluu的java开源cms,如kgcms,MiinCMP等皆受该BUG影响,新版本已修改该BUG,可同时兼容jetyy,tomcat等不同云平台的应用服务器。
加载 gresc配置文件:/data1/jetty_work/588/juusoft/jetty-0.0.0.0-11679-juusoft.war- _1_juusoft-any-/webappWEB-INF/classes/gres-config.properties更新gresc配置失败: /data1/jetty_work/588/juusoft/jetty-0.0.0.0-11679-juusoft.war-_1_juusoft-any-/webappWEB-INF/classes/gres-config.properties (No such file or directory)
错误原因:路径问题
gresc是一个java web程序调用UI共享库gres的客户端软件,该错误导致MiinCMP在新浪等平台上无法加载UI组件得模板。
详细原因:可能是jetty与Tomcat对realpath不同处理所致。
Tomcat下返回:/tomcat/webapps/ROOT/
在jetty下,即变成/tomcat/webapps/ROOT
结果导致GresC无法正确获取UI。
目前该BUG已修改,MiinCMP等程序可正常布署到新浪SAE云平台。
Juuluu的java开源cms,如kgcms,MiinCMP等皆受该BUG影响,新版本已修改该BUG,可同时兼容jetyy,tomcat等不同云平台的应用服务器。
更正后代码:
/*\
* 通过web目录方式加载gresc
*/
private GresConig loadWebGresServerConfig(String webSiteDir){
/*
// URL url= GresConfigLoader.class.getClassLoader().getResource("");
URL url= GresConfigLoader.class.getResource("");
System.out.println("url:"+url.getPath());
String configFile=url+configLocalFile;
configFile.replace("\\", "/");
configFile=configFile.replace("file:","");
//for jboss
configFile=configFile.replace("vfs:","");
configFile=configFile.replace("/com/juuluu/gres/web/client/java","");
*/
String configFile=webSiteDir+"/WEB-INF/classes/"+configLocalFile;
System.out.println("load gres config file:"+configFile);
log.append("加载 gresc配置文件:"+configFile);
GresConig dbConfig=new GresConig ();
try {
System.out.println("load config:"+configFile);
FileInputStream fi=new FileInputStream(configFile);
InputStream resourceAsStream = fi;
//load config
Properties p= new java.util.Properties();
p.load(resourceAsStream);
// Database.Type=Mysql
String version=p.getProperty("gres.web.server.version");
dbConfig.setVersion(version);
//Database.dbName=guuraacmsdb
String resAppC=p.getProperty("gres.web.server.appContext");
dbConfig.setServerAppContext(resAppC);
//Database.Host=localhost
String res_Host=p.getProperty("gres.web.server.host");
dbConfig.setResHost(res_Host);
//Database.Port=3306
String database_Port=p.getProperty("gres.web.server.port");
//Database.User=root
dbConfig.setResPort(database_Port);
String database_User=p.getProperty("gres.web.server.user");
dbConfig.setResUser(database_User);
//Database.password=6636a635902bcc
String database_password=p.getProperty("gres.web.server.pwd");
//Database.urlEncode=utf8
dbConfig.setResPwd(database_password);
String database_urlEncode=p.getProperty("gres.web.server.encode");
// create connection
dbConfig.setEncode(database_urlEncode);
GresConfigLoader.resConfig=dbConfig;
System.out.println("laod "+res_Host+" Config:"+resAppC);
log.append("更新上下文gresc配置成功,新UI服务器:"+res_Host);
}catch (FileNotFoundException ex) {
ex.printStackTrace();
log.append("更新gresc配置失败:"+ex.getMessage());
// Logger.getLogger(DefaultJdbcDbUtil.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();;
log.append("更新gresc配置失败:"+ex.getMessage());
// Logger.getLogger(DefaultJdbcDbUtil.class.getName()).log(Level.SEVERE, null, ex);
}
return dbConfig;
}
修正bug后,新浪云应用显示信息:
重设UI组件服务器 重设GRESC客户端成功!
gres Ui组件服务器 :appres.sththg.com
服务器端口 :80
网站目录:/data1/jetty_work/588/juusoft/jetty-0.0.0.0-11679-juusoft.war- _1_juusoft-any-/webapp
重启日志:
加载 gresc配置文件:/data1/jetty_work/588/juusoft/jetty-0.0.0.0-11679-juusoft.war- _1_juusoft-any-/webapp/WEB-INF/classes/gres-config.properties更新上下文gresc配 置成功,新UI服务器:appres.sththg.com
加载 gresc配置文件:/data1/jetty_work/588/juusoft/jetty-0.0.0.0-11679-juusoft.war- _1_juusoft-any-/webappWEB-INF/classes/gres-config.properties更新gresc配置失败: /data1/jetty_work/588/juusoft/jetty-0.0.0.0-11679-juusoft.war-_1_juusoft-any-/webappWEB-INF/classes/gres-config.properties (No such file or directory)
错误原因:路径问题
gresc是一个java web程序调用UI共享库gres的客户端软件,该错误导致MiinCMP在新浪等平台上无法加载UI组件得模板。
详细原因:可能是jetty与Tomcat对realpath不同处理所致。
Tomcat下返回:/tomcat/webapps/ROOT/
在jetty下,即变成/tomcat/webapps/ROOT
结果导致GresC无法正确获取UI。
目前该BUG已修改,MiinCMP等程序可正常布署到新浪SAE云平台。
Juuluu的java开源cms,如kgcms,MiinCMP等皆受该BUG影响,新版本已修改该BUG,可同时兼容jetyy,tomcat等不同云平台的应用服务器。
加载 gresc配置文件:/data1/jetty_work/588/juusoft/jetty-0.0.0.0-11679-juusoft.war- _1_juusoft-any-/webappWEB-INF/classes/gres-config.properties更新gresc配置失败: /data1/jetty_work/588/juusoft/jetty-0.0.0.0-11679-juusoft.war-_1_juusoft-any-/webappWEB-INF/classes/gres-config.properties (No such file or directory)
错误原因:路径问题
gresc是一个java web程序调用UI共享库gres的客户端软件,该错误导致MiinCMP在新浪等平台上无法加载UI组件得模板。
详细原因:可能是jetty与Tomcat对realpath不同处理所致。
Tomcat下返回:/tomcat/webapps/ROOT/
在jetty下,即变成/tomcat/webapps/ROOT
结果导致GresC无法正确获取UI。
目前该BUG已修改,MiinCMP等程序可正常布署到新浪SAE云平台。
Juuluu的java开源cms,如kgcms,MiinCMP等皆受该BUG影响,新版本已修改该BUG,可同时兼容jetyy,tomcat等不同云平台的应用服务器。
更正后代码:
/*\
* 通过web目录方式加载gresc
*/
private GresConig loadWebGresServerConfig(String webSiteDir){
/*
// URL url= GresConfigLoader.class.getClassLoader().getResource("");
URL url= GresConfigLoader.class.getResource("");
System.out.println("url:"+url.getPath());
String configFile=url+configLocalFile;
configFile.replace("\\", "/");
configFile=configFile.replace("file:","");
//for jboss
configFile=configFile.replace("vfs:","");
configFile=configFile.replace("/com/juuluu/gres/web/client/java","");
*/
String configFile=webSiteDir+"/WEB-INF/classes/"+configLocalFile;
System.out.println("load gres config file:"+configFile);
log.append("加载 gresc配置文件:"+configFile);
GresConig dbConfig=new GresConig ();
try {
System.out.println("load config:"+configFile);
FileInputStream fi=new FileInputStream(configFile);
InputStream resourceAsStream = fi;
//load config
Properties p= new java.util.Properties();
p.load(resourceAsStream);
// Database.Type=Mysql
String version=p.getProperty("gres.web.server.version");
dbConfig.setVersion(version);
//Database.dbName=guuraacmsdb
String resAppC=p.getProperty("gres.web.server.appContext");
dbConfig.setServerAppContext(resAppC);
//Database.Host=localhost
String res_Host=p.getProperty("gres.web.server.host");
dbConfig.setResHost(res_Host);
//Database.Port=3306
String database_Port=p.getProperty("gres.web.server.port");
//Database.User=root
dbConfig.setResPort(database_Port);
String database_User=p.getProperty("gres.web.server.user");
dbConfig.setResUser(database_User);
//Database.password=6636a635902bcc
String database_password=p.getProperty("gres.web.server.pwd");
//Database.urlEncode=utf8
dbConfig.setResPwd(database_password);
String database_urlEncode=p.getProperty("gres.web.server.encode");
// create connection
dbConfig.setEncode(database_urlEncode);
GresConfigLoader.resConfig=dbConfig;
System.out.println("laod "+res_Host+" Config:"+resAppC);
log.append("更新上下文gresc配置成功,新UI服务器:"+res_Host);
}catch (FileNotFoundException ex) {
ex.printStackTrace();
log.append("更新gresc配置失败:"+ex.getMessage());
// Logger.getLogger(DefaultJdbcDbUtil.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();;
log.append("更新gresc配置失败:"+ex.getMessage());
// Logger.getLogger(DefaultJdbcDbUtil.class.getName()).log(Level.SEVERE, null, ex);
}
return dbConfig;
}
修正bug后,新浪云应用显示信息:
重设UI组件服务器 重设GRESC客户端成功!
gres Ui组件服务器 :appres.sththg.com
服务器端口 :80
网站目录:/data1/jetty_work/588/juusoft/jetty-0.0.0.0-11679-juusoft.war- _1_juusoft-any-/webapp
重启日志:
加载 gresc配置文件:/data1/jetty_work/588/juusoft/jetty-0.0.0.0-11679-juusoft.war- _1_juusoft-any-/webapp/WEB-INF/classes/gres-config.properties更新上下文gresc配 置成功,新UI服务器:appres.sththg.com