Your code works for me essentially as written. It could just be weird formatting of the email, but make sure there aren't any blank lines between the @Inject annotations and the field or method it is annotating.
Otherwise, the fact that the error appears to be coming from TraversableLike, which is not involved in any of the code above, makes me think that your problem lies elsewhere. CC On Wed, Nov 20, 2013 at 6:07 PM, Maatary Okouya <[email protected]>wrote: > I'm using scala and Guice, in particular the Assisted Injection. I'm > having a problem with declaring private var my injected field in my client > class. If i declare the constructor injected fields of my client class > private as it can be seen immediately below i get an error: > > *have firstname (Maatary) used with an object that had no public field or > method named firstname or getFirstname (TraversableLike.scala:244)* > > I know that when private, the var gettter and setter are private, but this > is precisely what i want. An injection simply by the constructor and no > access to my field from the exterior. But i got that issue. Any help ? > > trait FieldInjectClientFactory { > > def createFieldInjectCLient(@Assisted("first") afirstname: String, > @Assisted("last") alastname: String):FieldInjectionClient > > } > > > > class FieldInjectionClient private { > > > > private var firstname: String = "" > > private var lastname: String = "" > > @Inject > > val injected: String = "" > > > @Inject > > def this(@Assisted("first") afirstname: String, @Assisted("last") > alastname: String) { > > this() > > firstname = afirstname > > lastname = alastname > > } > > override def toString() : String = { > > "firstname: " + firstname + ", lastname: " + lastname + ", injected: > " + injected > > > > } > > } > > > > class fieldinjectmodule extends AbstractModule { > > def configure() : Unit = { > > bind(classOf[String]).toInstance("test bind") > > val fb = new FactoryModuleBuilder() > > install(fb.build(classOf[FieldInjectClientFactory])) > > } > > } > > > val fieldInjector = Guice.createInjector(new fieldinjectmodule()) > > val factory = fieldInjector.getInstance(classOf[FieldInjectClientFactory]) > val client = factory.createFieldInjectCLient("Maatary", "Okouya") > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/google-guice. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-guice. For more options, visit https://groups.google.com/groups/opt_out.
