I wanted MANIFEST.MF file actually :/ On Fri, Oct 12, 2012 at 5:35 AM, Cook, Michael J. (OCTO) < [email protected]> wrote:
> Hmmm... > > Here's my metadata.xml... > > I get the following error: > > [ERROR] IPOJO-Extender : Cannot instantiate an abstract factory from > org.apache.felix.ipojo.ComponentFactory > org.apache.felix.ipojo.ConfigurationException: A component needs a class > name : component immediate="true" > at > org.apache.felix.ipojo.ComponentFactory.check(ComponentFactory.java:145) > at > org.apache.felix.ipojo.ComponentFactory.<init>(ComponentFactory.java:121) > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) > at > sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcce > ssorImpl.java:39) > at > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstru > ctorAccessorImpl.java:27) > at java.lang.reflect.Constructor.newInstance(Constructor.java:513) > at > org.apache.felix.ipojo.Extender.createAbstractFactory(Extender.java:500) > at org.apache.felix.ipojo.Extender.parse(Extender.java:301) > at org.apache.felix.ipojo.Extender.startManagementFor(Extender.java:237) > at org.apache.felix.ipojo.Extender.access$600(Extender.java:52) > at org.apache.felix.ipojo.Extender$CreatorThread.run(Extender.java:769) > at java.lang.Thread.run(Thread.java:680) > > > Here's what I had for the Bogus Class case on the metadata.xml: > > <ipojo> > <component className="cook.michael.BogusClass"/> > </ipojo> > > > > Mike > > > > On 10/11/12 10:23 PM, "Göktürk Gezer" <[email protected]> wrote: > > >Just to be on the same page I installed eclipse-ipojo-plugin too. > > > >First finding : you don't need a bogus component. You can just type > ><ipojo> > ><component/> > ></ipojo> > > > >inside you metadata.xml and it'll pass silently. > > > >Besides you might be hitting a bug we've fixed in trunk, because in the > >same scenario I suggested to you I saw some elements in MANIFEST which > >shouldn't be there. > >Could you share me your MANIFEST for the final state(bogus metadata.xml + > >annotations)? > > > >On Fri, Oct 12, 2012 at 5:05 AM, Cook, Michael J. (OCTO) < > >[email protected]> wrote: > > > >> Hi, > >> > >> >>Could you tell me what happens when you remove the <ipojo/> element > >>too > >> >>leaving the metadata.xml empty? > >> > >> > >> I get an error when there is no contents in the metadata.xml file. > >> > >> >>I could suggest you a trick to define a bogus > >> >>component inside metadata.xml(Will require you to maintain a bogus > >>class) > >> >>so that eclipse-ipojo-plugin will not fail on metadata.xml and move > >>along > >> >>its way with annotations. > >> > >> > >> I added a bogus class into the cook.michael package and put the > >> @Component/@Instantiate/@Validate/@Invalidate back into the code. Then > >> added this component to the metadata.xml file: > >> <ipojo> > >> <component className="cook.michael.BogusClass"/> > >> </ipojo> > >> > >> > >> > >> The above results in the start and stop not being invoked. > >> > >> >>Instead of embedding Felix into eclipse you can use its own Equinox > >> >>launcher. > >> > >> I'm developing atop Felix, because the target device is Felix based, so > >>I > >> would like to keep it on the same platform. > >> > >> > >> Thank you for your help. > >> Mike > >> > >> > >> On 10/11/12 9:47 PM, "Göktürk Gezer" <[email protected]> wrote: > >> > >> >On Fri, Oct 12, 2012 at 4:25 AM, Cook, Michael J. (OCTO) < > >> >[email protected]> wrote: > >> > > >> >> Göktürk, > >> >> > >> >> Thank you! I used #2 below and it worked well. I was able to launch > >>the > >> >> bundle, and I saw it output the traces I had been looking for. > >> >> > >> > > >> >Cool ! > >> > > >> > > >> >> > >> >> On the first, if I remove the contents of the metadata.xml file, how > >> >>can I > >> >> use iPOJO to generate the bundle? If I leave in the <ipojo/> > >>element, > >> >>and > >> >> I run iPOJO's "Create Bundle", I get a warning: "Neither component > >> >>types, > >> >> nor instances in /Users/mcook008/Workspaces/MyEclipse > >> >> 8.6/iPojoTest/metadata.xml". Start and stop are not called, although > >>the > >> >> class is marked with @Component and @Instantiate and start/stop is > >> >>marked > >> >> with @Validate/@Invalidate. > >> >> > >> > > >> >Well, I actually never used eclipse-ipojo-plugin before but it seems > >>to be > >> >dependent on metadata.xml but also sees the annotations on its way. > >> > > >> >Could you tell me what happens when you remove the <ipojo/> element too > >> >leaving the metadata.xml empty? > >> > >> > > >> >If above trick didn't work and you want to stick with > >>eclipse-ipojo-plugin > >> >while using annotations. I could suggest you a trick to define a bogus > >> >component inside metadata.xml(Will require you to maintain a bogus > >>class) > >> >so that eclipse-ipojo-plugin will not fail on metadata.xml and move > >>along > >> >its way with annotations. > >> > > >> >Also it seems to me that your development environment is heavy. > >>Instead of > >> >embedding Felix into eclipse you can use its own Equinox launcher. > >> >I suggest you to have a look at > >> > >>> > http://felix.apache.org/site/apache-felix-ipojo-eclipse-integration.html > >> >where > >> >you can see basic setup.(You can use annotations or metadata of your > >> >choice > >> >in this setup) > >> > > >> > > >> >Gokturk > >> > > >> > > >> >> > >> >> Mike > >> >> > >> >> > >> >> > >> >> On 10/11/12 8:54 PM, "Göktürk Gezer" <[email protected]> > wrote: > >> >> > >> >> >Well i thought at first that you didn't specify metadata.xml but i > >>see > >> >>now > >> >> >that you did. Mixing metadata.xml and annotations for one single > >> >>component > >> >> >is a mistake. For same component you must go with one of them. > >> >> > > >> >> >So there are 2 different ways for you: > >> >> > > >> >> >1- Using only annotations: Just disable the metadata.xml (easily > >> >>delete it > >> >> >or comment out the content ) and leave the annotations as it is. > >> >> >2- Using only medata.xml: If you want to use metadata.xml then > >>remove > >> >>all > >> >> >annotations including @validate and @invalidate and make sure your > >> >> >metadata.xml looks like this: > >> >> > > >> >> ><ipojo> > >> >> ><component className="cook.michael.MyComponentImpl"> > >> >> > <callback transition="validate" method="start"/> > >> >> > <callback transition="invalidate" method="stop"/> > >> >> ></component> > >> >> ><instance component="cook.michael.MyComponentImpl"/> > >> >> ></ipojo> > >> >> > > >> >> >Either way should bring you where you want. Just don't mix > >>annotation > >> >>and > >> >> >metadata usage for same component. > >> >> > > >> >> >Regards, > >> >> >Gokturk > >> >> > > >> >> > > >> >> > > >> >> >On Fri, Oct 12, 2012 at 3:32 AM, Cook, Michael J. (OCTO) < > >> >> >[email protected]> wrote: > >> >> > > >> >> >> Hi Göktürk, > >> >> >> > >> >> >> OK... Tried that. Still the same thing. There's not much to my > >> >>code, > >> >> >>so > >> >> >> I'm including it below. Please let me know if you see anything. > >> >> >> > >> >> >> Thank you for helping me, > >> >> >> Mike > >> >> >> > >> >> >> > >> >> >> MyComponentImpl.java: > >> >> >> > >> >> >> package cook.michael; > >> >> >> > >> >> >> import java.io.BufferedWriter; > >> >> >> import java.io.File; > >> >> >> import java.io.FileWriter; > >> >> >> import java.io.IOException; > >> >> >> > >> >> >> import org.apache.felix.ipojo.annotations.Component; > >> >> >> import org.apache.felix.ipojo.annotations.Invalidate; > >> >> >> import org.apache.felix.ipojo.annotations.Validate; > >> >> >> import org.apache.felix.ipojo.annotations.Instantiate; > >> >> >> > >> >> >> @Component > >> >> >> @Instantiate > >> >> >> public class MyComponentImpl { > >> >> >> > >> >> >> @Validate > >> >> >> public void start() throws IOException { > >> >> >> System.err.println("Starting: " ); > >> >> >> > >> >> >> System.out.println("I'm starting..."); > >> >> >> try{ > >> >> >> // Create file > >> >> >> FileWriter fstream = new > >> >> >>FileWriter("/Users/mcook008/out.txt"); > >> >> >> BufferedWriter out = new BufferedWriter(fstream); > >> >> >> out.write("Hello Java"); > >> >> >> //Close the output stream > >> >> >> out.close(); > >> >> >> }catch (Exception e){//Catch exception if any > >> >> >> System.err.println("Error: " + e.getMessage()); > >> >> >> } > >> >> >> throw new IOException() ; > >> >> >> } > >> >> >> > >> >> >> @Invalidate > >> >> >> public void stop() { > >> >> >> System.out.println("I'm leaving !"); > >> >> >> } > >> >> >> } > >> >> >> > >> >> >> > >> >> >> metadata.xml: > >> >> >> > >> >> >> <ipojo> > >> >> >> <component className="cook.michael.MyComponentImpl"/> > >> >> >> <instance component="cook.michael.MyComponentImpl"/> > >> >> >> </ipojo> > >> >> >> > >> >> >> > >> >> >> > >> >> >> iPojoTest.bnd: > >> >> >> > >> >> >> Import-Package: * > >> >> >> Export-Package: * > >> >> >> #Private-Package: > >> >> >> > >> >> >> > >> >> >> Generated manefest.mf: > >> >> >> > >> >> >> Manifest-Version: 1.0 > >> >> >> Export-Package: > >> >>org.apache.felix.ipojo.handler.temporal,org.apache.fel > >> >> >> > >> >>ix.ipojo.transaction,org.apache.felix.ipojo.extender,org.apache.felix > >> >> >> > >> >>.ipojo.whiteboard,org.apache.felix.ipojo.handlers.event,org.apache.fe > >> >> >> > >> >>lix.ipojo.handlers.jmx,org.apache.felix.ipojo.annotations,cook.michae > >> >> >> l > >> >> >> iPOJO-Components: component { > >> >>$classname="cook.michael.MyComponentImpl > >> >> >> " manipulation { method { $name="$init" }method { $name="start" > >> >>}meth > >> >> >> od { $name="stop" }}}instance { > >> >>$component="cook.michael.MyComponentI > >> >> >> mpl" }component { $name="cook.michael.MyComponentImpl" > >> >>$classname="co > >> >> >> ok.michael.MyComponentImpl" $public="true" > >> >>org.apache.felix.ipojo.ann > >> >> >> otations:instantiate { }callback { $transition="invalidate" > >> >>$method=" > >> >> >> stop" }callback { $transition="validate" $method="start" > >> >>}manipulatio > >> >> >> n { method { $name="$init" }method { $name="start" }method { > >> >>$name="s > >> >> >> top" }}} > >> >> >> Built-By: clement > >> >> >> Tool: Bnd-0.0.249 > >> >> >> Bundle-Name: Apache Felix iPOJO Annotations > >> >> >> Created-By: 1.6.0_35 (Apple Inc.) & iPOJO > >> >> >> Bundle-Vendor: The Apache Software Foundation > >> >> >> Bundle-Version: 1.8.2 > >> >> >> Build-Jdk: 1.6.0_31 > >> >> >> Bnd-LastModified: 1350001458935 > >> >> >> Bundle-ManifestVersion: 2 > >> >> >> Bundle-Description: iPOJO Annotations > >> >> >> Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt > >> >> >> Bundle-DocURL: > >> >>http://felix.apache.org/site/how-to-use-ipojo-annotatio > >> >> >> ns.html > >> >> >> Import-Package: org.osgi.service.log;version=1.3, > >> >>org.apache.felix.ipo > >> >> >> jo.handler.temporal, org.apache.felix.ipojo.transaction, > >> >>org.apache.f > >> >> >> elix.ipojo.architecture;version=0.9.0, > >> >>org.apache.felix.ipojo.extende > >> >> >> r, org.apache.felix.ipojo.whiteboard, > >> >>org.apache.felix.ipojo;version= > >> >> >> 0.9.0, org.apache.felix.ipojo.handlers.event, > >> >>org.apache.felix.ipojo. > >> >> >> handlers.jmx, org.osgi.service.cm;version=1.2, > >> >>org.apache.felix.ipojo > >> >> >> .annotations, cook.michael > >> >> >> Bundle-SymbolicName: iPojoTest > >> >> >> Originally-Created-By: Apache Maven Bundle Plugin > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> On 10/11/12 7:54 PM, "Göktürk Gezer" <[email protected]> > >> wrote: > >> >> >> > >> >> >> >Hi, > >> >> >> > > >> >> >> >First of all @Component is mandatory.(For annotation based > >>usage). > >> >> >> > > >> >> >> >But this only defines your component. To actually instantiate it > >>you > >> >> >> >should > >> >> >> >do it deliberately. One way to do that is using @Instantiate > >> >> >>annotation. > >> >> >> > > >> >> >> >So your code would be like: > >> >> >> > > >> >> >> >@Component > >> >> >> >@Instantiate > >> >> >> >public class foo{ > >> >> >> > > >> >> >> > @Validate > >> >> >> > public void start() > >> >> >> >.......... > >> >> >> >.......... > >> >> >> >} > >> >> >> > > >> >> >> >On Fri, Oct 12, 2012 at 1:00 AM, Cook, Michael J. (OCTO) < > >> >> >> >[email protected]> wrote: > >> >> >> > > >> >> >> >> Sorry. Just rechecked. Used @ Component on the class. And > >> >> >> >> @Invalidate/@validate on the methods. Just tried removing the > >> >> >> >>@Component. > >> >> >> >> Same result. No output. > >> >> >> >> > >> >> >> >> Mike > >> >> >> >> Michael Cook > >> >> >> >> VP Technology Innovation > >> >> >> >> Comcast > >> >> >> >> One Comcast Center > >> >> >> >> Philadelphia, PA 19103 > >> >> >> >> (o) 215-286-8260 > >> >> >> >> (m) 609-458-0332 > >> >> >> >> > >> >> >> >> ----- Original Message ----- > >> >> >> >> From: Cook, Michael J. (OCTO) > >> >> >> >> Sent: Thursday, October 11, 2012 05:47 PM > >> >> >> >> To: '[email protected]' <[email protected]> > >> >> >> >> Subject: Re: Getting Started with iPOJO > >> >> >> >> > >> >> >> >> I used @validate/@invalidate alone. > >> >> >> >> > >> >> >> >> Mike > >> >> >> >> > >> >> >> >> Michael Cook > >> >> >> >> VP Technology Innovation > >> >> >> >> Comcast > >> >> >> >> One Comcast Center > >> >> >> >> Philadelphia, PA 19103 > >> >> >> >> (o) 215-286-8260 > >> >> >> >> (m) 609-458-0332 > >> >> >> >> > >> >> >> >> ----- Original Message ----- > >> >> >> >> From: Göktürk Gezer [mailto:[email protected]] > >> >> >> >> Sent: Thursday, October 11, 2012 05:39 PM > >> >> >> >> To: [email protected] <[email protected]> > >> >> >> >> Subject: Re: Getting Started with iPOJO > >> >> >> >> > >> >> >> >> Hi, > >> >> >> >> > >> >> >> >> I need to ask this first since it's not on your code snippet: > >>Did > >> >>you > >> >> >> >>use > >> >> >> >> @Component annotation for class where you've declared your > >>start() > >> >> >> >>stop() > >> >> >> >> methods? Or did you use @Validate,@Invalidate alone? > >> >> >> >> > >> >> >> >> > >> >> >> >> *Regards,* > >> >> >> >> *Gokturk* > >> >> >> >> > >> >> >> >> On Thu, Oct 11, 2012 at 8:13 PM, Cook, Michael J. (OCTO) < > >> >> >> >> [email protected]> wrote: > >> >> >> >> > >> >> >> >> > Hi, > >> >> >> >> > > >> >> >> >> > I can't seem to find a good article that will help me resolve > >> >>the > >> >> >> >> "getting > >> >> >> >> > started" issue I am facing. > >> >> >> >> > > >> >> >> >> > I am using Eclipse Juno (4.2) on my Mac. > >> >> >> >> > > >> >> >> >> > I have downloaded and installed the iPOJO eclipse plugin, > >>from: > >> >> >> >> > http://clement.plop-plop.net/update/ > >> >> >> >> > > >> >> >> >> > I have created a sample project following the instructions > >>at: > >> >> >> >> > http://felix.apache.org/site/ipojo-eclipse-plug-in.html > >> >> >> >> > > >> >> >> >> > I have integrated Felix into Eclipse as a project, following > >> >> >> >>instructions > >> >> >> >> > here: > >> >> >> http://felix.apache.org/site/integrating-felix-with-eclipse.html > >> >> >> >> > > >> >> >> >> > I have downloaded the following iPOJO bundle: > >> >> >> >> > org.apache.felix.ipojo-1.8.2.jar > >> >> >> >> > > >> >> >> >> > I've launched Felix in the Eclipse console and I've installed > >> >>the > >> >> >> >> > org.apache.felix.ipojo-1.8.2.jar bundle and started it. > >> >> >> >> > > >> >> >> >> > I've created a test bundle using iPOJO called iPojoTest.jar > >>and > >> >> >>I've > >> >> >> >> > installed it and started it in the OSGI console. > >> >> >> >> > > >> >> >> >> > I run bundles in the console and I get: > >> >> >> >> > > >> >> >> >> > g! bundles > >> >> >> >> > > >> >> >> >> > 0|Active | 0|org.apache.felix.framework (3.0.7) > >> >> >> >> > > >> >> >> >> > 1|Active | 1|org.apache.felix.bundlerepository > >> >>(1.6.2) > >> >> >> >> > > >> >> >> >> > 2|Active | 1|org.apache.felix.gogo.command (0.6.1) > >> >> >> >> > > >> >> >> >> > 3|Active | 1|org.apache.felix.gogo.runtime (0.6.1) > >> >> >> >> > > >> >> >> >> > 4|Active | 1|org.apache.felix.gogo.shell (0.6.1) > >> >> >> >> > > >> >> >> >> > 12|Active | 1|iPojoTest (1.4.0) > >> >> >> >> > > >> >> >> >> > 13|Active | 1|org.apache.felix.ipojo (1.8.2) > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > So, the bundle seems to have started. > >> >> >> >> > > >> >> >> >> > But I don't get any console output from my sysoutsŠ > >> >> >> >> > > >> >> >> >> > Here are the start() and stop() methods: > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > @Validate > >> >> >> >> > > >> >> >> >> > public void start() throws IOException { > >> >> >> >> > > >> >> >> >> > System.out.println("I'm starting..."); > >> >> >> >> > > >> >> >> >> > try{ > >> >> >> >> > > >> >> >> >> > // Create file > >> >> >> >> > > >> >> >> >> > FileWriter fstream = new > >> >> >> >> > FileWriter("/Users/mcook008/out.txt"); > >> >> >> >> > > >> >> >> >> > BufferedWriter out = new > >> >>BufferedWriter(fstream); > >> >> >> >> > > >> >> >> >> > out.write("Hello Java"); > >> >> >> >> > > >> >> >> >> > //Close the output stream > >> >> >> >> > > >> >> >> >> > out.close(); > >> >> >> >> > > >> >> >> >> > }catch (Exception e){//Catch exception if > >>any > >> >> >> >> > > >> >> >> >> > System.err.println("Error: " + > >> >>e.getMessage()); > >> >> >> >> > > >> >> >> >> > } > >> >> >> >> > > >> >> >> >> > throw new IOException() ; > >> >> >> >> > > >> >> >> >> > } > >> >> >> >> > > >> >> >> >> > @Invalidate > >> >> >> >> > > >> >> >> >> > public void stop() { > >> >> >> >> > > >> >> >> >> > System.out.println("I'm leaving !"); > >> >> >> >> > > >> >> >> >> > } > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > I added in the file write to see if a file would be created. > >> >>There > >> >> >> >>is no > >> >> >> >> > file created. So, while OSGi thinks the bundle is ACTIVE, > >>the > >> >> >>start > >> >> >> >> method > >> >> >> >> > appears never have to been called. > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > Can anyone tell me what I may have done wrong or provide a > >>clue > >> >>as > >> >> >>to > >> >> >> >> what > >> >> >> >> > to look at to help diagnose the problem? > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > Thanks, > >> >> >> >> > > >> >> >> >> > Mike > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > >> >> >> > >> >> >> > >> >> >> > >>--------------------------------------------------------------------- > >> >> >> To unsubscribe, e-mail: [email protected] > >> >> >> For additional commands, e-mail: [email protected] > >> >> >> > >> >> >> > >> >> > >> >> > >> >> --------------------------------------------------------------------- > >> >> To unsubscribe, e-mail: [email protected] > >> >> For additional commands, e-mail: [email protected] > >> >> > >> >> > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [email protected] > >> For additional commands, e-mail: [email protected] > >> > >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >

