3 Replies Latest reply: May 18, 2012 12:19 PM by Mike Gao RSS

How to force deployed web app only use its own jar files (under WEB-INF/lib)

Mike Gao Newbie

Hi,

 

I am facing a problem when I migrate an web app from JBoss 4.2.3 to JBoss 7.1.1.  We used to put JDK's rt.jar directly under our App's WEB-INF/lib directory when we deployed the App on JBoss 4.2.3. It worked fine. However, the old way does not work with JBoss 7.1.1.  The following is the error messages:

 

1:24:43,592 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/]]

(MSC service thread 1-8) Exception sending context initialized event to listener instance of class com.digipixart.listeners.ApplicationListener:

java.lang.UnsatisfiedLinkError: Native Library E:\programs\jdk1.6.0_29\jre\bin\jpeg.dll already loaded in another classloader

    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1772) [rt.jar:1.6.0_29]

    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1724) [rt.jar:1.6.0_29]

    at java.lang.Runtime.loadLibrary0(Runtime.java:823) [rt.jar:1.6.0_29]

    at java.lang.System.loadLibrary(System.java:1028) [rt.jar:1.6.0_29]

    at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50) [rt.jar:1.6.0_04]

    at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.6.0_29]

    at com.sun.imageio.plugins.jpeg.JPEGImageReader.<clinit>(JPEGImageReader.java:71) [rt.jar:1.6.0_04]

    at com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi.createReaderInstance(JPEGImageReaderSpi.java:67) [rt.jar:1.6.0_04]

    at javax.imageio.spi.ImageReaderSpi.createReaderInstance(ImageReaderSpi.java:300) [rt.jar:1.6.0_29]

    at javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:503) [rt.jar:1.6.0_29]

    at javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:487) [rt.jar:1.6.0_29]

    at javax.imageio.ImageIO.read(ImageIO.java:1417) [rt.jar:1.6.0_29]

    at javax.imageio.ImageIO.read(ImageIO.java:1374) [rt.jar:1.6.0_29]

    at com.digipixart.listeners.ApplicationListener.testReadImage(ApplicationListener.java:395) [classes:]

    at com.digipixart.listeners.ApplicationListener.contextInitialized(ApplicationListener.java:330) [classes:]

    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]

    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]

    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_29]

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_29]

    at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_29]

 

The error messages above show the rt.jar under WEB-INF/lib (with version 1.6.0_04) and rt.jar under JAVA_HOME/jre/lib (with version 1.6.0_29) are mixed. Sometimes, JDK's rt.jar is used and sometimes rt.jar under WEB-INF/lib is used. I think that is why I get the error message of "java.lang.UnsatisfiedLinkError: Native Library E:\programs\jdk1.6.0_29\jre\bin\jpeg.dll already loaded in another classloader". It is because rt.jar of JDK is not in the same thread of rt.jar under WEB-INF/lib. When two different class loaders try to load the same native library, the UnsatisfiedLinkError is thrown.

 

Can someone please help me to resolve the issue?

 

Thank you very much in advance.

 

Mike