Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[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$java_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();
		}
	}
}



Back to the top