`
avi2
  • 浏览: 90335 次
社区版块
存档分类
最新评论

weblogic with spring hibernate mappingDirectoryLocations error

    博客分类:
  • java
阅读更多
_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

分享到:
评论

相关推荐

    spring-boot-reference.pdf

    4. Working with Spring Boot 5. Learning about Spring Boot Features 6. Moving to Production 7. Advanced Topics II. Getting Started 8. Introducing Spring Boot 9. System Requirements 9.1. Servlet ...

    spring-framework-reference-4.1.2

    3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................

    spring-framework-reference4.1.4

    3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................

    java面试题

    Hibernate和spring中常出现的几个异常 61 71.13. Hibernate与jdbc的联系 62 71.14. Hibernate与Spring的联系 62 71.15. Hibernate自带的分页机制是什么?如果不使用Hibernate自带的分页,则采用什么方式分页? 62 ...

    java面试宝典

    62、error和exception有什么区别 16 63、ArrayList和Vector的区别 16 64、Collection 和 Collections的区别 17 65、Set里的元素是不能重复的,那么用什么方法来区分重复与否呢? 是用==还是equals()? 它们有何区别 17...

    紫光华宇软件工程师笔试题

    【紫光华宇软件工程师笔试题】涉及到的知识点广泛,主要涵盖了Java编程、Spring框架、Hibernate ORM、JDBC、异常处理、设计模式、数据库操作、HTML、CSS、JavaScript以及JSP等多个方面。以下是对这些知识点的详细...

    框架面试笔试问答题.docx

    - **Oracle WebLogic Server**:高性能的企业级应用服务器,支持集群、负载均衡等功能。 #### 2. 数据连接池的工作机制 - **连接池**是一种用于存储数据库连接的机制,目的是提高数据库访问效率和减少数据库连接...

    最新Java面试宝典pdf版

    14、spring+Hibernate中委托方案怎么配置? 123 15、spring+Hibernate中委托方案怎么配置? 123 16. hibernate进行多表查询每个表中各取几个字段,也就是说查询出来的结果集没有一个实体类与之对应如何解决; 123 17....

    JAVA面试宝典2010

    14、spring+Hibernate中委托方案怎么配置? 123 15、spring+Hibernate中委托方案怎么配置? 123 16. hibernate进行多表查询每个表中各取几个字段,也就是说查询出来的结果集没有一个实体类与之对应如何解决; 123 17....

    Java面试宝典-经典

    14、spring+Hibernate中委托方案怎么配置? 123 15、spring+Hibernate中委托方案怎么配置? 123 16. hibernate进行多表查询每个表中各取几个字段,也就是说查询出来的结果集没有一个实体类与之对应如何解决; 123 17....

    java面试题大全(2012版)

    14、spring+Hibernate中委托方案怎么配置? 123 15、spring+Hibernate中委托方案怎么配置? 123 16. hibernate进行多表查询每个表中各取几个字段,也就是说查询出来的结果集没有一个实体类与之对应如何解决; 123 17....

    Java面试宝典2012版

    14、spring+Hibernate中委托方案怎么配置? 123 15、spring+Hibernate中委托方案怎么配置? 123 16. hibernate进行多表查询每个表中各取几个字段,也就是说查询出来的结果集没有一个实体类与之对应如何解决; 123 ...

    java面试宝典2012

    14、spring+Hibernate中委托方案怎么配置? 134 15、spring+Hibernate中委托方案怎么配置? 134 16. hibernate进行多表查询每个表中各取几个字段,也就是说查询出来的结果集没有一个实体类与之对应如何解决; 135 17....

    Java面试宝典2012新版

    14、spring+Hibernate中委托方案怎么配置? 123 15、spring+Hibernate中委托方案怎么配置? 123 16. hibernate进行多表查询每个表中各取几个字段,也就是说查询出来的结果集没有一个实体类与之对应如何解决; 123 17....

Global site tag (gtag.js) - Google Analytics