slider161
asked on
java.lang.InstantiationException
am writing an Ant script to run a JUnit test suite within an Eclipse plug-in and generate a JUnit report outside of Eclipse. I am referring to this tutorial
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.test/testframework.html?revision=1.4
I have written a test.xml file for my plug-in which uses the org.eclipse.test library.xml file run the suite and generate a report.
When I run the script I get the following error:
"org.osgi.framework.Bundle Exception: The activator org.eclipse.core.runtime.P lugin for bundle com.propylon.core.Test is invalid "
"Caused by: java.lang.InstantiationExc eption"
however the the class in-question is not an interface or abstract
Below is the class:
package com.propylon.core.tests;
import org.eclipse.core.runtime.P lugin;
import org.osgi.framework.BundleC ontext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends Plugin {
// The plug-in ID
public static final String PLUGIN_ID = "com.propylon.core.tests";
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.P lugins#sta rt(org.osg i.framewor k.BundleCo ntext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.P lugin#stop (org.osgi. framework. BundleCont ext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}
below is the stacktrace:
java-test:
[echo] Running com.propylon.core.tests.te stcase.All Tests. Result file: C:/eclipse3.3/results/com. propylon.c ore.tests. testcase.A llTests.xm l.
[java] org.osgi.framework.BundleE xception: The activator org.eclipse.core.runtime.P lugin for bundle com.propylon.core.Test is invalid
[java] at org.eclipse.osgi.framework .internal. core.Abstr actBundle. loadBundle Activator( AbstractBu ndle.java: 141)
[java] at org.eclipse.osgi.framework .internal. core.Bundl eContextIm pl.start(B undleConte xtImpl.jav a:970)
[java] at org.eclipse.osgi.framework .internal. core.Bundl eHost.star tWorker(Bu ndleHost.j ava:346)
[java] at org.eclipse.osgi.framework .internal. core.Abstr actBundle. start(Abst ractBundle .java:260)
[java] at org.eclipse.osgi.framework .util.Secu reAction.s tart(Secur eAction.ja va:400)
[java] at org.eclipse.core.runtime.i nternal.ad aptor.Ecli pseLazySta rter.postF indLocalCl ass(Eclips eLazyStart er.java:11 1)
[java] at org.eclipse.osgi.baseadapt or.loader. ClasspathM anager.fin dLocalClas s(Classpat hManager.j ava:417)
[java] at org.eclipse.osgi.internal. baseadapto r.DefaultC lassLoader .findLocal Class(Defa ultClassLo ader.java: 189)
[java] at org.eclipse.osgi.framework .internal. core.Bundl eLoader.fi ndLocalCla ss(BundleL oader.java :340)
[java] at org.eclipse.osgi.framework .internal. core.Bundl eLoader.fi ndClassInt ernal(Bund leLoader.j ava:408)
[java] at org.eclipse.osgi.framework .internal. core.Bundl eLoader.fi ndClass(Bu ndleLoader .java:369)
[java] at org.eclipse.osgi.framework .internal. core.Bundl eLoader.fi ndClass(Bu ndleLoader .java:357)
[java] at org.eclipse.osgi.internal. baseadapto r.DefaultC lassLoader .loadClass (DefaultCl assLoader. java:83)
[java] at java.lang.ClassLoader.load Class(Unkn own Source)
[java] at org.eclipse.osgi.framework .internal. core.Bundl eLoader.lo adClass(Bu ndleLoader .java:289)
[java] at org.eclipse.osgi.framework .internal. core.Bundl eHost.load Class(Bund leHost.jav a:227)
[java] at org.eclipse.osgi.framework .internal. core.Abstr actBundle. loadClass( AbstractBu ndle.java: 1269)
[java] at org.eclipse.test.EclipseTe stRunner.l oadSuiteCl ass(Eclips eTestRunne r.java:302 )
[java] at org.eclipse.test.EclipseTe stRunner.g etTest(Ecl ipseTestRu nner.java: 233)
[java] at org.eclipse.test.EclipseTe stRunner.< init>(Ecli pseTestRun ner.java:2 16)
[java] at org.eclipse.test.EclipseTe stRunner.r un(Eclipse TestRunner .java:200)
[java] at org.eclipse.test.CoreTestA pplication .runTests( CoreTestAp plication. java:35)
[java] at org.eclipse.test.CoreTestA pplication .run(CoreT estApplica tion.java: 31)
[java] at sun.reflect.NativeMethodAc cessorImpl .invoke0(N ative Method)
[java] at sun.reflect.NativeMethodAc cessorImpl .invoke(Un known Source)
[java] at sun.reflect.DelegatingMeth odAccessor Impl.invok e(Unknown Source)
[java] at java.lang.reflect.Method.i nvoke(Unkn own Source)
[java] at org.eclipse.equinox.intern al.app.Ecl ipseAppCon tainer.cal lMethod(Ec lipseAppCo ntainer.ja va:533)
[java] at org.eclipse.equinox.intern al.app.Ecl ipseAppHan dle.run(Ec lipseAppHa ndle.java: 155)
[java] at org.eclipse.core.runtime.i nternal.ad aptor.Ecli pseAppLaun cher.runAp plication( EclipseApp Launcher.j ava:106)
[java] at org.eclipse.core.runtime.i nternal.ad aptor.Ecli pseAppLaun cher.start (EclipseAp pLauncher. java:76)
[java] at org.eclipse.core.runtime.a daptor.Ecl ipseStarte r.run(Ecli pseStarter .java:363)
[java] at org.eclipse.core.runtime.a daptor.Ecl ipseStarte r.run(Ecli pseStarter .java:176)
[java] at sun.reflect.NativeMethodAc cessorImpl .invoke0(N ative Method)
[java] at sun.reflect.NativeMethodAc cessorImpl .invoke(Un known Source)
[java] at sun.reflect.DelegatingMeth odAccessor Impl.invok e(Unknown Source)
[java] at java.lang.reflect.Method.i nvoke(Unkn own Source)
[java] at org.eclipse.equinox.launch er.Main.in vokeFramew ork(Main.j ava:504)
[java] at org.eclipse.equinox.launch er.Main.ba sicRun(Mai n.java:443 )
[java] at org.eclipse.equinox.launch er.Main.ru n(Main.jav a:1169)
[java] at org.eclipse.equinox.launch er.Main.ma in(Main.ja va:1144)
[java] at org.eclipse.core.launcher. Main.main( Main.java: 30)
[java] Caused by: java.lang.InstantiationExc eption
[java] at sun.reflect.InstantiationE xceptionCo nstructorA ccessorImp l.newInsta nce(Unknow n Source)
[java] at java.lang.reflect.Construc tor.newIns tance(Unkn own Source)
[java] at java.lang.Class.newInstanc e0(Unknown Source)
[java] at java.lang.Class.newInstanc e(Unknown Source)
[java] at org.eclipse.osgi.framework .internal. core.Abstr actBundle. loadBundle Activator( AbstractBu ndle.java: 136)
[java] ... 41 more
[java] Java Result: 2
How am I getting this error?
thank you for your time
Slider
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.test/testframework.html?revision=1.4
I have written a test.xml file for my plug-in which uses the org.eclipse.test library.xml file run the suite and generate a report.
When I run the script I get the following error:
"org.osgi.framework.Bundle
"Caused by: java.lang.InstantiationExc
however the the class in-question is not an interface or abstract
Below is the class:
package com.propylon.core.tests;
import org.eclipse.core.runtime.P
import org.osgi.framework.BundleC
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends Plugin {
// The plug-in ID
public static final String PLUGIN_ID = "com.propylon.core.tests";
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.P
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.P
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}
below is the stacktrace:
java-test:
[echo] Running com.propylon.core.tests.te
[java] org.osgi.framework.BundleE
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.core.runtime.i
[java] at org.eclipse.osgi.baseadapt
[java] at org.eclipse.osgi.internal.
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.internal.
[java] at java.lang.ClassLoader.load
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.test.EclipseTe
[java] at org.eclipse.test.EclipseTe
[java] at org.eclipse.test.EclipseTe
[java] at org.eclipse.test.EclipseTe
[java] at org.eclipse.test.CoreTestA
[java] at org.eclipse.test.CoreTestA
[java] at sun.reflect.NativeMethodAc
[java] at sun.reflect.NativeMethodAc
[java] at sun.reflect.DelegatingMeth
[java] at java.lang.reflect.Method.i
[java] at org.eclipse.equinox.intern
[java] at org.eclipse.equinox.intern
[java] at org.eclipse.core.runtime.i
[java] at org.eclipse.core.runtime.i
[java] at org.eclipse.core.runtime.a
[java] at org.eclipse.core.runtime.a
[java] at sun.reflect.NativeMethodAc
[java] at sun.reflect.NativeMethodAc
[java] at sun.reflect.DelegatingMeth
[java] at java.lang.reflect.Method.i
[java] at org.eclipse.equinox.launch
[java] at org.eclipse.equinox.launch
[java] at org.eclipse.equinox.launch
[java] at org.eclipse.equinox.launch
[java] at org.eclipse.core.launcher.
[java] Caused by: java.lang.InstantiationExc
[java] at sun.reflect.InstantiationE
[java] at java.lang.reflect.Construc
[java] at java.lang.Class.newInstanc
[java] at java.lang.Class.newInstanc
[java] at org.eclipse.osgi.framework
[java] ... 41 more
[java] Java Result: 2
How am I getting this error?
thank you for your time
Slider
ASKER
I am not implementing the tutorial, instead I am applying it to my own problem. I have written a test.xml to run my plugin. The test.xml uses the library.xml in the org.eclipse.test plugin to run the tests and generate a report.
My JUnit tests must be inside a plugin, where does it say not have unit tests in a plugin?
My JUnit tests must be inside a plugin, where does it say not have unit tests in a plugin?
ASKER
I trying to activate a plugin that runs a JUnit test suite using an Ant script. However I keep getting an error
"The activator org.eclipse.core.runtime.P lugin for bundle com.propylon.core.Test is invalid"
"Caused by: java.lang.InstantiationExc eption"
Thrown when an application tries to create an instance of a class using the newInstance method in class Class, but the specified class object cannot be instantiated because it is an interface or is an abstract class.
Somewhere the Class.newInstance() method is being invoked on Plugin (the abstract class) rather than Activator (the non-abstract one), why?
I created the plugin project using the eclispe wizard this its the Activator class it generated
package com.propylon.core.test;
import org.eclipse.core.runtime.P lugin;
import org.osgi.framework.BundleC ontext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends Plugin {
// The plug-in ID
public static final String PLUGIN_ID = "com.propylon.core.Test";
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.P lugins#sta rt(org.osg i.framewor k.BundleCo ntext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.P lugin#stop (org.osgi. framework. BundleCont ext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}
below is the stack trance:
java-test:
[echo] Running com.propylon.core.tests.te stcase.All Tests. Result file: C:/eclipse3.3/results/com. propylon.c ore.tests. testcase.A llTests.xm l.
[java] org.osgi.framework.BundleE xception: The activator org.eclipse.core.runtime.P lugin for bundle com.propylon.core.Test is invalid
[java] at org.eclipse.osgi.framework .internal. core.Abstr actBundle. loadBundle Activator( AbstractBu ndle.java: 141)
[java] at org.eclipse.osgi.framework .internal. core.Bundl eContextIm pl.start(B undleConte xtImpl.jav a:970)
[java] at org.eclipse.osgi.framework .internal. core.Bundl eHost.star tWorker(Bu ndleHost.j ava:346)
[java] at org.eclipse.osgi.framework .internal. core.Abstr actBundle. start(Abst ractBundle .java:260)
[java] at org.eclipse.osgi.framework .util.Secu reAction.s tart(Secur eAction.ja va:400)
[java] at org.eclipse.core.runtime.i nternal.ad aptor.Ecli pseLazySta rter.postF indLocalCl ass(Eclips eLazyStart er.java:11 1)
[java] at org.eclipse.osgi.baseadapt or.loader. ClasspathM anager.fin dLocalClas s(Classpat hManager.j ava:417)
[java] at org.eclipse.osgi.internal. baseadapto r.DefaultC lassLoader .findLocal Class(Defa ultClassLo ader.java: 189)
[java] at org.eclipse.osgi.framework .internal. core.Bundl eLoader.fi ndLocalCla ss(BundleL oader.java :340)
[java] at org.eclipse.osgi.framework .internal. core.Bundl eLoader.fi ndClassInt ernal(Bund leLoader.j ava:408)
[java] at org.eclipse.osgi.framework .internal. core.Bundl eLoader.fi ndClass(Bu ndleLoader .java:369)
[java] at org.eclipse.osgi.framework .internal. core.Bundl eLoader.fi ndClass(Bu ndleLoader .java:357)
[java] at org.eclipse.osgi.internal. baseadapto r.DefaultC lassLoader .loadClass (DefaultCl assLoader. java:83)
[java] at java.lang.ClassLoader.load Class(Unkn own Source)
[java] at org.eclipse.osgi.framework .internal. core.Bundl eLoader.lo adClass(Bu ndleLoader .java:289)
[java] at org.eclipse.osgi.framework .internal. core.Bundl eHost.load Class(Bund leHost.jav a:227)
[java] at org.eclipse.osgi.framework .internal. core.Abstr actBundle. loadClass( AbstractBu ndle.java: 1269)
[java] at org.eclipse.test.EclipseTe stRunner.l oadSuiteCl ass(Eclips eTestRunne r.java:302 )
[java] at org.eclipse.test.EclipseTe stRunner.g etTest(Ecl ipseTestRu nner.java: 233)
[java] at org.eclipse.test.EclipseTe stRunner.< init>(Ecli pseTestRun ner.java:2 16)
[java] at org.eclipse.test.EclipseTe stRunner.r un(Eclipse TestRunner .java:200)
[java] at org.eclipse.test.CoreTestA pplication .runTests( CoreTestAp plication. java:35)
[java] at org.eclipse.test.CoreTestA pplication .run(CoreT estApplica tion.java: 31)
[java] at sun.reflect.NativeMethodAc cessorImpl .invoke0(N ative Method)
[java] at sun.reflect.NativeMethodAc cessorImpl .invoke(Un known Source)
[java] at sun.reflect.DelegatingMeth odAccessor Impl.invok e(Unknown Source)
[java] at java.lang.reflect.Method.i nvoke(Unkn own Source)
[java] at org.eclipse.equinox.intern al.app.Ecl ipseAppCon tainer.cal lMethod(Ec lipseAppCo ntainer.ja va:533)
[java] at org.eclipse.equinox.intern al.app.Ecl ipseAppHan dle.run(Ec lipseAppHa ndle.java: 155)
[java] at org.eclipse.core.runtime.i nternal.ad aptor.Ecli pseAppLaun cher.runAp plication( EclipseApp Launcher.j ava:106)
[java] at org.eclipse.core.runtime.i nternal.ad aptor.Ecli pseAppLaun cher.start (EclipseAp pLauncher. java:76)
[java] at org.eclipse.core.runtime.a daptor.Ecl ipseStarte r.run(Ecli pseStarter .java:363)
[java] at org.eclipse.core.runtime.a daptor.Ecl ipseStarte r.run(Ecli pseStarter .java:176)
[java] at sun.reflect.NativeMethodAc cessorImpl .invoke0(N ative Method)
[java] at sun.reflect.NativeMethodAc cessorImpl .invoke(Un known Source)
[java] at sun.reflect.DelegatingMeth odAccessor Impl.invok e(Unknown Source)
[java] at java.lang.reflect.Method.i nvoke(Unkn own Source)
[java] at org.eclipse.equinox.launch er.Main.in vokeFramew ork(Main.j ava:504)
[java] at org.eclipse.equinox.launch er.Main.ba sicRun(Mai n.java:443 )
[java] at org.eclipse.equinox.launch er.Main.ru n(Main.jav a:1169)
[java] at org.eclipse.equinox.launch er.Main.ma in(Main.ja va:1144)
[java] at org.eclipse.core.launcher. Main.main( Main.java: 30)
[java] Caused by: java.lang.InstantiationExc eption
[java] at sun.reflect.InstantiationE xceptionCo nstructorA ccessorImp l.newInsta nce(Unknow n Source)
[java] at java.lang.reflect.Construc tor.newIns tance(Unkn own Source)
[java] at java.lang.Class.newInstanc e0(Unknown Source)
[java] at java.lang.Class.newInstanc e(Unknown Source)
[java] at org.eclipse.osgi.framework .internal. core.Abstr actBundle. loadBundle Activator( AbstractBu ndle.java: 136)
[java] ... 41 more
[java] Java Result: 2
Has anyone come across this problem before? Do I need to change some setting in eclipse or modify may activator class?
Thank you for your time
slider
"The activator org.eclipse.core.runtime.P
"Caused by: java.lang.InstantiationExc
Thrown when an application tries to create an instance of a class using the newInstance method in class Class, but the specified class object cannot be instantiated because it is an interface or is an abstract class.
Somewhere the Class.newInstance() method is being invoked on Plugin (the abstract class) rather than Activator (the non-abstract one), why?
I created the plugin project using the eclispe wizard this its the Activator class it generated
package com.propylon.core.test;
import org.eclipse.core.runtime.P
import org.osgi.framework.BundleC
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends Plugin {
// The plug-in ID
public static final String PLUGIN_ID = "com.propylon.core.Test";
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.P
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.P
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}
below is the stack trance:
java-test:
[echo] Running com.propylon.core.tests.te
[java] org.osgi.framework.BundleE
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.core.runtime.i
[java] at org.eclipse.osgi.baseadapt
[java] at org.eclipse.osgi.internal.
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.internal.
[java] at java.lang.ClassLoader.load
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.osgi.framework
[java] at org.eclipse.test.EclipseTe
[java] at org.eclipse.test.EclipseTe
[java] at org.eclipse.test.EclipseTe
[java] at org.eclipse.test.EclipseTe
[java] at org.eclipse.test.CoreTestA
[java] at org.eclipse.test.CoreTestA
[java] at sun.reflect.NativeMethodAc
[java] at sun.reflect.NativeMethodAc
[java] at sun.reflect.DelegatingMeth
[java] at java.lang.reflect.Method.i
[java] at org.eclipse.equinox.intern
[java] at org.eclipse.equinox.intern
[java] at org.eclipse.core.runtime.i
[java] at org.eclipse.core.runtime.i
[java] at org.eclipse.core.runtime.a
[java] at org.eclipse.core.runtime.a
[java] at sun.reflect.NativeMethodAc
[java] at sun.reflect.NativeMethodAc
[java] at sun.reflect.DelegatingMeth
[java] at java.lang.reflect.Method.i
[java] at org.eclipse.equinox.launch
[java] at org.eclipse.equinox.launch
[java] at org.eclipse.equinox.launch
[java] at org.eclipse.equinox.launch
[java] at org.eclipse.core.launcher.
[java] Caused by: java.lang.InstantiationExc
[java] at sun.reflect.InstantiationE
[java] at java.lang.reflect.Construc
[java] at java.lang.Class.newInstanc
[java] at java.lang.Class.newInstanc
[java] at org.eclipse.osgi.framework
[java] ... 41 more
[java] Java Result: 2
Has anyone come across this problem before? Do I need to change some setting in eclipse or modify may activator class?
Thank you for your time
slider
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
link, it suggests not to - the existing plugin should work as-is.