You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> on 2014/03/02 19:13:36 UTC

Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”

Hey, I am trying to use iPOJO API to create component type. (I don’t want to use iPOJO Annotations).
In my bundle start method, I have the following code:
public void start(BundleContext context)
{

    ComponentType x = new PrimitiveComponentType()
            .setBundleContext(context)
            .setClassName(InstanceFactoryImpl.class.getName())
            .setValidateMethod("start")
            .setInvalidateMethod("stop");


            x.start();

            try {
                x.createInstance();
            } catch (UnacceptableConfiguration e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (MissingHandlerException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ConfigurationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            System.out.println("and we are done!");
}
InstanceFactoryImpl class is in the same package as the following:
public class InstanceFactoryImpl implements instancefactory.InstanceFactory{


    @Override
    public void start() {



    }

    @Override
    public void stop() {

    }



}
When I load my bundle to Felix framework in my java application, I get the following error:
[ERROR]  : [instancefactoryImpl.InstanceFactoryImpl-0] createInstance -> Cannot invoke the constructor (method not found) : instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
    at java.lang.Class.getConstructor0(Class.java:2715)
    at java.lang.Class.getDeclaredConstructor(Class.java:1987)
    at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
    at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
    at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
    at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
    at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
    at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
    at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
    at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
    at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
    at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
    at instancefactoryImpl.Activator.start(Activator.java:37)
    at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
    at embedder.HostApplication.<init>(HostApplication.java:148)
    at embedder.Embedder.main(Embedder.java:12)
[ERROR] instancefactoryImpl.InstanceFactoryImpl : Cannot create a POJO instance, the POJO constructor cannot be found
org.apache.felix.ipojo.ConfigurationException: The configuration is not correct for the type instancefactoryImpl.InstanceFactoryImpl : Cannot create a POJO instance, the POJO constructor cannot be found
    at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:328)
    at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
    at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
    at instancefactoryImpl.Activator.start(Activator.java:37)
    at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
    at embedder.HostApplication.<init>(HostApplication.java:148)
    at embedder.Embedder.main(Embedder.java:12)
Caused by: org.apache.felix.ipojo.ConfigurationException: Cannot create a POJO instance, the POJO constructor cannot be found
    at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:191)
    at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
    ... 10 more
Caused by: java.lang.RuntimeException: Cannot create a POJO instance, the POJO constructor cannot be found
    at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:766)
    at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
    at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
    at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
    at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
    at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
    at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
    ... 11 more
Caused by: java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
    at java.lang.Class.getConstructor0(Class.java:2715)
    at java.lang.Class.getDeclaredConstructor(Class.java:1987)
    at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
    ... 17 more
I am getting the error at the following line:
x.createInstance();
I tried to explicitly define a constructor, and to add a method called "init". All this failed, and the same error keeps showing. What should I do? Thanks?


Kind Regards,
Zaid Almahmoud
Research Assistant
[cid:image001.png@01CE4FB8.E6C8A910]<http://www.ebtic.org/>
Khalifa University of Science, Technology, and Research
Abu Dhabi - United Arab Emirates
TEL: 00971-2-401-8178
MOB: 00971-50-9619601


RE: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”

Posted by Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae>.
Mr. Clement, 

Would you please add your answer to my stackoverflow question: 
http://stackoverflow.com/questions/22129965/using-ipojo-api-shows-cannot-create-a-pojo-instance-the-pojo-constructor-cann

so that I give you that check! 

:D


Zaid

-----Original Message-----
From: Zaid Jamal Saeed Al Mahmoud [mailto:zaid.almahmoud@kustar.ac.ae] 
Sent: 03 آذار, 2014 07:43 م
To: users@felix.apache.org
Subject: RE: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”

Thank you very much Mr. Clement,

My issue was solved when I updated my api bundle version.

Although I found iPOJO complicated at the beginning, now I am in love with it more and more :)



Zaid

-----Original Message-----
From: Clement Escoffier [mailto:clement.escoffier@gmail.com]
Sent: 03 آذار, 2014 07:11 م
To: Apache Felix - Users Mailing List
Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”

Hi,

I’ve added a comment on the issue. It looks like you are using an outdated version of the API bundle.  

Clement


On 2 mars 2014, at 21:12, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:

> I created an issue. Here's the link:
> 
> https://issues.apache.org/jira/browse/FELIX-4443
> 
> 
> I appreciate your help.
> 
> 
> Zaid
> 
> -----Original Message-----
> From: Clement Escoffier [mailto:clement.escoffier@gmail.com]
> Sent: 02 آذار, 2014 11:16 م
> To: Apache Felix - Users Mailing List
> Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”
> 
> 
> On 2 mars 2014, at 20:06, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:
> 
>> I will send my bundle and my java project to your email address (privately) since I don't know Jira Ticket.
> 
> Jira is the bug tracker we use:
> https://issues.apache.org/jira/browse/FELIX/?selectedTab=com.atlassian
> .jira.jira-projects-plugin:summary-panel
> 
> You can create an issue, attach your code, add comments… The advantage is that you can follow the resolution of your issue. Also, other people can check the fix or turn around.
> 
> Clement
> 
>> 
>> 
>> Zaid
>> 
>> -----Original Message-----
>> From: Clement Escoffier [mailto:clement.escoffier@gmail.com]
>> Sent: 02 آذار, 2014 11:05 م
>> To: Apache Felix - Users Mailing List
>> Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”
>> 
>> 
>> On 2 mars 2014, at 19:56, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:
>> 
>>> Thank you Mr. Clement for your response.
>>> 
>>> Before trying to use manipulation, which I already done in the past. 
>>> I wanted to show you this interesting scenario,
>>> 
>>> This worked for me:
>>> 
>>> 	        new PrimitiveComponentType()
>>> 	        .setBundleContext(context)
>>> 	        .setClassName(PlainHelloImpl.class.getName())
>>> 	        .addService(new Service()) 
>>> 	        .createInstance(); // Create the instance
>>> 
>>> But this did not work for me:
>>> 
>>> 	        new PrimitiveComponentType()
>>> 	        .setBundleContext(context)
>>> 	        .setClassName(PlainHelloImpl.class.getName())
>>> 	        .createInstance(); // Create the instance
>>> 
>>> 
>>> As you can see, the only difference is adding the service. What? Why?
>> 
>> Thant’s interesting. 
>> So you mean adding the service makes it work ? 
>> Could you send me both traces.
>> 
>> Would you be able to share your code (either privately, or attached to a Jira ticket) so I can reproduce it ? 
>> 
>> Clement
>> 
>>> 
>>> 
>>> Zaid
>>> 
>>> -----Original Message-----
>>> From: Clement Escoffier [mailto:clement.escoffier@gmail.com]
>>> Sent: 02 آذار, 2014 10:48 م
>>> To: Apache Felix - Users Mailing List
>>> Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”
>>> 
>>> Hi,
>>> 
>>> When using the iPOJO API, it tries to manipulate the component implement classes at runtime (if there are not already manipulated). It looks like this manipulation does not happen in your case. To be sure it is the issue, try to manipulate the class first (add @Component on it, and use ant of maven to build your bundle). 
>>> 
>>> Clement
>>> 
>>> On 2 mars 2014, at 19:13, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:
>>> 
>>>> Hey, I am trying to use iPOJO API to create component type. (I don’t want to use iPOJO Annotations).
>>>> 
>>>> In my bundle start method, I have the following code:
>>>> 
>>>> public void start(BundleContext context) {
>>>> 
>>>>  ComponentType x = new PrimitiveComponentType()
>>>>          .setBundleContext(context)
>>>>          .setClassName(InstanceFactoryImpl.class.getName())
>>>>          .setValidateMethod("start")
>>>>          .setInvalidateMethod("stop");
>>>> 
>>>> 
>>>>          x.start();
>>>> 
>>>>          try {
>>>>              x.createInstance();
>>>>          } catch (UnacceptableConfiguration e) {
>>>>              // TODO Auto-generated catch block
>>>>              e.printStackTrace();
>>>>          } catch (MissingHandlerException e) {
>>>>              // TODO Auto-generated catch block
>>>>              e.printStackTrace();
>>>>          } catch (ConfigurationException e) {
>>>>              // TODO Auto-generated catch block
>>>>              e.printStackTrace();
>>>>          }
>>>> 
>>>>          System.out.println("and we are done!"); } 
>>>> InstanceFactoryImpl class is in the same package as the following:
>>>> public class InstanceFactoryImpl implements 
>>>> instancefactory.InstanceFactory{
>>>> 
>>>> 
>>>>  @Override
>>>>  public void start() {
>>>> 
>>>> 
>>>> 
>>>>  }
>>>> 
>>>>  @Override
>>>>  public void stop() {
>>>> 
>>>>  }
>>>> 
>>>> 
>>>> 
>>>> }
>>>> When I load my bundle to Felix framework in my java application, I get the following error:
>>>> 
>>>> [ERROR]  : [instancefactoryImpl.InstanceFactoryImpl-0]
>>>> createInstance
>>>> -> Cannot invoke the constructor (method not found) : 
>>>> instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.
>>>> InstanceManager)
>>>> java.lang.NoSuchMethodException: 
>>>> instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipo
>>>> jo.InstanceManager)  at
>>>> java.lang.Class.getConstructor0(Class.java:2715)
>>>>  at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>>>>  at
>>>> org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager
>>>> .java:726)  at
>>>> org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManage
>>>> r.java:923)  at
>>>> org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbac
>>>> kHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>>>>  at
>>>> org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbac
>>>> kHandler.stateChanged(LifecycleCallbackHandler.java)
>>>>  at
>>>> org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.jav
>>>> a:536)  at
>>>> org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:4
>>>> 18)  at
>>>> org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFac
>>>> tory.java:179)  at
>>>> org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFa
>>>> ctory.java:319)  at
>>>> org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFa
>>>> ctory.java:240)  at
>>>> org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentTy
>>>> pe.java:79)  at
>>>> instancefactoryImpl.Activator.start(Activator.java:37)
>>>>  at
>>>> org.apache.felix.framework.util.SecureAction.startActivator(SecureA
>>>> ction.java:645)  at
>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>>>>  at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>>>>  at
>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>>>>  at
>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>>>>  at embedder.HostApplication.<init>(HostApplication.java:148)
>>>>  at embedder.Embedder.main(Embedder.java:12)
>>>> [ERROR] instancefactoryImpl.InstanceFactoryImpl : Cannot create a 
>>>> POJO instance, the POJO constructor cannot be found
>>>> org.apache.felix.ipojo.ConfigurationException: The configuration is 
>>>> not correct for the type instancefactoryImpl.InstanceFactoryImpl :
>>>> Cannot create a POJO instance, the POJO constructor cannot be found 
>>>> at 
>>>> org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFa
>>>> ctory.java:328)  at
>>>> org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFa
>>>> ctory.java:240)  at
>>>> org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentTy
>>>> pe.java:79)  at
>>>> instancefactoryImpl.Activator.start(Activator.java:37)
>>>>  at
>>>> org.apache.felix.framework.util.SecureAction.startActivator(SecureA
>>>> ction.java:645)  at
>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>>>>  at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>>>>  at
>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>>>>  at
>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>>>>  at embedder.HostApplication.<init>(HostApplication.java:148)
>>>>  at embedder.Embedder.main(Embedder.java:12)
>>>> Caused by: org.apache.felix.ipojo.ConfigurationException: Cannot 
>>>> create a POJO instance, the POJO constructor cannot be found  at 
>>>> org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFac
>>>> tory.java:191)  at
>>>> org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFa
>>>> ctory.java:319)
>>>>  ... 10 more
>>>> Caused by: java.lang.RuntimeException: Cannot create a POJO 
>>>> instance, the POJO constructor cannot be found  at 
>>>> org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager
>>>> .java:766)  at
>>>> org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManage
>>>> r.java:923)  at
>>>> org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbac
>>>> kHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>>>>  at
>>>> org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbac
>>>> kHandler.stateChanged(LifecycleCallbackHandler.java)
>>>>  at
>>>> org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.jav
>>>> a:536)  at
>>>> org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:4
>>>> 18)  at
>>>> org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFac
>>>> tory.java:179)
>>>>  ... 11 more
>>>> Caused by: java.lang.NoSuchMethodException: 
>>>> instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipo
>>>> jo.InstanceManager)  at
>>>> java.lang.Class.getConstructor0(Class.java:2715)
>>>>  at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>>>>  at
>>>> org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager
>>>> .java:726)
>>>>  ... 17 more
>>>> I am getting the error at the following line:
>>>> 
>>>> x.createInstance();
>>>> I tried to explicitly define a constructor, and to add a method called "init". All this failed, and the same error keeps showing. What should I do? Thanks?
>>>> 
>>>> 
>>>> 
>>>> Kind Regards,
>>>> Zaid Almahmoud
>>>> Research Assistant
>>>> 
>>>> Khalifa University of Science, Technology, and Research Abu Dhabi - 
>>>> United Arab Emirates
>>>> TEL: 00971-2-401-8178
>>>> MOB: 00971-50-9619601
>>> 
>>> 
>>> --------------------------------------------------------------------
>>> - To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


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


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


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


RE: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”

Posted by Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae>.
Thank you very much Mr. Clement,

My issue was solved when I updated my api bundle version.

Although I found iPOJO complicated at the beginning, now I am in love with it more and more :)



Zaid

-----Original Message-----
From: Clement Escoffier [mailto:clement.escoffier@gmail.com] 
Sent: 03 آذار, 2014 07:11 م
To: Apache Felix - Users Mailing List
Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”

Hi,

I’ve added a comment on the issue. It looks like you are using an outdated version of the API bundle.  

Clement


On 2 mars 2014, at 21:12, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:

> I created an issue. Here's the link:
> 
> https://issues.apache.org/jira/browse/FELIX-4443
> 
> 
> I appreciate your help.
> 
> 
> Zaid
> 
> -----Original Message-----
> From: Clement Escoffier [mailto:clement.escoffier@gmail.com]
> Sent: 02 آذار, 2014 11:16 م
> To: Apache Felix - Users Mailing List
> Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”
> 
> 
> On 2 mars 2014, at 20:06, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:
> 
>> I will send my bundle and my java project to your email address (privately) since I don't know Jira Ticket.
> 
> Jira is the bug tracker we use:
> https://issues.apache.org/jira/browse/FELIX/?selectedTab=com.atlassian
> .jira.jira-projects-plugin:summary-panel
> 
> You can create an issue, attach your code, add comments… The advantage is that you can follow the resolution of your issue. Also, other people can check the fix or turn around.
> 
> Clement
> 
>> 
>> 
>> Zaid
>> 
>> -----Original Message-----
>> From: Clement Escoffier [mailto:clement.escoffier@gmail.com]
>> Sent: 02 آذار, 2014 11:05 م
>> To: Apache Felix - Users Mailing List
>> Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”
>> 
>> 
>> On 2 mars 2014, at 19:56, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:
>> 
>>> Thank you Mr. Clement for your response.
>>> 
>>> Before trying to use manipulation, which I already done in the past. 
>>> I wanted to show you this interesting scenario,
>>> 
>>> This worked for me:
>>> 
>>> 	        new PrimitiveComponentType()
>>> 	        .setBundleContext(context)
>>> 	        .setClassName(PlainHelloImpl.class.getName())
>>> 	        .addService(new Service()) 
>>> 	        .createInstance(); // Create the instance
>>> 
>>> But this did not work for me:
>>> 
>>> 	        new PrimitiveComponentType()
>>> 	        .setBundleContext(context)
>>> 	        .setClassName(PlainHelloImpl.class.getName())
>>> 	        .createInstance(); // Create the instance
>>> 
>>> 
>>> As you can see, the only difference is adding the service. What? Why?
>> 
>> Thant’s interesting. 
>> So you mean adding the service makes it work ? 
>> Could you send me both traces.
>> 
>> Would you be able to share your code (either privately, or attached to a Jira ticket) so I can reproduce it ? 
>> 
>> Clement
>> 
>>> 
>>> 
>>> Zaid
>>> 
>>> -----Original Message-----
>>> From: Clement Escoffier [mailto:clement.escoffier@gmail.com]
>>> Sent: 02 آذار, 2014 10:48 م
>>> To: Apache Felix - Users Mailing List
>>> Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”
>>> 
>>> Hi,
>>> 
>>> When using the iPOJO API, it tries to manipulate the component implement classes at runtime (if there are not already manipulated). It looks like this manipulation does not happen in your case. To be sure it is the issue, try to manipulate the class first (add @Component on it, and use ant of maven to build your bundle). 
>>> 
>>> Clement
>>> 
>>> On 2 mars 2014, at 19:13, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:
>>> 
>>>> Hey, I am trying to use iPOJO API to create component type. (I don’t want to use iPOJO Annotations).
>>>> 
>>>> In my bundle start method, I have the following code:
>>>> 
>>>> public void start(BundleContext context) {
>>>> 
>>>>  ComponentType x = new PrimitiveComponentType()
>>>>          .setBundleContext(context)
>>>>          .setClassName(InstanceFactoryImpl.class.getName())
>>>>          .setValidateMethod("start")
>>>>          .setInvalidateMethod("stop");
>>>> 
>>>> 
>>>>          x.start();
>>>> 
>>>>          try {
>>>>              x.createInstance();
>>>>          } catch (UnacceptableConfiguration e) {
>>>>              // TODO Auto-generated catch block
>>>>              e.printStackTrace();
>>>>          } catch (MissingHandlerException e) {
>>>>              // TODO Auto-generated catch block
>>>>              e.printStackTrace();
>>>>          } catch (ConfigurationException e) {
>>>>              // TODO Auto-generated catch block
>>>>              e.printStackTrace();
>>>>          }
>>>> 
>>>>          System.out.println("and we are done!"); } 
>>>> InstanceFactoryImpl class is in the same package as the following:
>>>> public class InstanceFactoryImpl implements 
>>>> instancefactory.InstanceFactory{
>>>> 
>>>> 
>>>>  @Override
>>>>  public void start() {
>>>> 
>>>> 
>>>> 
>>>>  }
>>>> 
>>>>  @Override
>>>>  public void stop() {
>>>> 
>>>>  }
>>>> 
>>>> 
>>>> 
>>>> }
>>>> When I load my bundle to Felix framework in my java application, I get the following error:
>>>> 
>>>> [ERROR]  : [instancefactoryImpl.InstanceFactoryImpl-0]
>>>> createInstance
>>>> -> Cannot invoke the constructor (method not found) : 
>>>> instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.
>>>> InstanceManager)
>>>> java.lang.NoSuchMethodException: 
>>>> instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipo
>>>> jo.InstanceManager)  at 
>>>> java.lang.Class.getConstructor0(Class.java:2715)
>>>>  at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>>>>  at 
>>>> org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager
>>>> .java:726)  at 
>>>> org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManage
>>>> r.java:923)  at 
>>>> org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbac
>>>> kHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>>>>  at 
>>>> org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbac
>>>> kHandler.stateChanged(LifecycleCallbackHandler.java)
>>>>  at 
>>>> org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.jav
>>>> a:536)  at 
>>>> org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:4
>>>> 18)  at 
>>>> org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFac
>>>> tory.java:179)  at 
>>>> org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFa
>>>> ctory.java:319)  at 
>>>> org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFa
>>>> ctory.java:240)  at 
>>>> org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentTy
>>>> pe.java:79)  at 
>>>> instancefactoryImpl.Activator.start(Activator.java:37)
>>>>  at 
>>>> org.apache.felix.framework.util.SecureAction.startActivator(SecureA
>>>> ction.java:645)  at 
>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>>>>  at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>>>>  at 
>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>>>>  at 
>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>>>>  at embedder.HostApplication.<init>(HostApplication.java:148)
>>>>  at embedder.Embedder.main(Embedder.java:12)
>>>> [ERROR] instancefactoryImpl.InstanceFactoryImpl : Cannot create a 
>>>> POJO instance, the POJO constructor cannot be found
>>>> org.apache.felix.ipojo.ConfigurationException: The configuration is 
>>>> not correct for the type instancefactoryImpl.InstanceFactoryImpl : 
>>>> Cannot create a POJO instance, the POJO constructor cannot be found  
>>>> at 
>>>> org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFa
>>>> ctory.java:328)  at 
>>>> org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFa
>>>> ctory.java:240)  at 
>>>> org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentTy
>>>> pe.java:79)  at 
>>>> instancefactoryImpl.Activator.start(Activator.java:37)
>>>>  at 
>>>> org.apache.felix.framework.util.SecureAction.startActivator(SecureA
>>>> ction.java:645)  at 
>>>> org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>>>>  at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>>>>  at 
>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>>>>  at 
>>>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>>>>  at embedder.HostApplication.<init>(HostApplication.java:148)
>>>>  at embedder.Embedder.main(Embedder.java:12)
>>>> Caused by: org.apache.felix.ipojo.ConfigurationException: Cannot 
>>>> create a POJO instance, the POJO constructor cannot be found  at 
>>>> org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFac
>>>> tory.java:191)  at 
>>>> org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFa
>>>> ctory.java:319)
>>>>  ... 10 more
>>>> Caused by: java.lang.RuntimeException: Cannot create a POJO 
>>>> instance, the POJO constructor cannot be found  at 
>>>> org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager
>>>> .java:766)  at 
>>>> org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManage
>>>> r.java:923)  at 
>>>> org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbac
>>>> kHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>>>>  at 
>>>> org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbac
>>>> kHandler.stateChanged(LifecycleCallbackHandler.java)
>>>>  at 
>>>> org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.jav
>>>> a:536)  at 
>>>> org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:4
>>>> 18)  at 
>>>> org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFac
>>>> tory.java:179)
>>>>  ... 11 more
>>>> Caused by: java.lang.NoSuchMethodException: 
>>>> instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipo
>>>> jo.InstanceManager)  at 
>>>> java.lang.Class.getConstructor0(Class.java:2715)
>>>>  at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>>>>  at 
>>>> org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager
>>>> .java:726)
>>>>  ... 17 more
>>>> I am getting the error at the following line:
>>>> 
>>>> x.createInstance();
>>>> I tried to explicitly define a constructor, and to add a method called "init". All this failed, and the same error keeps showing. What should I do? Thanks?
>>>> 
>>>> 
>>>> 
>>>> Kind Regards,
>>>> Zaid Almahmoud
>>>> Research Assistant
>>>> 
>>>> Khalifa University of Science, Technology, and Research Abu Dhabi - 
>>>> United Arab Emirates
>>>> TEL: 00971-2-401-8178
>>>> MOB: 00971-50-9619601
>>> 
>>> 
>>> --------------------------------------------------------------------
>>> - To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


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


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


Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”

Posted by Clement Escoffier <cl...@gmail.com>.
Hi,

I’ve added a comment on the issue. It looks like you are using an outdated version of the API bundle.  

Clement


On 2 mars 2014, at 21:12, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:

> I created an issue. Here's the link:
> 
> https://issues.apache.org/jira/browse/FELIX-4443
> 
> 
> I appreciate your help.
> 
> 
> Zaid
> 
> -----Original Message-----
> From: Clement Escoffier [mailto:clement.escoffier@gmail.com] 
> Sent: 02 آذار, 2014 11:16 م
> To: Apache Felix - Users Mailing List
> Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”
> 
> 
> On 2 mars 2014, at 20:06, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:
> 
>> I will send my bundle and my java project to your email address (privately) since I don't know Jira Ticket.
> 
> Jira is the bug tracker we use:
> https://issues.apache.org/jira/browse/FELIX/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel
> 
> You can create an issue, attach your code, add comments… The advantage is that you can follow the resolution of your issue. Also, other people can check the fix or turn around.
> 
> Clement
> 
>> 
>> 
>> Zaid
>> 
>> -----Original Message-----
>> From: Clement Escoffier [mailto:clement.escoffier@gmail.com]
>> Sent: 02 آذار, 2014 11:05 م
>> To: Apache Felix - Users Mailing List
>> Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”
>> 
>> 
>> On 2 mars 2014, at 19:56, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:
>> 
>>> Thank you Mr. Clement for your response.
>>> 
>>> Before trying to use manipulation, which I already done in the past. 
>>> I wanted to show you this interesting scenario,
>>> 
>>> This worked for me:
>>> 
>>> 	        new PrimitiveComponentType()
>>> 	        .setBundleContext(context)
>>> 	        .setClassName(PlainHelloImpl.class.getName())
>>> 	        .addService(new Service()) 
>>> 	        .createInstance(); // Create the instance
>>> 
>>> But this did not work for me:
>>> 
>>> 	        new PrimitiveComponentType()
>>> 	        .setBundleContext(context)
>>> 	        .setClassName(PlainHelloImpl.class.getName())
>>> 	        .createInstance(); // Create the instance
>>> 
>>> 
>>> As you can see, the only difference is adding the service. What? Why?
>> 
>> Thant’s interesting. 
>> So you mean adding the service makes it work ? 
>> Could you send me both traces.
>> 
>> Would you be able to share your code (either privately, or attached to a Jira ticket) so I can reproduce it ? 
>> 
>> Clement
>> 
>>> 
>>> 
>>> Zaid
>>> 
>>> -----Original Message-----
>>> From: Clement Escoffier [mailto:clement.escoffier@gmail.com]
>>> Sent: 02 آذار, 2014 10:48 م
>>> To: Apache Felix - Users Mailing List
>>> Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”
>>> 
>>> Hi,
>>> 
>>> When using the iPOJO API, it tries to manipulate the component implement classes at runtime (if there are not already manipulated). It looks like this manipulation does not happen in your case. To be sure it is the issue, try to manipulate the class first (add @Component on it, and use ant of maven to build your bundle). 
>>> 
>>> Clement
>>> 
>>> On 2 mars 2014, at 19:13, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:
>>> 
>>>> Hey, I am trying to use iPOJO API to create component type. (I don’t want to use iPOJO Annotations).
>>>> 
>>>> In my bundle start method, I have the following code:
>>>> 
>>>> public void start(BundleContext context) {
>>>> 
>>>>  ComponentType x = new PrimitiveComponentType()
>>>>          .setBundleContext(context)
>>>>          .setClassName(InstanceFactoryImpl.class.getName())
>>>>          .setValidateMethod("start")
>>>>          .setInvalidateMethod("stop");
>>>> 
>>>> 
>>>>          x.start();
>>>> 
>>>>          try {
>>>>              x.createInstance();
>>>>          } catch (UnacceptableConfiguration e) {
>>>>              // TODO Auto-generated catch block
>>>>              e.printStackTrace();
>>>>          } catch (MissingHandlerException e) {
>>>>              // TODO Auto-generated catch block
>>>>              e.printStackTrace();
>>>>          } catch (ConfigurationException e) {
>>>>              // TODO Auto-generated catch block
>>>>              e.printStackTrace();
>>>>          }
>>>> 
>>>>          System.out.println("and we are done!"); } 
>>>> InstanceFactoryImpl class is in the same package as the following:
>>>> public class InstanceFactoryImpl implements 
>>>> instancefactory.InstanceFactory{
>>>> 
>>>> 
>>>>  @Override
>>>>  public void start() {
>>>> 
>>>> 
>>>> 
>>>>  }
>>>> 
>>>>  @Override
>>>>  public void stop() {
>>>> 
>>>>  }
>>>> 
>>>> 
>>>> 
>>>> }
>>>> When I load my bundle to Felix framework in my java application, I get the following error:
>>>> 
>>>> [ERROR]  : [instancefactoryImpl.InstanceFactoryImpl-0] 
>>>> createInstance
>>>> -> Cannot invoke the constructor (method not found) : 
>>>> instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.
>>>> InstanceManager)
>>>> java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
>>>>  at java.lang.Class.getConstructor0(Class.java:2715)
>>>>  at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>>>>  at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
>>>>  at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
>>>>  at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>>>>  at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
>>>>  at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
>>>>  at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
>>>>  at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
>>>>  at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
>>>>  at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
>>>>  at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>>>>  at instancefactoryImpl.Activator.start(Activator.java:37)
>>>>  at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
>>>>  at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>>>>  at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>>>>  at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>>>>  at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>>>>  at embedder.HostApplication.<init>(HostApplication.java:148)
>>>>  at embedder.Embedder.main(Embedder.java:12)
>>>> [ERROR] instancefactoryImpl.InstanceFactoryImpl : Cannot create a 
>>>> POJO instance, the POJO constructor cannot be found
>>>> org.apache.felix.ipojo.ConfigurationException: The configuration is not correct for the type instancefactoryImpl.InstanceFactoryImpl : Cannot create a POJO instance, the POJO constructor cannot be found
>>>>  at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:328)
>>>>  at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
>>>>  at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>>>>  at instancefactoryImpl.Activator.start(Activator.java:37)
>>>>  at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
>>>>  at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>>>>  at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>>>>  at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>>>>  at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>>>>  at embedder.HostApplication.<init>(HostApplication.java:148)
>>>>  at embedder.Embedder.main(Embedder.java:12)
>>>> Caused by: org.apache.felix.ipojo.ConfigurationException: Cannot create a POJO instance, the POJO constructor cannot be found
>>>>  at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:191)
>>>>  at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
>>>>  ... 10 more
>>>> Caused by: java.lang.RuntimeException: Cannot create a POJO instance, the POJO constructor cannot be found
>>>>  at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:766)
>>>>  at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
>>>>  at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>>>>  at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
>>>>  at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
>>>>  at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
>>>>  at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
>>>>  ... 11 more
>>>> Caused by: java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
>>>>  at java.lang.Class.getConstructor0(Class.java:2715)
>>>>  at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>>>>  at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
>>>>  ... 17 more
>>>> I am getting the error at the following line:
>>>> 
>>>> x.createInstance();
>>>> I tried to explicitly define a constructor, and to add a method called "init". All this failed, and the same error keeps showing. What should I do? Thanks?
>>>> 
>>>> 
>>>> 
>>>> Kind Regards,
>>>> Zaid Almahmoud
>>>> Research Assistant
>>>> 
>>>> Khalifa University of Science, Technology, and Research Abu Dhabi - 
>>>> United Arab Emirates
>>>> TEL: 00971-2-401-8178
>>>> MOB: 00971-50-9619601
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


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


RE: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”

Posted by Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae>.
I created an issue. Here's the link:

https://issues.apache.org/jira/browse/FELIX-4443


I appreciate your help.


Zaid

-----Original Message-----
From: Clement Escoffier [mailto:clement.escoffier@gmail.com] 
Sent: 02 آذار, 2014 11:16 م
To: Apache Felix - Users Mailing List
Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”


On 2 mars 2014, at 20:06, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:

> I will send my bundle and my java project to your email address (privately) since I don't know Jira Ticket.

Jira is the bug tracker we use:
https://issues.apache.org/jira/browse/FELIX/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel

You can create an issue, attach your code, add comments… The advantage is that you can follow the resolution of your issue. Also, other people can check the fix or turn around.

Clement

> 
> 
> Zaid
> 
> -----Original Message-----
> From: Clement Escoffier [mailto:clement.escoffier@gmail.com]
> Sent: 02 آذار, 2014 11:05 م
> To: Apache Felix - Users Mailing List
> Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”
> 
> 
> On 2 mars 2014, at 19:56, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:
> 
>> Thank you Mr. Clement for your response.
>> 
>> Before trying to use manipulation, which I already done in the past. 
>> I wanted to show you this interesting scenario,
>> 
>> This worked for me:
>> 
>> 	        new PrimitiveComponentType()
>> 	        .setBundleContext(context)
>> 	        .setClassName(PlainHelloImpl.class.getName())
>> 	        .addService(new Service()) 
>> 	        .createInstance(); // Create the instance
>> 
>> But this did not work for me:
>> 
>> 	        new PrimitiveComponentType()
>> 	        .setBundleContext(context)
>> 	        .setClassName(PlainHelloImpl.class.getName())
>> 	        .createInstance(); // Create the instance
>> 
>> 
>> As you can see, the only difference is adding the service. What? Why?
> 
> Thant’s interesting. 
> So you mean adding the service makes it work ? 
> Could you send me both traces.
> 
> Would you be able to share your code (either privately, or attached to a Jira ticket) so I can reproduce it ? 
> 
> Clement
> 
>> 
>> 
>> Zaid
>> 
>> -----Original Message-----
>> From: Clement Escoffier [mailto:clement.escoffier@gmail.com]
>> Sent: 02 آذار, 2014 10:48 م
>> To: Apache Felix - Users Mailing List
>> Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”
>> 
>> Hi,
>> 
>> When using the iPOJO API, it tries to manipulate the component implement classes at runtime (if there are not already manipulated). It looks like this manipulation does not happen in your case. To be sure it is the issue, try to manipulate the class first (add @Component on it, and use ant of maven to build your bundle). 
>> 
>> Clement
>> 
>> On 2 mars 2014, at 19:13, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:
>> 
>>> Hey, I am trying to use iPOJO API to create component type. (I don’t want to use iPOJO Annotations).
>>> 
>>> In my bundle start method, I have the following code:
>>> 
>>> public void start(BundleContext context) {
>>> 
>>>   ComponentType x = new PrimitiveComponentType()
>>>           .setBundleContext(context)
>>>           .setClassName(InstanceFactoryImpl.class.getName())
>>>           .setValidateMethod("start")
>>>           .setInvalidateMethod("stop");
>>> 
>>> 
>>>           x.start();
>>> 
>>>           try {
>>>               x.createInstance();
>>>           } catch (UnacceptableConfiguration e) {
>>>               // TODO Auto-generated catch block
>>>               e.printStackTrace();
>>>           } catch (MissingHandlerException e) {
>>>               // TODO Auto-generated catch block
>>>               e.printStackTrace();
>>>           } catch (ConfigurationException e) {
>>>               // TODO Auto-generated catch block
>>>               e.printStackTrace();
>>>           }
>>> 
>>>           System.out.println("and we are done!"); } 
>>> InstanceFactoryImpl class is in the same package as the following:
>>> public class InstanceFactoryImpl implements 
>>> instancefactory.InstanceFactory{
>>> 
>>> 
>>>   @Override
>>>   public void start() {
>>> 
>>> 
>>> 
>>>   }
>>> 
>>>   @Override
>>>   public void stop() {
>>> 
>>>   }
>>> 
>>> 
>>> 
>>> }
>>> When I load my bundle to Felix framework in my java application, I get the following error:
>>> 
>>> [ERROR]  : [instancefactoryImpl.InstanceFactoryImpl-0] 
>>> createInstance
>>> -> Cannot invoke the constructor (method not found) : 
>>> instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.
>>> InstanceManager)
>>> java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
>>>   at java.lang.Class.getConstructor0(Class.java:2715)
>>>   at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>>>   at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
>>>   at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
>>>   at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>>>   at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
>>>   at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
>>>   at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
>>>   at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
>>>   at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
>>>   at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
>>>   at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>>>   at instancefactoryImpl.Activator.start(Activator.java:37)
>>>   at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
>>>   at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>>>   at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>>>   at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>>>   at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>>>   at embedder.HostApplication.<init>(HostApplication.java:148)
>>>   at embedder.Embedder.main(Embedder.java:12)
>>> [ERROR] instancefactoryImpl.InstanceFactoryImpl : Cannot create a 
>>> POJO instance, the POJO constructor cannot be found
>>> org.apache.felix.ipojo.ConfigurationException: The configuration is not correct for the type instancefactoryImpl.InstanceFactoryImpl : Cannot create a POJO instance, the POJO constructor cannot be found
>>>   at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:328)
>>>   at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
>>>   at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>>>   at instancefactoryImpl.Activator.start(Activator.java:37)
>>>   at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
>>>   at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>>>   at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>>>   at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>>>   at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>>>   at embedder.HostApplication.<init>(HostApplication.java:148)
>>>   at embedder.Embedder.main(Embedder.java:12)
>>> Caused by: org.apache.felix.ipojo.ConfigurationException: Cannot create a POJO instance, the POJO constructor cannot be found
>>>   at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:191)
>>>   at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
>>>   ... 10 more
>>> Caused by: java.lang.RuntimeException: Cannot create a POJO instance, the POJO constructor cannot be found
>>>   at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:766)
>>>   at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
>>>   at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>>>   at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
>>>   at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
>>>   at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
>>>   at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
>>>   ... 11 more
>>> Caused by: java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
>>>   at java.lang.Class.getConstructor0(Class.java:2715)
>>>   at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>>>   at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
>>>   ... 17 more
>>> I am getting the error at the following line:
>>> 
>>> x.createInstance();
>>> I tried to explicitly define a constructor, and to add a method called "init". All this failed, and the same error keeps showing. What should I do? Thanks?
>>> 
>>> 
>>> 
>>> Kind Regards,
>>> Zaid Almahmoud
>>> Research Assistant
>>> 
>>> Khalifa University of Science, Technology, and Research Abu Dhabi - 
>>> United Arab Emirates
>>> TEL: 00971-2-401-8178
>>> MOB: 00971-50-9619601
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


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


Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”

Posted by Clement Escoffier <cl...@gmail.com>.
On 2 mars 2014, at 20:06, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:

> I will send my bundle and my java project to your email address (privately) since I don't know Jira Ticket.

Jira is the bug tracker we use:
https://issues.apache.org/jira/browse/FELIX/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel

You can create an issue, attach your code, add comments…
The advantage is that you can follow the resolution of your issue. Also, other people can check the fix or turn around.

Clement

> 
> 
> Zaid
> 
> -----Original Message-----
> From: Clement Escoffier [mailto:clement.escoffier@gmail.com] 
> Sent: 02 آذار, 2014 11:05 م
> To: Apache Felix - Users Mailing List
> Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”
> 
> 
> On 2 mars 2014, at 19:56, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:
> 
>> Thank you Mr. Clement for your response.
>> 
>> Before trying to use manipulation, which I already done in the past. I 
>> wanted to show you this interesting scenario,
>> 
>> This worked for me:
>> 
>> 	        new PrimitiveComponentType()
>> 	        .setBundleContext(context)
>> 	        .setClassName(PlainHelloImpl.class.getName())
>> 	        .addService(new Service()) 
>> 	        .createInstance(); // Create the instance
>> 
>> But this did not work for me:
>> 
>> 	        new PrimitiveComponentType()
>> 	        .setBundleContext(context)
>> 	        .setClassName(PlainHelloImpl.class.getName())
>> 	        .createInstance(); // Create the instance
>> 
>> 
>> As you can see, the only difference is adding the service. What? Why?
> 
> Thant’s interesting. 
> So you mean adding the service makes it work ? 
> Could you send me both traces.
> 
> Would you be able to share your code (either privately, or attached to a Jira ticket) so I can reproduce it ? 
> 
> Clement
> 
>> 
>> 
>> Zaid
>> 
>> -----Original Message-----
>> From: Clement Escoffier [mailto:clement.escoffier@gmail.com]
>> Sent: 02 آذار, 2014 10:48 م
>> To: Apache Felix - Users Mailing List
>> Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”
>> 
>> Hi,
>> 
>> When using the iPOJO API, it tries to manipulate the component implement classes at runtime (if there are not already manipulated). It looks like this manipulation does not happen in your case. To be sure it is the issue, try to manipulate the class first (add @Component on it, and use ant of maven to build your bundle). 
>> 
>> Clement
>> 
>> On 2 mars 2014, at 19:13, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:
>> 
>>> Hey, I am trying to use iPOJO API to create component type. (I don’t want to use iPOJO Annotations).
>>> 
>>> In my bundle start method, I have the following code:
>>> 
>>> public void start(BundleContext context) {
>>> 
>>>   ComponentType x = new PrimitiveComponentType()
>>>           .setBundleContext(context)
>>>           .setClassName(InstanceFactoryImpl.class.getName())
>>>           .setValidateMethod("start")
>>>           .setInvalidateMethod("stop");
>>> 
>>> 
>>>           x.start();
>>> 
>>>           try {
>>>               x.createInstance();
>>>           } catch (UnacceptableConfiguration e) {
>>>               // TODO Auto-generated catch block
>>>               e.printStackTrace();
>>>           } catch (MissingHandlerException e) {
>>>               // TODO Auto-generated catch block
>>>               e.printStackTrace();
>>>           } catch (ConfigurationException e) {
>>>               // TODO Auto-generated catch block
>>>               e.printStackTrace();
>>>           }
>>> 
>>>           System.out.println("and we are done!"); } 
>>> InstanceFactoryImpl class is in the same package as the following:
>>> public class InstanceFactoryImpl implements 
>>> instancefactory.InstanceFactory{
>>> 
>>> 
>>>   @Override
>>>   public void start() {
>>> 
>>> 
>>> 
>>>   }
>>> 
>>>   @Override
>>>   public void stop() {
>>> 
>>>   }
>>> 
>>> 
>>> 
>>> }
>>> When I load my bundle to Felix framework in my java application, I get the following error:
>>> 
>>> [ERROR]  : [instancefactoryImpl.InstanceFactoryImpl-0] createInstance
>>> -> Cannot invoke the constructor (method not found) : 
>>> instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.
>>> InstanceManager)
>>> java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
>>>   at java.lang.Class.getConstructor0(Class.java:2715)
>>>   at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>>>   at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
>>>   at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
>>>   at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>>>   at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
>>>   at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
>>>   at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
>>>   at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
>>>   at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
>>>   at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
>>>   at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>>>   at instancefactoryImpl.Activator.start(Activator.java:37)
>>>   at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
>>>   at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>>>   at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>>>   at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>>>   at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>>>   at embedder.HostApplication.<init>(HostApplication.java:148)
>>>   at embedder.Embedder.main(Embedder.java:12)
>>> [ERROR] instancefactoryImpl.InstanceFactoryImpl : Cannot create a 
>>> POJO instance, the POJO constructor cannot be found
>>> org.apache.felix.ipojo.ConfigurationException: The configuration is not correct for the type instancefactoryImpl.InstanceFactoryImpl : Cannot create a POJO instance, the POJO constructor cannot be found
>>>   at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:328)
>>>   at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
>>>   at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>>>   at instancefactoryImpl.Activator.start(Activator.java:37)
>>>   at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
>>>   at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>>>   at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>>>   at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>>>   at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>>>   at embedder.HostApplication.<init>(HostApplication.java:148)
>>>   at embedder.Embedder.main(Embedder.java:12)
>>> Caused by: org.apache.felix.ipojo.ConfigurationException: Cannot create a POJO instance, the POJO constructor cannot be found
>>>   at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:191)
>>>   at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
>>>   ... 10 more
>>> Caused by: java.lang.RuntimeException: Cannot create a POJO instance, the POJO constructor cannot be found
>>>   at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:766)
>>>   at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
>>>   at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>>>   at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
>>>   at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
>>>   at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
>>>   at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
>>>   ... 11 more
>>> Caused by: java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
>>>   at java.lang.Class.getConstructor0(Class.java:2715)
>>>   at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>>>   at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
>>>   ... 17 more
>>> I am getting the error at the following line:
>>> 
>>> x.createInstance();
>>> I tried to explicitly define a constructor, and to add a method called "init". All this failed, and the same error keeps showing. What should I do? Thanks?
>>> 
>>> 
>>> 
>>> Kind Regards,
>>> Zaid Almahmoud
>>> Research Assistant
>>> 
>>> Khalifa University of Science, Technology, and Research Abu Dhabi - 
>>> United Arab Emirates
>>> TEL: 00971-2-401-8178
>>> MOB: 00971-50-9619601
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


RE: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”

Posted by Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae>.
I will send my bundle and my java project to your email address (privately) since I don't know Jira Ticket.


Zaid

-----Original Message-----
From: Clement Escoffier [mailto:clement.escoffier@gmail.com] 
Sent: 02 آذار, 2014 11:05 م
To: Apache Felix - Users Mailing List
Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”


On 2 mars 2014, at 19:56, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:

> Thank you Mr. Clement for your response.
> 
> Before trying to use manipulation, which I already done in the past. I 
> wanted to show you this interesting scenario,
> 
> This worked for me:
> 
> 	        new PrimitiveComponentType()
> 	        .setBundleContext(context)
> 	        .setClassName(PlainHelloImpl.class.getName())
> 	        .addService(new Service()) 
> 	        .createInstance(); // Create the instance
> 
> But this did not work for me:
> 
> 	        new PrimitiveComponentType()
> 	        .setBundleContext(context)
> 	        .setClassName(PlainHelloImpl.class.getName())
> 	        .createInstance(); // Create the instance
> 
> 
> As you can see, the only difference is adding the service. What? Why?

Thant’s interesting. 
So you mean adding the service makes it work ? 
Could you send me both traces.

Would you be able to share your code (either privately, or attached to a Jira ticket) so I can reproduce it ? 

Clement

> 
> 
> Zaid
> 
> -----Original Message-----
> From: Clement Escoffier [mailto:clement.escoffier@gmail.com]
> Sent: 02 آذار, 2014 10:48 م
> To: Apache Felix - Users Mailing List
> Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”
> 
> Hi,
> 
> When using the iPOJO API, it tries to manipulate the component implement classes at runtime (if there are not already manipulated). It looks like this manipulation does not happen in your case. To be sure it is the issue, try to manipulate the class first (add @Component on it, and use ant of maven to build your bundle). 
> 
> Clement
> 
> On 2 mars 2014, at 19:13, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:
> 
>> Hey, I am trying to use iPOJO API to create component type. (I don’t want to use iPOJO Annotations).
>> 
>> In my bundle start method, I have the following code:
>> 
>> public void start(BundleContext context) {
>> 
>>    ComponentType x = new PrimitiveComponentType()
>>            .setBundleContext(context)
>>            .setClassName(InstanceFactoryImpl.class.getName())
>>            .setValidateMethod("start")
>>            .setInvalidateMethod("stop");
>> 
>> 
>>            x.start();
>> 
>>            try {
>>                x.createInstance();
>>            } catch (UnacceptableConfiguration e) {
>>                // TODO Auto-generated catch block
>>                e.printStackTrace();
>>            } catch (MissingHandlerException e) {
>>                // TODO Auto-generated catch block
>>                e.printStackTrace();
>>            } catch (ConfigurationException e) {
>>                // TODO Auto-generated catch block
>>                e.printStackTrace();
>>            }
>> 
>>            System.out.println("and we are done!"); } 
>> InstanceFactoryImpl class is in the same package as the following:
>> public class InstanceFactoryImpl implements 
>> instancefactory.InstanceFactory{
>> 
>> 
>>    @Override
>>    public void start() {
>> 
>> 
>> 
>>    }
>> 
>>    @Override
>>    public void stop() {
>> 
>>    }
>> 
>> 
>> 
>> }
>> When I load my bundle to Felix framework in my java application, I get the following error:
>> 
>> [ERROR]  : [instancefactoryImpl.InstanceFactoryImpl-0] createInstance
>> -> Cannot invoke the constructor (method not found) : 
>> instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.
>> InstanceManager)
>> java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
>>    at java.lang.Class.getConstructor0(Class.java:2715)
>>    at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>>    at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
>>    at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
>>    at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>>    at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
>>    at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
>>    at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
>>    at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
>>    at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
>>    at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
>>    at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>>    at instancefactoryImpl.Activator.start(Activator.java:37)
>>    at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
>>    at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>>    at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>>    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>>    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>>    at embedder.HostApplication.<init>(HostApplication.java:148)
>>    at embedder.Embedder.main(Embedder.java:12)
>> [ERROR] instancefactoryImpl.InstanceFactoryImpl : Cannot create a 
>> POJO instance, the POJO constructor cannot be found
>> org.apache.felix.ipojo.ConfigurationException: The configuration is not correct for the type instancefactoryImpl.InstanceFactoryImpl : Cannot create a POJO instance, the POJO constructor cannot be found
>>    at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:328)
>>    at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
>>    at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>>    at instancefactoryImpl.Activator.start(Activator.java:37)
>>    at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
>>    at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>>    at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>>    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>>    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>>    at embedder.HostApplication.<init>(HostApplication.java:148)
>>    at embedder.Embedder.main(Embedder.java:12)
>> Caused by: org.apache.felix.ipojo.ConfigurationException: Cannot create a POJO instance, the POJO constructor cannot be found
>>    at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:191)
>>    at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
>>    ... 10 more
>> Caused by: java.lang.RuntimeException: Cannot create a POJO instance, the POJO constructor cannot be found
>>    at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:766)
>>    at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
>>    at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>>    at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
>>    at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
>>    at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
>>    at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
>>    ... 11 more
>> Caused by: java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
>>    at java.lang.Class.getConstructor0(Class.java:2715)
>>    at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>>    at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
>>    ... 17 more
>> I am getting the error at the following line:
>> 
>> x.createInstance();
>> I tried to explicitly define a constructor, and to add a method called "init". All this failed, and the same error keeps showing. What should I do? Thanks?
>> 
>> 
>> 
>> Kind Regards,
>> Zaid Almahmoud
>> Research Assistant
>> 
>> Khalifa University of Science, Technology, and Research Abu Dhabi - 
>> United Arab Emirates
>> TEL: 00971-2-401-8178
>> MOB: 00971-50-9619601
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


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


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


Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”

Posted by Clement Escoffier <cl...@gmail.com>.
On 2 mars 2014, at 19:56, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:

> Thank you Mr. Clement for your response.
> 
> Before trying to use manipulation, which I already done in the past. I wanted to show you this interesting scenario,
> 
> This worked for me:
> 
> 	        new PrimitiveComponentType()
> 	        .setBundleContext(context)
> 	        .setClassName(PlainHelloImpl.class.getName())
> 	        .addService(new Service()) 
> 	        .createInstance(); // Create the instance
> 
> But this did not work for me:
> 
> 	        new PrimitiveComponentType()
> 	        .setBundleContext(context)
> 	        .setClassName(PlainHelloImpl.class.getName())
> 	        .createInstance(); // Create the instance
> 
> 
> As you can see, the only difference is adding the service. What? Why?

Thant’s interesting. 
So you mean adding the service makes it work ? 
Could you send me both traces.

Would you be able to share your code (either privately, or attached to a Jira ticket) so I can reproduce it ? 

Clement

> 
> 
> Zaid
> 
> -----Original Message-----
> From: Clement Escoffier [mailto:clement.escoffier@gmail.com] 
> Sent: 02 آذار, 2014 10:48 م
> To: Apache Felix - Users Mailing List
> Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”
> 
> Hi,
> 
> When using the iPOJO API, it tries to manipulate the component implement classes at runtime (if there are not already manipulated). It looks like this manipulation does not happen in your case. To be sure it is the issue, try to manipulate the class first (add @Component on it, and use ant of maven to build your bundle). 
> 
> Clement
> 
> On 2 mars 2014, at 19:13, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:
> 
>> Hey, I am trying to use iPOJO API to create component type. (I don’t want to use iPOJO Annotations).
>> 
>> In my bundle start method, I have the following code:
>> 
>> public void start(BundleContext context) {
>> 
>>    ComponentType x = new PrimitiveComponentType()
>>            .setBundleContext(context)
>>            .setClassName(InstanceFactoryImpl.class.getName())
>>            .setValidateMethod("start")
>>            .setInvalidateMethod("stop");
>> 
>> 
>>            x.start();
>> 
>>            try {
>>                x.createInstance();
>>            } catch (UnacceptableConfiguration e) {
>>                // TODO Auto-generated catch block
>>                e.printStackTrace();
>>            } catch (MissingHandlerException e) {
>>                // TODO Auto-generated catch block
>>                e.printStackTrace();
>>            } catch (ConfigurationException e) {
>>                // TODO Auto-generated catch block
>>                e.printStackTrace();
>>            }
>> 
>>            System.out.println("and we are done!"); } 
>> InstanceFactoryImpl class is in the same package as the following:
>> public class InstanceFactoryImpl implements 
>> instancefactory.InstanceFactory{
>> 
>> 
>>    @Override
>>    public void start() {
>> 
>> 
>> 
>>    }
>> 
>>    @Override
>>    public void stop() {
>> 
>>    }
>> 
>> 
>> 
>> }
>> When I load my bundle to Felix framework in my java application, I get the following error:
>> 
>> [ERROR]  : [instancefactoryImpl.InstanceFactoryImpl-0] createInstance 
>> -> Cannot invoke the constructor (method not found) : 
>> instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.
>> InstanceManager)
>> java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
>>    at java.lang.Class.getConstructor0(Class.java:2715)
>>    at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>>    at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
>>    at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
>>    at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>>    at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
>>    at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
>>    at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
>>    at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
>>    at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
>>    at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
>>    at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>>    at instancefactoryImpl.Activator.start(Activator.java:37)
>>    at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
>>    at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>>    at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>>    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>>    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>>    at embedder.HostApplication.<init>(HostApplication.java:148)
>>    at embedder.Embedder.main(Embedder.java:12)
>> [ERROR] instancefactoryImpl.InstanceFactoryImpl : Cannot create a POJO 
>> instance, the POJO constructor cannot be found
>> org.apache.felix.ipojo.ConfigurationException: The configuration is not correct for the type instancefactoryImpl.InstanceFactoryImpl : Cannot create a POJO instance, the POJO constructor cannot be found
>>    at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:328)
>>    at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
>>    at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>>    at instancefactoryImpl.Activator.start(Activator.java:37)
>>    at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
>>    at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>>    at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>>    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>>    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>>    at embedder.HostApplication.<init>(HostApplication.java:148)
>>    at embedder.Embedder.main(Embedder.java:12)
>> Caused by: org.apache.felix.ipojo.ConfigurationException: Cannot create a POJO instance, the POJO constructor cannot be found
>>    at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:191)
>>    at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
>>    ... 10 more
>> Caused by: java.lang.RuntimeException: Cannot create a POJO instance, the POJO constructor cannot be found
>>    at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:766)
>>    at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
>>    at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>>    at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
>>    at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
>>    at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
>>    at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
>>    ... 11 more
>> Caused by: java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
>>    at java.lang.Class.getConstructor0(Class.java:2715)
>>    at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>>    at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
>>    ... 17 more
>> I am getting the error at the following line:
>> 
>> x.createInstance();
>> I tried to explicitly define a constructor, and to add a method called "init". All this failed, and the same error keeps showing. What should I do? Thanks?
>> 
>> 
>> 
>> Kind Regards,
>> Zaid Almahmoud
>> Research Assistant
>> 
>> Khalifa University of Science, Technology, and Research Abu Dhabi - 
>> United Arab Emirates
>> TEL: 00971-2-401-8178
>> MOB: 00971-50-9619601
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


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


RE: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”

Posted by Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae>.
Thank you Mr. Clement for your response.

Before trying to use manipulation, which I already done in the past. I wanted to show you this interesting scenario,

This worked for me:

	        new PrimitiveComponentType()
	        .setBundleContext(context)
	        .setClassName(PlainHelloImpl.class.getName())
	        .addService(new Service()) 
	        .createInstance(); // Create the instance

But this did not work for me:

	        new PrimitiveComponentType()
	        .setBundleContext(context)
	        .setClassName(PlainHelloImpl.class.getName())
	        .createInstance(); // Create the instance


As you can see, the only difference is adding the service. What? Why?


Zaid

-----Original Message-----
From: Clement Escoffier [mailto:clement.escoffier@gmail.com] 
Sent: 02 آذار, 2014 10:48 م
To: Apache Felix - Users Mailing List
Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”

Hi,

When using the iPOJO API, it tries to manipulate the component implement classes at runtime (if there are not already manipulated). It looks like this manipulation does not happen in your case. To be sure it is the issue, try to manipulate the class first (add @Component on it, and use ant of maven to build your bundle). 

Clement

On 2 mars 2014, at 19:13, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:

> Hey, I am trying to use iPOJO API to create component type. (I don’t want to use iPOJO Annotations).
> 
> In my bundle start method, I have the following code:
> 
> public void start(BundleContext context) {
>  
>     ComponentType x = new PrimitiveComponentType()
>             .setBundleContext(context)
>             .setClassName(InstanceFactoryImpl.class.getName())
>             .setValidateMethod("start")
>             .setInvalidateMethod("stop");
>  
>  
>             x.start();
>  
>             try {
>                 x.createInstance();
>             } catch (UnacceptableConfiguration e) {
>                 // TODO Auto-generated catch block
>                 e.printStackTrace();
>             } catch (MissingHandlerException e) {
>                 // TODO Auto-generated catch block
>                 e.printStackTrace();
>             } catch (ConfigurationException e) {
>                 // TODO Auto-generated catch block
>                 e.printStackTrace();
>             }
>  
>             System.out.println("and we are done!"); } 
> InstanceFactoryImpl class is in the same package as the following:
> public class InstanceFactoryImpl implements 
> instancefactory.InstanceFactory{
>  
>  
>     @Override
>     public void start() {
>  
>  
>  
>     }
>  
>     @Override
>     public void stop() {
>  
>     }
>  
>  
>  
> }
> When I load my bundle to Felix framework in my java application, I get the following error:
> 
> [ERROR]  : [instancefactoryImpl.InstanceFactoryImpl-0] createInstance 
> -> Cannot invoke the constructor (method not found) : 
> instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.
> InstanceManager)
> java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
>     at java.lang.Class.getConstructor0(Class.java:2715)
>     at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>     at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
>     at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
>     at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>     at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
>     at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
>     at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
>     at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
>     at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
>     at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
>     at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>     at instancefactoryImpl.Activator.start(Activator.java:37)
>     at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
>     at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>     at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>     at embedder.HostApplication.<init>(HostApplication.java:148)
>     at embedder.Embedder.main(Embedder.java:12)
> [ERROR] instancefactoryImpl.InstanceFactoryImpl : Cannot create a POJO 
> instance, the POJO constructor cannot be found
> org.apache.felix.ipojo.ConfigurationException: The configuration is not correct for the type instancefactoryImpl.InstanceFactoryImpl : Cannot create a POJO instance, the POJO constructor cannot be found
>     at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:328)
>     at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
>     at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>     at instancefactoryImpl.Activator.start(Activator.java:37)
>     at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
>     at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>     at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>     at embedder.HostApplication.<init>(HostApplication.java:148)
>     at embedder.Embedder.main(Embedder.java:12)
> Caused by: org.apache.felix.ipojo.ConfigurationException: Cannot create a POJO instance, the POJO constructor cannot be found
>     at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:191)
>     at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
>     ... 10 more
> Caused by: java.lang.RuntimeException: Cannot create a POJO instance, the POJO constructor cannot be found
>     at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:766)
>     at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
>     at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>     at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
>     at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
>     at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
>     at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
>     ... 11 more
> Caused by: java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
>     at java.lang.Class.getConstructor0(Class.java:2715)
>     at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>     at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
>     ... 17 more
> I am getting the error at the following line:
> 
> x.createInstance();
> I tried to explicitly define a constructor, and to add a method called "init". All this failed, and the same error keeps showing. What should I do? Thanks?
> 
>  
>  
> Kind Regards,
> Zaid Almahmoud
> Research Assistant
> 
> Khalifa University of Science, Technology, and Research Abu Dhabi - 
> United Arab Emirates
> TEL: 00971-2-401-8178
> MOB: 00971-50-9619601


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


RE: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”

Posted by Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae>.
With manipulation, my component perfectly works. I tried it several times.


Zaid

-----Original Message-----
From: Zaid Jamal Saeed Al Mahmoud 
Sent: 02 آذار, 2014 10:58 م
To: Apache Felix - Users Mailing List
Subject: RE: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”

Thank you Mr. Clement for your response.

Before trying to use manipulation, which I already done in the past. I wanted to show you this interesting scenario,

This worked for me:

	        new PrimitiveComponentType()
	        .setBundleContext(context)
	        .setClassName(PlainHelloImpl.class.getName())
	        .addService(new Service()) 
	        .createInstance(); // Create the instance

But this did not work for me:

	        new PrimitiveComponentType()
	        .setBundleContext(context)
	        .setClassName(PlainHelloImpl.class.getName())
	        .createInstance(); // Create the instance


As you can see, the only difference is adding the service. What? Why?


Zaid

-----Original Message-----
From: Clement Escoffier [mailto:clement.escoffier@gmail.com]
Sent: 02 آذار, 2014 10:48 م
To: Apache Felix - Users Mailing List
Subject: Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”

Hi,

When using the iPOJO API, it tries to manipulate the component implement classes at runtime (if there are not already manipulated). It looks like this manipulation does not happen in your case. To be sure it is the issue, try to manipulate the class first (add @Component on it, and use ant of maven to build your bundle). 

Clement

On 2 mars 2014, at 19:13, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:

> Hey, I am trying to use iPOJO API to create component type. (I don’t want to use iPOJO Annotations).
> 
> In my bundle start method, I have the following code:
> 
> public void start(BundleContext context) {
>  
>     ComponentType x = new PrimitiveComponentType()
>             .setBundleContext(context)
>             .setClassName(InstanceFactoryImpl.class.getName())
>             .setValidateMethod("start")
>             .setInvalidateMethod("stop");
>  
>  
>             x.start();
>  
>             try {
>                 x.createInstance();
>             } catch (UnacceptableConfiguration e) {
>                 // TODO Auto-generated catch block
>                 e.printStackTrace();
>             } catch (MissingHandlerException e) {
>                 // TODO Auto-generated catch block
>                 e.printStackTrace();
>             } catch (ConfigurationException e) {
>                 // TODO Auto-generated catch block
>                 e.printStackTrace();
>             }
>  
>             System.out.println("and we are done!"); } 
> InstanceFactoryImpl class is in the same package as the following:
> public class InstanceFactoryImpl implements 
> instancefactory.InstanceFactory{
>  
>  
>     @Override
>     public void start() {
>  
>  
>  
>     }
>  
>     @Override
>     public void stop() {
>  
>     }
>  
>  
>  
> }
> When I load my bundle to Felix framework in my java application, I get the following error:
> 
> [ERROR]  : [instancefactoryImpl.InstanceFactoryImpl-0] createInstance
> -> Cannot invoke the constructor (method not found) : 
> instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.
> InstanceManager)
> java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
>     at java.lang.Class.getConstructor0(Class.java:2715)
>     at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>     at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
>     at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
>     at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>     at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
>     at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
>     at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
>     at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
>     at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
>     at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
>     at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>     at instancefactoryImpl.Activator.start(Activator.java:37)
>     at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
>     at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>     at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>     at embedder.HostApplication.<init>(HostApplication.java:148)
>     at embedder.Embedder.main(Embedder.java:12)
> [ERROR] instancefactoryImpl.InstanceFactoryImpl : Cannot create a POJO 
> instance, the POJO constructor cannot be found
> org.apache.felix.ipojo.ConfigurationException: The configuration is not correct for the type instancefactoryImpl.InstanceFactoryImpl : Cannot create a POJO instance, the POJO constructor cannot be found
>     at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:328)
>     at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
>     at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>     at instancefactoryImpl.Activator.start(Activator.java:37)
>     at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
>     at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>     at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>     at embedder.HostApplication.<init>(HostApplication.java:148)
>     at embedder.Embedder.main(Embedder.java:12)
> Caused by: org.apache.felix.ipojo.ConfigurationException: Cannot create a POJO instance, the POJO constructor cannot be found
>     at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:191)
>     at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
>     ... 10 more
> Caused by: java.lang.RuntimeException: Cannot create a POJO instance, the POJO constructor cannot be found
>     at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:766)
>     at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
>     at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>     at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
>     at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
>     at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
>     at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
>     ... 11 more
> Caused by: java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
>     at java.lang.Class.getConstructor0(Class.java:2715)
>     at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>     at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
>     ... 17 more
> I am getting the error at the following line:
> 
> x.createInstance();
> I tried to explicitly define a constructor, and to add a method called "init". All this failed, and the same error keeps showing. What should I do? Thanks?
> 
>  
>  
> Kind Regards,
> Zaid Almahmoud
> Research Assistant
> 
> Khalifa University of Science, Technology, and Research Abu Dhabi - 
> United Arab Emirates
> TEL: 00971-2-401-8178
> MOB: 00971-50-9619601


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


Re: Using iPOJO API shows “ Cannot create a POJO instance, the POJO constructor cannot be found”

Posted by Clement Escoffier <cl...@gmail.com>.
Hi,

When using the iPOJO API, it tries to manipulate the component implement classes at runtime (if there are not already manipulated). It looks like this manipulation does not happen in your case. To be sure it is the issue, try to manipulate the class first (add @Component on it, and use ant of maven to build your bundle). 

Clement

On 2 mars 2014, at 19:13, Zaid Jamal Saeed Al Mahmoud <za...@kustar.ac.ae> wrote:

> Hey, I am trying to use iPOJO API to create component type. (I don’t want to use iPOJO Annotations).
> 
> In my bundle start method, I have the following code:
> 
> public void start(BundleContext context)
> {
>  
>     ComponentType x = new PrimitiveComponentType()
>             .setBundleContext(context)
>             .setClassName(InstanceFactoryImpl.class.getName())
>             .setValidateMethod("start")
>             .setInvalidateMethod("stop");
>  
>  
>             x.start();
>  
>             try {
>                 x.createInstance();
>             } catch (UnacceptableConfiguration e) {
>                 // TODO Auto-generated catch block
>                 e.printStackTrace();
>             } catch (MissingHandlerException e) {
>                 // TODO Auto-generated catch block
>                 e.printStackTrace();
>             } catch (ConfigurationException e) {
>                 // TODO Auto-generated catch block
>                 e.printStackTrace();
>             }
>  
>             System.out.println("and we are done!");
> }
> InstanceFactoryImpl class is in the same package as the following:
> public class InstanceFactoryImpl implements instancefactory.InstanceFactory{
>  
>  
>     @Override
>     public void start() {
>  
>  
>  
>     }
>  
>     @Override
>     public void stop() {
>  
>     }
>  
>  
>  
> }
> When I load my bundle to Felix framework in my java application, I get the following error:
> 
> [ERROR]  : [instancefactoryImpl.InstanceFactoryImpl-0] createInstance -> Cannot invoke the constructor (method not found) : instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
> java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
>     at java.lang.Class.getConstructor0(Class.java:2715)
>     at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>     at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
>     at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
>     at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>     at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
>     at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
>     at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
>     at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
>     at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
>     at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
>     at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>     at instancefactoryImpl.Activator.start(Activator.java:37)
>     at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
>     at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>     at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>     at embedder.HostApplication.<init>(HostApplication.java:148)
>     at embedder.Embedder.main(Embedder.java:12)
> [ERROR] instancefactoryImpl.InstanceFactoryImpl : Cannot create a POJO instance, the POJO constructor cannot be found
> org.apache.felix.ipojo.ConfigurationException: The configuration is not correct for the type instancefactoryImpl.InstanceFactoryImpl : Cannot create a POJO instance, the POJO constructor cannot be found
>     at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:328)
>     at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
>     at org.apache.felix.ipojo.api.ComponentType.createInstance(ComponentType.java:79)
>     at instancefactoryImpl.Activator.start(Activator.java:37)
>     at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
>     at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
>     at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
>     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
>     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
>     at embedder.HostApplication.<init>(HostApplication.java:148)
>     at embedder.Embedder.main(Embedder.java:12)
> Caused by: org.apache.felix.ipojo.ConfigurationException: Cannot create a POJO instance, the POJO constructor cannot be found
>     at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:191)
>     at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
>     ... 10 more
> Caused by: java.lang.RuntimeException: Cannot create a POJO instance, the POJO constructor cannot be found
>     at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:766)
>     at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:923)
>     at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:156)
>     at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
>     at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:536)
>     at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:418)
>     at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
>     ... 11 more
> Caused by: java.lang.NoSuchMethodException: instancefactoryImpl.InstanceFactoryImpl.<init>(org.apache.felix.ipojo.InstanceManager)
>     at java.lang.Class.getConstructor0(Class.java:2715)
>     at java.lang.Class.getDeclaredConstructor(Class.java:1987)
>     at org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:726)
>     ... 17 more
> I am getting the error at the following line:
> 
> x.createInstance();
> I tried to explicitly define a constructor, and to add a method called "init". All this failed, and the same error keeps showing. What should I do? Thanks?
> 
>  
>  
> Kind Regards,
> Zaid Almahmoud
> Research Assistant
> 
> Khalifa University of Science, Technology, and Research
> Abu Dhabi - United Arab Emirates
> TEL: 00971-2-401-8178
> MOB: 00971-50-9619601