我目前正尝试将一些数据导出,转换并加载到数据库,以便稍后进行一些分析。但是,在运行应用程序时,它会给我一个错误!
以下是代码:
import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;
public class HelloWorldTest
{
public static void main(String args[])
{
try {
KettleEnvironment.init();
TransMeta metaData = new TransMeta("try.ktr");
Trans trans = new Trans( metaData );
trans.execute( null );
trans.waitUntilFinished();
if ( trans.getErrors() > 0 ) {
System.out.print( "Error Executing transformation" );
}
} catch( KettleException e ) {
e.printStackTrace();
}
}
}
以下是错误:
Jun 07, 2016 10:35:16 PM org.apache.commons.vfs2.VfsLog info
INFO: Using "C:\Users\Gian\AppData\Local\Temp\vfs_cache" as temporary files store.
2016/06/07 22:35:17 - TRIAL - Dispatching started for transformation [TRIAL]
2016/06/07 22:35:17 - Table output.0 - Connected to database [HOY] (commit=1000)
java.lang.NoClassDefFoundError: jxl/WorkbookSettings
child index = 0, logging object : org.pentaho.di.core.logging.LoggingObject@54a5733f parent=1645b834-7fb3-4c86-ab3d-a607681ab69c
2016/06/07 22:35:24 - Microsoft Excel Input.0 - Finished processing (I=0, O=0, R=0, W=0, U=0, E=1)
2016/06/07 22:35:24 - TRIAL - Transformation detected one or more steps with errors.
2016/06/07 22:35:24 - TRIAL - Transformation is killing the other steps!
Error Executing transformation at org.pentaho.di.trans.steps.excelinput.jxl.XLSWorkbook.<init>(XLSWorkbook.java:47)
at org.pentaho.di.trans.steps.excelinput.WorkbookFactory.getWorkbook(WorkbookFactory.java:39)
at org.pentaho.di.trans.steps.excelinput.ExcelInput.getRowFromWorkbooks(ExcelInput.java:552)
at org.pentaho.di.trans.steps.excelinput.ExcelInput.processRow(ExcelInput.java:430)
at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.ClassNotFoundException: jxl.WorkbookSettings
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
2016/06/07 22:35:24 - Microsoft Excel Input.0 - ERROR (version 6.1.0.1-196, build 1 from 2016-04-07 12.08.49 by buildguy) : Unexpected error
2016/06/07 22:35:24 - Microsoft Excel Input.0 - ERROR (version 6.1.0.1-196, build 1 from 2016-04-07 12.08.49 by buildguy) : java.lang.NoClassDefFoundError: jxl/WorkbookSettings
2016/06/07 22:35:24 - Microsoft Excel Input.0 - at org.pentaho.di.trans.steps.excelinput.jxl.XLSWorkbook.<init>(XLSWorkbook.java:47)
2016/06/07 22:35:24 - Microsoft Excel Input.0 - at org.pentaho.di.trans.steps.excelinput.WorkbookFactory.getWorkbook(WorkbookFactory.java:39)
2016/06/07 22:35:24 - Microsoft Excel Input.0 - at org.pentaho.di.trans.steps.excelinput.ExcelInput.getRowFromWorkbooks(ExcelInput.java:552)
2016/06/07 22:35:24 - Microsoft Excel Input.0 - at org.pentaho.di.trans.steps.excelinput.ExcelInput.processRow(ExcelInput.java:430)
2016/06/07 22:35:24 - Microsoft Excel Input.0 - at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62)
2016/06/07 22:35:24 - Microsoft Excel Input.0 - at java.lang.Thread.run(Thread.java:724)
2016/06/07 22:35:24 - Microsoft Excel Input.0 - Caused by: java.lang.ClassNotFoundException: jxl.WorkbookSettings
2016/06/07 22:35:24 - Microsoft Excel Input.0 - at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
2016/06/07 22:35:24 - Microsoft Excel Input.0 - at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
2016/06/07 22:35:24 - Microsoft Excel Input.0 - at java.security.AccessController.doPrivileged(Native Method)
2016/06/07 22:35:24 - Microsoft Excel Input.0 - at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
2016/06/07 22:35:24 - Microsoft Excel Input.0 - at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
2016/06/07 22:35:24 - Microsoft Excel Input.0 - at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
2016/06/07 22:35:24 - Microsoft Excel Input.0 - at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
2016/06/07 22:35:24 - Microsoft Excel Input.0 - ... 6 more
2016/06/07 22:35:24 - TRIAL - ERROR (version 6.1.0.1-196, build 1 from 2016-04-07 12.08.49 by buildguy) : Errors detected!`
答案 0 :(得分:0)
这已经解决了!你只需要下载jxl.jar并将其包含在lib文件夹中:)