You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by bob_k <fa...@gmail.com> on 2008/10/08 20:01:31 UTC

Error obtaining injected value for field

Hi folks.

It seems to be a simple problem but I cannot figure out what's going on.

I have created an XMLBuilder class that dynamically generates an XML file,
"XMLBuilder" and when I try to instantiate it in a Tapestry page I'm getting
this error:

.......................................

# java.lang.ClassNotFoundException
caught an exception while obtaining a class file for
com.eveo.edetail.webapp.pages.GenerateXML

exception
    org.apache.tapestry5.internal.services.TransformationException: Error
obtaining injected value for field
com.eveo.edetail.webapp.pages.GenerateXML.builder: No service implements the
interface com.eveo.edetail.util.XMLBuilder.

# org.apache.tapestry5.internal.services.TransformationException
Error obtaining injected value for field
com.eveo.edetail.webapp.pages.GenerateXML.builder: No service implements the
interface com.eveo.edetail.util.XMLBuilder. 

.......................................

In my Tapestry page, "GenerateXML.java" I have the following simple code.

public class GenerateXML {

	@Inject
	private XMLBuilder builder = new XMLBuilder();

	void onActivate()
	{
		try {
			builder.generateXML(3);
		} catch (TransformerConfigurationException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (SAXException e) {
			e.printStackTrace();
		}
		
	}
}

...............................................

I'm injecting the class that I want to use but I'm getting this error.  It
seems like such a simple thing but I'm stumped about what's happening.

Anyone have any ideas?

thanks.

-Bob
-- 
View this message in context: http://www.nabble.com/Error-obtaining-injected-value-for-field-tp19884107p19884107.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Error obtaining injected value for field

Posted by Andy Pahne <ap...@net22.de>.
There are a two things that seem wrong to me:

1. do not instanciate
  

        @Inject
	private XMLBuilder builder;


        @Inject
	private XMLBuilder builder = new XMLBuilder();

    I never instanciate injected thingies and it always works.


2. inject a page like this:

    @InjectPage("path/to/XMLBuilder")
    private XMLBuilder xmlBuilder;


    Is XMLBuilder a page (complete document) or does it produce some XML 
rendererd inside pages? For the latter, I would have made it a component.
  
 
Andy

    




bob_k wrote:
> Hi folks.
>
> It seems to be a simple problem but I cannot figure out what's going on.
>
> I have created an XMLBuilder class that dynamically generates an XML file,
> "XMLBuilder" and when I try to instantiate it in a Tapestry page I'm getting
> this error:
>
> .......................................
>
> # java.lang.ClassNotFoundException
> caught an exception while obtaining a class file for
> com.eveo.edetail.webapp.pages.GenerateXML
>
> exception
>     org.apache.tapestry5.internal.services.TransformationException: Error
> obtaining injected value for field
> com.eveo.edetail.webapp.pages.GenerateXML.builder: No service implements the
> interface com.eveo.edetail.util.XMLBuilder.
>
> # org.apache.tapestry5.internal.services.TransformationException
> Error obtaining injected value for field
> com.eveo.edetail.webapp.pages.GenerateXML.builder: No service implements the
> interface com.eveo.edetail.util.XMLBuilder. 
>
> .......................................
>
> In my Tapestry page, "GenerateXML.java" I have the following simple code.
>
> public class GenerateXML {
>
> 	@Inject
> 	private XMLBuilder builder = new XMLBuilder();
>
> 	void onActivate()
> 	{
> 		try {
> 			builder.generateXML(3);
> 		} catch (TransformerConfigurationException e) {
> 			e.printStackTrace();
> 		} catch (IOException e) {
> 			e.printStackTrace();
> 		} catch (SAXException e) {
> 			e.printStackTrace();
> 		}
> 		
> 	}
> }
>
> ...............................................
>
> I'm injecting the class that I want to use but I'm getting this error.  It
> seems like such a simple thing but I'm stumped about what's happening.
>
> Anyone have any ideas?
>
> thanks.
>
> -Bob
>   


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


Re: Error obtaining injected value for field

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 08 Oct 2008 15:01:31 -0300, bob_k <fa...@gmail.com> escreveu:

> public class GenerateXML {
>
> 	@Inject
> 	private XMLBuilder builder = new XMLBuilder();

Remove the @Inject annotation, as you're instantiating XMLBuilder on the  
spot instead of getting it through Tapestry-Ioc.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
Consultor, desenvolvedor e instrutor em Java
http://www.arsmachina.com.br/thiago

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