设为首页 收藏本站
查看: 521|回复: 0

[经验分享] weblogic with spring hibernate mappingDirectoryLocations error

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2017-2-16 10:00:57 | 显示全部楼层 |阅读模式
_wls_cls_gen.jar Issue
from http://jaysensharma.wordpress.com/2009/12/28/_wls_cls_gen-jar-issue/
WebLogic 10 And WebLogic 10.3 creates a Jar file (_wls_cls_gen.jar)while deploying our Archieved Applications (WAR files). Which includes all the contains available inside the WEB-INF/classes directory inside this jar file(_wls_cls_gen.jar). I didnot find a way to tell WebLogic Server to not to create this JAR file, because it creates many issues.
Example: if we have placed a Property file or Some XML files  inside the “WEB-INF/classes” directory with the name “test.properties” or “test.xml” then WebLogic Server will place this Property file as well inside the (_Wls_cls_gen.jar) file while deployment…
zip:C:/bea103/user_projects/domains/Test_Domain/servers/AdminServer/tmp/_WL_user/testWebApp/8j5e1y/war/WEB-INF/lib/_wl_cls_gen.jar!/test.properties
Now if we write the following code inside out application like Servlet then it won’t work and will fail while reading the Properties file:
Note: Many frameworks uses the Following techinques and Sometimes WebLogic Code causes this issue..(http://forums.oracle.com/forums/thread.jspa?messageID=4217650#4217650)…which may cause our applications to fail while reading jar Archieved resources. because they uses the following techinque to read the resources available inside a JAR file:
——————————————-WRONG – APPROACH – BELOW———————
InputStream stream = null;
try {
Properties p = new Properties();
String path=Thread.currentThread().getContextClassLoader().getResource(“Info.properties”).getPath();
System.out.println(“—————-PATH: “+path);
p.load(new java.io.FileInputStream(path));
Host = p.getProperty(“Host”);
Pot = p.getProperty(“Port”);
User = p.getProperty(“User”);
Passwd = p.getProperty(“Passwd”);
System.out.println(“Property Key-Values:” +”\n”+ Host +”\n”+ Pot + “\n”+User+ “\n”+Passwd);
} catch (Exception e) {
e.printStackTrace();
}

——————
To avoid the above issue…we need to change our code like following: most of the Frameworks also need to change their implementations…
———————— CORRECT – APPROACH – BELOW ——————-
InputStream stream = null;
System.out.println(“————————————”);
try {
Properties p = new Properties();
stream=this.getClass().getClassLoader().getResourceAsStream(“Info.properties”);
p.load(stream);
Host = p.getProperty(“Host”);
Pot = p.getProperty(“Port”);
User = p.getProperty(“User”);
Passwd = p.getProperty(“Passwd”);
System.out.println(“Property Key-Values:” +”\n”+ Host +”\n”+ Pot + “\n”+User+ “\n”+Passwd);
} catch (Exception e) {
e.printStackTrace();
}

———————
The above piece of code can be used whenever we want to read a Non-Class/Class resource from inside a JAR file.
Thanks
Jay SenSharma

__________________________________________
weblogic sucks! either you rewrite the function of spring , or you just use the folder way.

besides:
ServletContext.getRealPath returns null

http://ananthkannan.blogspot.com/2009/12/servletcontextgetrealpath-returns-null.html
Another weird behavior from weblogic when webapp is deployed as WAR. ServletContext.getRealPath() returns null when deployed as WAR but it works ok when deployed as exploded. There are two ways we can fix this issue when you still want to deploy as WAR but would like to get over with this issue:
1. Go to server admin console->Domain-> Web applications. Click the checkbox of Archived Real Path Enabled. This should make an entry into domain config.xml as below.
       <web-app-container>
<show-archived-real-path-enabled>true</show-archived-real-path-enabled>
</web-app-container>

2. Second option is at webapp level by updating weblogic.xml as below:
      <container-descriptor>
<show-archived-real-path-enabled>true</show-archived-real-path-enabled>
</container-descriptor>
The value of <show-archived-real-path-enabled> set in the web app has precedence over the value set at the domain level. The default value of this property is false.
have read an article again, maybe I can try
http://forum.springsource.org/showthread.php?t=45204&referrerid=14239
See the Spring Reference 4.7.2.3 http://static.springframework.org/spring/docs/2.5.x/reference/resources.html#resources-wildcards-in-path-other-stuff
which explains why "classpath*:*.hbm.xml" doesn't work. You can get it to work if you put your hbm.xml files in a specified subdirectory/package, for example "classpath*:res/*.hbm.xml". Or if you put them in the same directories as the corresponding Java classes, you could use "classpath*:com/**/*.hbm.xml", assuming your classes are under the root package "com".
Reply With Quote

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-342854-1-1.html 上篇帖子: weblogic部署企业应用程序目录结构 下篇帖子: Using WebLogic JDBC in an Application
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表