Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Adding external JARs in text UI folder
Adding external JARs in text UI folder [message #558901] Tue, 14 September 2010 19:48 Go to next message
No real name is currently offline No real nameFriend
Messages: 101
Registered: August 2010
Senior Member
Hi,

I need to use the Apache POI library to create Excel spreadsheets from my DSL. I created a folder called "lib" in my org.xtext.example.hlm.ui folder. I copied (I'm on Windows 7) all the relevant jars into this folder. Then, I selected each .jar file, right clicked, Build Path -> add to Build Path. Now in my action code for a menu action, I have something like this:

...

import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class MyHLMStaticChecker extends ActionDelegate implements IEditorActionDelegate {
	
	public void run(IAction action) {
		System.out.println("Executing command static checker!!!!");

		// Code here to get the model			
			Workbook wb = new XSSFWorkbook();
			System.out.println("Workbook created fine!");
		}
	}
		
	public void setActiveEditor(IAction action, IEditorPart targetEditor) {
	}
}



I get no errors/warnings in the code during development indicating that the Workbook/XSFWorkbook can't be resolved to the correct class type. When I try to run the application by selecting org.xtexst.example.hlm, right click, Run As -> Eclipse Application and select the appropriate menu command, I get an assertion error indicating the XSFWorkbook() class can't be found. I don't understand how to resovle this error:


Executing command static checker!!!!
Startup state is s0
No of state is 1
!SESSION 2010-09-14 12:37:16.740 -----------------------------------------------
eclipse.buildId=I20100608-0911
java.version=1.6.0_21
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.sdk.ide
Command-line arguments:  -product org.eclipse.sdk.ide -data C:\Users\jlm\Desktop\linux\work\dev\gui\ide/../runtime-EclipseApplication -dev file:C:/Users/pgupta6/Desktop/linux/work/dev/gui/ide/.metadata/.plugins/org.eclipse.pde.core/Eclipse Application/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog

!ENTRY org.eclipse.ui 4 0 2010-09-14 12:37:31.422
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NoClassDefFoundError: org/apache/poi/xssf/usermodel/XSSFWorkbook
	at org.xtext.example.hlm.ui.MyHLMStaticChecker.run(MyHLMStaticChecker.java:67)
	at org.eclipse.ui.actions.ActionDelegate.runWithEvent(ActionDelegate.java:70)
	at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:241)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.xssf.usermodel.XSSFWorkbook
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	... 31 more



In addition to adding the jars to the build path, is there something else that needs to be done to get this working in the Xtext deveopment environment? Thank you for any ideas.
Re: Adding external JARs in text UI folder [message #558903 is a reply to message #558901] Tue, 14 September 2010 19:53 Go to previous message
No real name is currently offline No real nameFriend
Messages: 101
Registered: August 2010
Senior Member
Please ignore. I solved it. Apparently, need to go to plugin.xml and add all the .jars in the lib folder to the classpath variable as well (just adding it to the build path is not sufficient). Now the code runs fine.

[Updated on: Tue, 14 September 2010 19:54]

Report message to a moderator

Previous Topic:Xtext editor loading non-resource data
Next Topic:reading recursively with XPand
Goto Forum:
  


Current Time: Fri Apr 26 10:42:33 GMT 2024

Powered by FUDForum. Page generated in 0.03614 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top