Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] A newbie's question : java.lang.NoSuchMethodError

Hi,

This is not possible without the alteration of the JRE classes.
Currently AspectJ implements an Inter-type member declaration via a
method added to an interface. The method is implemented in all direct
know implementing classes (sub classes inherit the method). Thus though
your xxx.xxx.XXXXPreparedStatement classes has this particular method it
is not defined in the java.sql.PreparedStatement interface that is
loaded.

<aside>
Half the battle in writing a tracing tool is capturing the information
the second and often the most important is the visual representation of
the performance data. You might want to check out
www.jinspired.com/products/jdbinsight/ which is a Java/JDBC profiler.
Unless of course you are in the business of writing profiler tools and
not business applications.

Early Access download:
http://www.jinspired.com/products/jdbinsight/eap/jdbinsight_20ea2b.exe
Note: The exe is Windows installer as the console is currently only
supported on Windows though in the <install-root>/bin directory there
are serverside binaries for solaris and linux.

A new build will be available at the weekend to be notified on new
builds send an email to sales@xxxxxxxxxxxxx.

The next release of JDBInsight will be based around our work-in-progress
AspectJ integration. Following that we will be providing a J2EE profiler
based around AspectJ, JVMPI / JVMTI and CEEP (Complex Enterprise Event
Processing) see Power of Events Book.
<aside>

All the best,

William Louth
JDBInsight Product Architect
www.jinspired.com


-----Original Message-----
From: Wang, Weiguo [mailto:WWang@xxxxxxxxxxxxx] 
Sent: Wednesday, August 13, 2003 6:17 PM
To: 'aspectj-users@xxxxxxxxxxx'
Subject: [aspectj-users] A newbie's question :
java.lang.NoSuchMethodError


Hi,

I am writing a SQL tracing tool for my project, but am stuck with this
particular issue:

I wanted to introduce a String member to the interface,
java.sql.PreparedStatement. The aspect compiled fine in eclipse. My
driver jar file has been regenerated with the aspect weaved in. But I
got the following exception when I ran the database access code:

java.lang.NoSuchMethodError:
java.sql.PreparedStatement.ajc$interFieldSet$aspects_test_TestAspect$jav
a_sq
l_PreparedStatement$sqlCopy(Ljava/lang/String;)V
	at
aspects.test.TestAspect.ajc$interFieldInit$aspects_test_TestAspect$java_
sql_
PreparedStatement$sqlCopy(TestAspect.java:14)
	at
com.mysql.jdbc.PreparedStatement.<init>(PreparedStatement.java:112)
	at
com.mysql.jdbc.Connection.prepareStatement(Connection.java:1293)
	at
com.mysql.jdbc.Connection.prepareStatement(Connection.java:1267)
	at aspects.test.TestMain.main(TestMain.java:20)
Exception in thread "main" 

I inspected the decompiled classes. Everything looks fine to me. I've
listed my aspect and test class below. I am using mysql. The code is
very easy to be modified to work with other databases/drivers. Any help
is greatly appreciated.

Please forgive me if this or similar issue has been posted before. The
archive doesn't support searching.

Weiguo


-----------------------------------------------------------------------
package aspects.test;

import java.sql.*;

public aspect TestAspect 
{
	/*
	 * Tried to introduce a new member
	 */	
	private String PreparedStatement.sqlCopy = "";

}
-----------------------------------------------------------------------
package aspects.test;

import java.sql.*;

/*
 * 
 * Test class. Just run main.
 */
public class TestMain
{
	private static String URL =
		"jdbc:mysql://localhost:3306/mysql?user=root&password=";

	public static void main(String[] args1)
	{
		try
		{
	
Class.forName("com.mysql.jdbc.Driver").newInstance();
			java.sql.Connection conn =
DriverManager.getConnection(URL);
			conn.prepareStatement("select * from address
where address_id = ?");
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
}

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top