Forum: Building VoltDB Applications

Post: Error when creating store procedure

Error when creating store procedure
duydx
Feb 14, 2015
Hi everyone,
I want to create a store procedure but I met a problem when trying compile it.
package voltdb;

import org.voltdb.*;

public class insert_cust extends VoltProcedure {
	// TODO Auto-generated method stub
	public final SQLStmt sqlAdd = new SQLStmt(
			"insert into customer values (?, ?, ?);");

	public VoltTable[] run(int id, int number, String text)
			throws VoltAbortException {
		voltQueueSQL(sqlAdd, id, number, text);
		voltExecuteSQL();
		return null;
	}
}



javac -classpath "./:/opt/voltdb-ent-5.0/voltdb/*" insert_cust.java

[voltdb@voltdb1 voltdb]$ sqlcmd
SQL Command :: localhost:21212
1> load classes insert_cust.jar
2> ;
VOLTDB ERROR: UNEXPECTED FAILURE:
  org.voltdb.VoltProcedure$VoltAbortException: insert_cust (wrong name: voltdb/insert_cust)
        at org.voltdb.sysprocs.UpdateApplicationCatalog.executePlanFragment(UpdateApplicationCatalog.java:195)
        at org.voltdb.ProcedureRunner.executeSysProcPlanFragment(ProcedureRunner.java:812)
        at org.voltdb.iv2.Site.executeSysProcPlanFragment(Site.java:885)
        at org.voltdb.iv2.SysprocFragmentTask.processFragmentTask(SysprocFragmentTask.java:188)
        at org.voltdb.iv2.SysprocFragmentTask.run(SysprocFragmentTask.java:126)
        at org.voltdb.iv2.Site.run(Site.java:537)
        at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NoClassDefFoundError: insert_cust (wrong name: voltdb/insert_cust)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
        at org.voltdb.utils.InMemoryJarfile$JarLoader.loadClass(InMemoryJarfile.java:300)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:270)
        at org.voltdb.sysprocs.UpdateApplicationCatalog.executePlanFragment(UpdateApplicationCatalog.java:183)
        ... 6 more

3> 

I looking forward to hearing from you.

Sincerely,
pzhao
Feb 16, 2015
duydx,

Did you do jar the class files after javac? It appears you were able to compile properly using javac. I was able to compile your code properly as well.
Here is a guide on compiling/loading a stored procedure.

Peter Zhao
duydx
Feb 17, 2015
Thanks Mr pzhao,
I didn't compile it. Thank you for show me why
Duydx
shadybroker
Jul 28, 2015
Uhm... I don't seem to have VoltProcedure available (using IntelliJ and Maven). What dependency do I have to my pom.xml to get it? And I'm using the community edition
shadybroker
Jul 28, 2015
Never mind I figured out that I would have to add the jars in voltdb-<version>/voltdb to my path to get VoltProcedure.