Error in XML Parsing on Sun Java System Portal Server 7

Hi All,

I have made a Sample Porlet which consist of xml parsing using xerces.jar.When I deploy this application on Sun Java Sytem Portal Server 7 on Linux the portlet gives error.I think this is because of class loader i.e it is not loading xerces.jar which is in the classpath of my application but instead of that it is taking the xerces.jar from the server itself due to which I m not able to run my portlet.

How can I manage to load xerces.jar which is within my application?Or is there any other problem or whether I have to place this xerces.jar in the server.Please let me know if anyone has got idea about this.All suggestions are welcome.

Thanx and Regards,

Chirag.

[706 byte] By [chirag1011] at [2007-11-26 8:03:20]
# 1
What web server / application server are you using?
jimfaut at 2007-7-6 20:37:09 > top of Java-index,Web & Directory Servers,Portal Servers...
# 2

the order in which classes are loaded (web app vs. system class loader) is not defined by j2ee, and varies by vendor. so, your analysis of the root cause may very well be correct. all web containers that i know of at least have a vendor specific method to cause your web app to favor the web app classes.

as i mentioned, the method for choosing the web app classes first will depend on the web container you are using. you should be able to find out how to do that by looking into the docs for the web container. maybe someone else here has the specifics for you.

of course, the easiest thing would be to see if you can use the XML-related classes that come standard in the JDK. otherwise, you need to have a vendor specific deployment descriptor for every web container that you want to run your web app on.

farble1670 at 2007-7-6 20:37:09 > top of Java-index,Web & Directory Servers,Portal Servers...
# 3

Hi All,

Thanx for the reply.I will try to find the way how the classes are loaded from the application.

By the way I m using Sun Java System Web Server 6.1 SP5 and Sun Java System Application Server 8.1.

If any one has got idea how to define loading of classes in these servers please let me know.All suggestions are welcome.

Thanx and Regards,

Chirag.

chirag1011 at 2007-7-6 20:37:09 > top of Java-index,Web & Directory Servers,Portal Servers...
# 4

Chirag,

The Portal Server 7 installer installs JDK 1.5.0_04 and the Webserver, Appserver instances are started using this JDK. The JDK bundles JAXP APIs. Since they are bundled into the Java Runtime Environment, the Servlet/J2EE container cannot and does not allow users to override it.Putting the newer version of the XML API Jars in the server classpath or even in the WAR IWEB-INF/lib) does not work. Basically the Servlet/J2EE containers do not allow webapplications to load newer versions of a class that is already bundled into the JRE.

One way to force the webcontainer to use a different version of JAXP or other bundled API is to set the java.endorsed.dirs VM property.

http://java.sun.com/j2se/1.5.0/docs/guide/standards/

One Weberver this can be done by adding the following entry in the server.xml in the JVM options section:

<jvm-options>-Djava.endorsed.dirs=/opt/new/jaxp</jvm-options>

However doing this change will cause the entire VM, Appserver/Webserver applications to use the APIs in the endorsed directroy. This can potentially break the Appserver/Webserver or other applications that depend on the older version of the APIs.

Since this change can have a lot of implications, you might want to check if this kind of change is supported by Sun.

thanks,

_raju

uppalapa at 2007-7-6 20:37:09 > top of Java-index,Web & Directory Servers,Portal Servers...
# 5

Chirag,

One more alternate solution is:

To include a vendor specific deployment descriptor to change the classloader lookup order from parent first to child first. for example, for sun's web containers you do this by adding a sun-web.xml:

<?xml version="1.0" encoding="UTF-8"?>

<sun-web-app>

...

<class-loader>

<property name="delegate" value="false"/>

</class-loader>

</sun-web-app>

mahipalsinhrana at 2007-7-6 20:37:09 > top of Java-index,Web & Directory Servers,Portal Servers...
# 6

Hi All,

Thanx for your replies.I have tried the following solutions:

1. I have created "endorsed" folder in /opt and copied xerces.jar in that folder and In server.xml of webserver I added the the following tag in JVM options section:

<jvm-options>-Djava.endorsed.dirs=/opt/endorsed</jvm-options>

2. Next I also added in sun-web.xml:

<?xml version="1.0" encoding="UTF-8"?>

<sun-web-app>

...

<class-loader>

<property name="delegate" value="false"/>

</class-loader>

</sun-web-app>

Both the above mentioned solutions did not worked.It will be helpful for me if you can suggest me some other alternatives.All suggestions are welcome.

Thanx and regards,

Chirag.

chirag1011 at 2007-7-6 20:37:09 > top of Java-index,Web & Directory Servers,Portal Servers...