[Javassist user questions] - Using Javassist inside Mojo
by ad-rocha
Hi all,
Iôm trying to use Javassist inside a Mojo. The code is very simple, but the program fails with a java.lang.ClassNotFoundException.
First I collect all dependencies of Maven project:
| // maven dependencies
| List<String> classpath = new ArrayList<String>();
| classpath.addAll(project.getCompileClasspathElements());
| classpath.addAll(project.getTestClasspathElements());
| Set<Artifact> artifacts = project.getDependencyArtifacts();
| for (Artifact artifact : artifacts) {
| classpath.add(artifact.getFile().getAbsolutePath());
| }
|
After that, I append all dependencies to ClassPool:
| ClassPool pool = ClassPool.getDefault();
| // add dependencies to classpath
| for (String element : classpath) {
| pool.appendClassPath(element);
| }
| // get class
| CtClass cc = pool.get(className);
|
The error is caused by method.getAnnotations() call below:
| ...
| if (object instanceof CtMethod) {
| CtMethod method = (CtMethod) object;
| annotations = method.getAnnotations();
| ...
| }
|
The error is: java.lang.ClassNotFoundException: org.testng.annotations.BeforeMethod
But, org.testng.annotations.BeforeMethod is inside testng-5.8-jdk15.jar, wich was added to classpath. What am I doing wrong?
Thanks in advance,
Andre
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4234800#4234800
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4234800
16 years, 10 months
[JBoss AOP] - Deploy AOP Application on JBOSS AS
by wandxinho
Hello, i was join jboss aop and a standalonne aplication works perfectly, but when i was deploy a web application on JbossAS it doesnt work. Please, wht is necessary for my application work on JbossAS ? i just follow this steps:
To upgrade your jboss instance:
1) Copy the contents of the lib folder into the JBoss-5.x/lib/ folder
2) Copy the jboss-aop-jdk50.deployer over the JBoss-5.x/server/xxx/deployers/jboss-aop-jboss5.deployer/ folder
Note that this will not replace the jboss-aspect-library.jar, which is tied to application server version
my JbossAS is 5.0.1GA and my aop version is 2.0.0GA.
and the error is
15:44:36,912 INFO [TomcatDeployment] deploy, ctxPath=/HelloWorldAOP
15:44:47,877 ERROR [[MyServlet]] Servlet.service() for servlet MyServlet threw exception java.lang.IllegalArgumentException: Can not set static org.jboss.aop.MethodInfo field Apecto.Actions.aop$MethodInfo_alterar_N_6055099272587152912 to java.lang.ref.WeakReference
Thanks!
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4234798#4234798
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4234798
16 years, 10 months
[Installation, Configuration & DEPLOYMENT] - Re:
by alskor
"jaikiran" wrote :
| Looks like the com.starview.support.startup.Startup's instantiateClasses is trying to invoke some constructor? Can you post the relevant code? Also why is it that the application specific code is trying to instantiate this class?
|
here's that line, where exception is being thrown (line 516), although I don't think it would help:
startupObject = withPropFileConstructor.newInstance(args);
|
the code loads some startup classes in that method and one of them requires a context initialization, which can't be performed because (I guess) the proper JAR file is not visible to the current classloader (why??).
It's an old legacy app and I can't really change much in this scheme. It works properly with Jboss 3.2.7.
My guess is I need to reference the jar file with that NamingContextFactory somewhere in Jboss config file. But it is already present in jboss common\lib\ folder and my current conf\jboss-service.xml has standard references to load default Jboss libs:
<classpath codebase="${jboss.server.lib.url}" archives="*"/>
| <classpath codebase="${jboss.common.lib.url}" archives="*"/>
|
so, what could be a reason for this class not being visible?
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4234781#4234781
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4234781
16 years, 10 months