It looks like weblogic throws this error when web application is deployed only as WAR. But it doesn't throw any exception when deployed as exploded.
weblogic.management.DeploymentException: Cannot set web app root system property when WAR file is not expanded - with nested exception: [java.lang.IllegalStateException: Cannot set web app root system property when WAR file is not expanded].
There are two ways we can fix this issue when you still want to deploy as WAR.
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. or you can directly edit your domain config.xml and add the below entry.
<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.
ServletContext.getRealPath returns null
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.
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.
Labels:
Weblogic
Java exception unknown source
Sometimes when debugging application we may run into this exception - Java Exception unknown source.
The possible reason could be when compiling the application, javac ant tasks omits debug option by defaut. So we will have to explicity set debug flag to true. See the javac ant task documentation for more info. You can mention some thing like below:
The possible reason could be when compiling the application, javac ant tasks omits debug option by defaut. So we will have to explicity set debug flag to true. See the javac ant task documentation for more info. You can mention some thing like below:
<target name="compile"> <javac srcdir="${src.dir}" destdir="{dest.dir}." debug="on" debuglevel="lines,vars,source" /> </target>
Hope this helps.
Labels:
Java
Log4jConfigListener Deployment Issue
It looks like Spring framework's Log4jConfigListener is having an issue when webapp is deployed as WAR. Log4jConfigListener is defined in web.xml. I got the below error while deploying the application in weblogic 10.3.
weblogic.management.DeploymentException: Cannot set web app root system property when WAR file is not expanded - with nested exception: [java.lang.IllegalStateException: Cannot set web app root system property when WAR file is not expanded].
The solution is deploy the WAR as exploded or don't use Log4jConfigListener. The spring framework documentation also says the WAR should be exploded.
There is some update here. There is a solution available to this without any code change. We just need to set "Archived Real Path Enabled" option checked. Please check this blog entry on how to enable.
Useful Links:
To read more articles on Weblogic, please click here.
weblogic.management.DeploymentException: Cannot set web app root system property when WAR file is not expanded - with nested exception: [java.lang.IllegalStateException: Cannot set web app root system property when WAR file is not expanded].
The solution is deploy the WAR as exploded or don't use Log4jConfigListener. The spring framework documentation also says the WAR should be exploded.
There is some update here. There is a solution available to this without any code change. We just need to set "Archived Real Path Enabled" option checked. Please check this blog entry on how to enable.
Useful Links:
To read more articles on Weblogic, please click here.
Labels:
log4j,
Log4jConfigListener,
Weblogic
ResourceUtils.getFile() bug in Spring Framework 2.0.8 with weblogic10.3
I cam across this weird problem which gave me really hard time for about 2-3 weeks. The issue is as below:
We use spring framework in one of our web applications. One of the java classes loads XMLs which reside in web-inf/classes folder. It uses ResourceUtils.getFile() method as below:
File file = ResourceUtils.getFile("classpath://data-values.xml");
This method works fine when we deploy as exploded WAR in weblogic 10.3 but when we deploy as WAR, it gives FileNotFoundException. What weblogic does during WAR deployment(obviously it internally explodes) is, it puts all the files reside in web-inf/classes folder into jar called _wl_cls_gen.jar file and copies into web-inf/lib directory. This is where the problem during deployment as the java class was unable to read the xml and throwing FileNotFoundException.
The exact error message is as below:
java.io.FileNotFoundException: class path resource [//data-values.xml] cannot be resolved to absolute file path because it does not reside in the file system: zip:C:/domains/devDomain/servers/AdminServer/tmp/_WL_user/testWebApp/8j5e1y/war/WEB-INF/lib/_wl_cls_gen.jar!/data-values.xml
So I was looking to see if there is a way to tell weblogic to avoid generating this jar as my java classes were unable to load XMLs which resides in that jar file now. It looks like as for as my knowledge there may not be a way. Even I have asked the same question in oracle forums itself but that didn't help. Also when we googled we came across this issue in number of search results. Some say it is spring issue with ResourceUtils.getFile().
Some suggested use different approach to load xmls. So one of our team members tried using org.springframework.core.io.ClassPathResource which fixed the issue. The code snippet is as below:
String xmlFile = "classpath://data-values.xml";
final int index = StringUtils.lastIndexOf(xmlFile, "/") == -1 ? 0 : StringUtils.lastIndexOf(xmlFile, "/");
final Resource resource = new ClassPathResource(StringUtils.substring(xmlFile, index, xmlFile.length()));
final InputStream is = resource.getInputStream();
try {
final InputStreamReader reader = new InputStreamReader(is);
try {
final Document headerDoc = new SAXBuilder().build(reader);
} finally {
reader.close();
}
} finally {
is.close();
}
It looks like Spring's 2.0.8 version ResourceUtils.getFile() method is having a bug while loading xmls when you deploy as WAR in weblogic. But no issues when you deploy as exploded. But ClasspathResource seems to be working fine.
We use spring framework in one of our web applications. One of the java classes loads XMLs which reside in web-inf/classes folder. It uses ResourceUtils.getFile() method as below:
File file = ResourceUtils.getFile("classpath://data-values.xml");
This method works fine when we deploy as exploded WAR in weblogic 10.3 but when we deploy as WAR, it gives FileNotFoundException. What weblogic does during WAR deployment(obviously it internally explodes) is, it puts all the files reside in web-inf/classes folder into jar called _wl_cls_gen.jar file and copies into web-inf/lib directory. This is where the problem during deployment as the java class was unable to read the xml and throwing FileNotFoundException.
The exact error message is as below:
java.io.FileNotFoundException: class path resource [//data-values.xml] cannot be resolved to absolute file path because it does not reside in the file system: zip:C:/domains/devDomain/servers/AdminServer/tmp/_WL_user/testWebApp/8j5e1y/war/WEB-INF/lib/_wl_cls_gen.jar!/data-values.xml
So I was looking to see if there is a way to tell weblogic to avoid generating this jar as my java classes were unable to load XMLs which resides in that jar file now. It looks like as for as my knowledge there may not be a way. Even I have asked the same question in oracle forums itself but that didn't help. Also when we googled we came across this issue in number of search results. Some say it is spring issue with ResourceUtils.getFile().
Some suggested use different approach to load xmls. So one of our team members tried using org.springframework.core.io.ClassPathResource which fixed the issue. The code snippet is as below:
String xmlFile = "classpath://data-values.xml";
final int index = StringUtils.lastIndexOf(xmlFile, "/") == -1 ? 0 : StringUtils.lastIndexOf(xmlFile, "/");
final Resource resource = new ClassPathResource(StringUtils.substring(xmlFile, index, xmlFile.length()));
final InputStream is = resource.getInputStream();
try {
final InputStreamReader reader = new InputStreamReader(is);
try {
final Document headerDoc = new SAXBuilder().build(reader);
} finally {
reader.close();
}
} finally {
is.close();
}
It looks like Spring's 2.0.8 version ResourceUtils.getFile() method is having a bug while loading xmls when you deploy as WAR in weblogic. But no issues when you deploy as exploded. But ClasspathResource seems to be working fine.
Subscribe to:
Posts (Atom)