Skip to content

Instantly share code, notes, and snippets.

@tstibbs
Last active January 26, 2016 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tstibbs/945a0a4c467f0547ec0c to your computer and use it in GitHub Desktop.
Save tstibbs/945a0a4c467f0547ec0c to your computer and use it in GitHub Desktop.
# loaded from the correct place
[Loaded com.google.common.base.internal.Finalizer from file:/home/user/mywar/dqgjbr/war/WEB-INF/lib/guava-15.0-cdi1.0.jar]
FINALIZE CLASS LOC: file:/home/user/mywar/dqgjbr/war/WEB-INF/lib/guava-15.0-cdi1.0.jar
# also loaded from the correct place
[Loaded com.google.common.base.FinalizableReferenceQueue from file:/home/user/mywar/dqgjbr/war/WEB-INF/lib/guava-15.0-cdi1.0.jar]
# for some reason FinalizableReferenceQueue loads Finalizer again, but this time from the wrong place
[Loaded com.google.common.base.internal.Finalizer from file:/opt/wlserver/modules/features/weblogic.server.merged.jar]
# which results in this stack trace
<26-Jan-2016 11:45:18 o'clock GMT> <Warning> <HTTP> <BEA-101162> <User defined listener com.example.TestFilter failed: java.lang.AssertionError: java.lang.NoSuchMethodException: com.google.common.base.internal.Finalizer.startFinalizer(java.lang.Class, java.lang.ref.ReferenceQueue, java.lang.ref.PhantomReference).
java.lang.AssertionError: java.lang.NoSuchMethodException: com.google.common.base.internal.Finalizer.startFinalizer(java.lang.Class, java.lang.ref.ReferenceQueue, java.lang.ref.PhantomReference)
at com.google.common.base.FinalizableReferenceQueue.getStartFinalizer(FinalizableReferenceQueue.java:308)
at com.google.common.base.FinalizableReferenceQueue.<clinit>(FinalizableReferenceQueue.java:90)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.example.TestFilter.contextInitialized(TestFilter.java:28)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodException: com.google.common.base.internal.Finalizer.startFinalizer(java.lang.Class, java.lang.ref.ReferenceQueue, java.lang.ref.PhantomReference)
at java.lang.Class.getMethod(Class.java:1665)
at com.google.common.base.FinalizableReferenceQueue.getStartFinalizer(FinalizableReferenceQueue.java:302)
at com.google.common.base.FinalizableReferenceQueue.<clinit>(FinalizableReferenceQueue.java:90)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
Truncated. see log file for complete stacktrace
package com.example;
import java.net.URL;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class TestFilter implements ServletContextListener
{
public void contextInitialized(ServletContextEvent sce)
{
try
{
final URL finalizerPath = Class.forName("com.google.common.base.internal.Finalizer").getProtectionDomain().getCodeSource().getLocation();
System.out.println("FINALIZE CLASS LOC: " + finalizerPath);//will print the path to the guava jar in our web-inf
Class.forName("com.google.common.base.FinalizableReferenceQueue");//will error
}
catch (ClassNotFoundException e)
{
}
}
public void contextDestroyed(ServletContextEvent sce)
{
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0" metadata-complete="true">
<listener>
<listener-class>com.example.TestFilter</listener-class>
</listener>
</web-app>
<!DOCTYPE weblogic-web-app PUBLIC
"-//BEA Systems, Inc.//DTD Web Application 8.1//EN"
"http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd">
<weblogic-web-app>
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment