Reputation: 883
I try to use AspectJ loadtime-weaving in an applet with jars from my web server as I use a Java reflection call on a library. The name of the class that must be loaded is passed as a parameter. I cannot use compiletime-weaving therefore.
Here is some piece of code of my applet "MyApplet":
URLClassLoader appletClassLoader = (URLClassLoader)
RemoteConfigurationApplet.class.getClassLoader();
URL[] urlList = appletClassLoader.getURLs();
URL aspectJar = null;
try {
aspectJar = new URL("https://myserver:8443/MyWebApp/applet/MyApplet.jar/");
} catch (MalformedURLException e1) {
e1.printStackTrace();
}
WeavingURLClassLoader weavingClassLoader = new WeavingURLClassLoader(urlList,
new URL[]{ aspectJar }, Thread.currentThread().getContextClassLoader());
However, I always get an exception:
org.aspectj.bridge.AbortException: bad aspect library: "/MyWebApp/applet/MyApplet.jar"
I suspect the usage of a file-object in "addAspectLibrary" to be responsible for the problem:
private void addAspectLibrary(String aspectLibraryName) {
File aspectLibrary = new File(aspectLibraryName);
if (aspectLibrary.isDirectory() || (FileUtil.isZipFile(aspectLibrary))) {
try {
info("adding aspect library: '" + aspectLibrary + "'");
weaver.addLibraryJarFile(aspectLibrary);
} catch (IOException ex) {
error("exception adding aspect library: '" + ex + "'");
}
} else {
error("bad aspect library: '" + aspectLibrary + "'");
}
}
It cuts down the URL and then looks on the harddisk for this file where it cannot find it. Has anybody a solution to make it running though?
Upvotes: 0
Views: 723