felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fabiolf <fabio.l.fons...@gmail.com>
Subject Re: Using iPOJO API to create components and instances
Date Sun, 15 Apr 2012 00:41:17 GMT
Hi Clement,

I did as you said and I was surely doing something wrong because now the
error changed. My code now is:


		Bundle bundle = m_context.getBundle(21);
		BundleContext localContext = bundle.getBundleContext();
		try {
			System.out.println("myType");

			new PrimitiveComponentType()
			.setBundleContext(localContext)
			.setClassName(ProviderA.class.getName())
			.setValidateMethod("start")
			.setInvalidateMethod("stop")
			.addService(new Service())
			.createInstance("TestProviderA");
                  [...]

The bundle 21 is the one that has the TestProviderA class. I'm getting the
following error:

[ERROR] org.test.iPOJO.providerA.ProviderA : org/apache/felix/ipojo/Pojo
java.lang.NoClassDefFoundError: org/apache/felix/ipojo/Pojo
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
	at
org.apache.felix.ipojo.ComponentFactory$FactoryClassloader.defineClass(ComponentFactory.java:501)
	at
org.apache.felix.ipojo.ComponentFactory.defineClass(ComponentFactory.java:215)
	at
org.apache.felix.ipojo.ComponentFactory.loadClass(ComponentFactory.java:244)
	at org.apache.felix.ipojo.InstanceManager.load(InstanceManager.java:575)
	at
org.apache.felix.ipojo.InstanceManager.getClazz(InstanceManager.java:887)
	at org.apache.felix.ipojo.util.Callback.searchMethod(Callback.java:164)
	at org.apache.felix.ipojo.util.Callback.call(Callback.java:223)
	at org.apache.felix.ipojo.util.Callback.call(Callback.java:193)
	at
org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallback.call(LifecycleCallback.java:86)
	at
org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__stateChanged(LifecycleCallbackHandler.java:162)
	at
org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
	at
org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:472)
	at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:354)
	at
org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:178)
	at
org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:301)
	at
org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:238)
	at
org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:99)
	at
org.test.iPOJO.fabioManipulator.FabioManipulatorCmdImpl.create(FabioManipulatorCmdImpl.java:80)
	at
org.test.iPOJO.fabioManipulator.FabioManipulatorCmdImpl.execute(FabioManipulatorCmdImpl.java:61)
	at
org.apache.felix.shell.impl.Activator$ShellServiceImpl.executeCommand(Activator.java:286)
	at
org.apache.felix.shell.tui.Activator$ShellTuiRunnable.run(Activator.java:184)
	at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.ClassNotFoundException: org.apache.felix.ipojo.Pojo not
found by org.test.iPOJO.providerA [21]
	at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)
	at
org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)
	at
org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1723)
	at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:926)
	at
org.apache.felix.ipojo.ComponentFactory$FactoryClassloader.loadClass(ComponentFactory.java:528)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	... 25 more
[ERROR] org.test.iPOJO.providerA.ProviderA : org/apache/felix/ipojo/Pojo
org.apache.felix.ipojo.ConfigurationException: The configuration is not
correct for the type org.test.iPOJO.providerA.ProviderA :
org/apache/felix/ipojo/Pojo
	at
org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:308)
	at
org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:238)
	at
org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:99)
	at
org.test.iPOJO.fabioManipulator.FabioManipulatorCmdImpl.create(FabioManipulatorCmdImpl.java:80)
	at
org.test.iPOJO.fabioManipulator.FabioManipulatorCmdImpl.execute(FabioManipulatorCmdImpl.java:61)
	at
org.apache.felix.shell.impl.Activator$ShellServiceImpl.executeCommand(Activator.java:286)
	at
org.apache.felix.shell.tui.Activator$ShellTuiRunnable.run(Activator.java:184)
	at java.lang.Thread.run(Thread.java:680)

I saw that the class org.apache.felix.ipojo.Pojo can be found in the iPOJO
bundle and I'm with it started as you can see below:

-> ps
START LEVEL 1
   ID   State         Level  Name
[   0] [Active     ] [    0] System Bundle (4.0.2)
[   1] [Active     ] [    1] Apache Felix Bundle Repository (1.6.6)
[   2] [Active     ] [    1] Apache Felix iPOJO (1.9.0.SNAPSHOT)
[   3] [Active     ] [    1] Apache Felix iPOJO API (1.7.0.SNAPSHOT)
[   4] [Active     ] [    1] Apache Felix iPOJO Arch Command
(1.7.0.SNAPSHOT)
[   5] [Active     ] [    1] Apache Felix iPOJO Composite (1.9.0.SNAPSHOT)
[   6] [Active     ] [    1] Apache Felix Shell Service (1.4.2)
[   7] [Active     ] [    1] Apache Felix Shell TUI (1.4.1)
[   8] [Active     ] [    1] Java Utils (1.0.0)
[  19] [Active     ] [    1] Fabio Manipulator (1.0.0)
[  20] [Active     ] [    1] Testing iPOJO API: Services (1.0.0)
[  21] [Active     ] [    1] Testing iPOJO API: Provider A (1.0.0)
[  22] [Active     ] [    1] Testing iPOJO API: Provider B (1.0.0)
[  23] [Active     ] [    1] Testing iPOJO API: Consumer (1.0.0)

I'm probably doing something wrong again...

Thanks a lot!
Fabio

--
View this message in context: http://apache-felix.18485.n6.nabble.com/Using-iPOJO-API-to-create-components-and-instances-tp4881802p4882641.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Mime
View raw message