Thanks for your answer, but in the doc I found that : By convention, module builder class names end in Module and are final classes.
And my module is : package papo.ioc.services; public final class UserModule { public UserService build() { return new UserServiceImpl(); } } Do we have to use only AppModule and not our custom Module such mine UserModule? Ok for the Manifest, it was a try. 2007/5/30, Howard Lewis Ship <[EMAIL PROTECTED]>:
You don't need the MANIFEST.MF. You do need to name your module correctly, it should be AppModule. The documention is *very clear* on the naming for that. Also, you should consider letting Tapestry IoC inject the Log ( org.apache.commons.logging.Log) for your service; cleans up a lot of code that way. This will be On 5/29/07, Blackwings <[EMAIL PROTECTED]> wrote: > > So, I'm now on 5.04 and I re-read the documentation about ioc to be > sure I didn't do a mistake when I declared my service. > > The module is final and follow the naming convention: > > package papo.ioc.services; > public final class UserModule { > public UserService build() { > return new UserServiceImpl(); > } > } > > And I declared it in the MANIFEST.MF under webroot/META-INF : > > Manifest-Version: 1.0 > Tapestry-Module-Classes: papo.ioc.services.UserModule > > The service interface seems ok: > > package papo.ioc.services; > import papo.exception.PapoException; > import papo.model.User; > public interface UserService { > public User getAuthenticatedUser(String login, String password) > throws PapoException; > } > > The implementation looks normal: > > package papo.ioc.services; > > import org.apache.log4j.Logger; > import papo.dao.UserDao; > import papo.exception.PapoException; > import papo.model.User; > > public class UserServiceImpl implements UserService { > /** Obtain a suitable logger */ > private static Logger logger = > Logger.getLogger(UserServiceImpl.class.getName()); > > public User getAuthenticatedUser(String login, String password) > throws PapoException { > UserDao dao = new UserDao(); > User user = null; > try { > user = dao.searchUser(login, password); > } > catch (PapoException pe) { > logger.error("The authentication has failed !!", pe); > throw new PapoException("The authentication has failed !!"); > } > return user; > } > } > > > and the I use it in my Start page: > > @Inject > @Service("UserService") > private UserService _userService; > > String onSuccess() { > String success = "Home"; > String failure = "Start"; > try { > _user = _userService.getAuthenticatedUser(_login.getLogin(), > _login.getPassword()); > } > catch (PapoException pe) { > _message = "La procedure d'identification a rencontré un probleme > !!"; > return failure; > } > return success; > } > > But I still have the error : > > java.lang.ClassNotFoundException > > caught an exception while obtaining a class file for papo.pages.Start > exception > java.lang.RuntimeException: Error obtaining injected value for field > papo.pages.Start._userService: No service implements the interface > papo.ioc.services.UserService. > > What can I try now? > > 2007/5/29, Blackwings <[EMAIL PROTECTED]>: > > > > I was using the 5.03. I just changed for the 5.04 then I tried your > proposition : > > > > "No service implements the interface papo.ioc.services.UserService." > > > > But my implementation, UserServiceImpl is in the same package than its > interface UserService and implements it. > > The module UserModule that contains the buildUserService method and > return the UserService is also in this package... > > > > What did I miss?? > > > > > > 2007/5/29, Davor Hrg <[EMAIL PROTECTED]>: > > > > > try: > > > @Inject > > > private UserService _userService; > > > > > > you haven't mentioned the version > > > code above is for 5.0.4, I'm not sure for older versions > > > > > > Davor Hrg > > > > > > On 5/29/07, Blackwings <[EMAIL PROTECTED]> wrote: > > > > > > > > Hi, > > > > > > > > I think I'm not using correctly the tapestry-ioc since my page call > itself > > > > my module to get the service implementation instance (as service): > > > > > > > > UserModule > > > > > > > > public class UserModule { > > > > > > > > public static UserService buildUserService() { > > > > return new UserServiceImpl(); > > > > } > > > > } > > > > > > > > UserService > > > > > > > > public interface UserService { > > > > public User getAuthenticatedUser(String login, String password) > throws > > > > PapoException; > > > > } > > > > > > > > UserServiceImpl > > > > > > > > public class UserServiceImpl implements UserService { > > > > public User getAuthenticatedUser(String login, String password) > throws > > > > PapoException { > > > > [code] > > > > return user; > > > > } > > > > > > > > } > > > > > > > > Start > > > > > > > > [code] > > > > private UserService _userService; > > > > > > > > String onSuccess() { > > > > [code here] > > > > _userService = UserModule.buildUserService (); > > > > _user = _userService.getAuthenticatedUser(_login.getLogin(), > > > > _login.getPassword()); > > > > > > > > ****** > > > > > > > > My page call itself the build method... so my page is hardly linked > to the > > > > ioc but this is wrong. > > > > I thought about something like : > > > > > > > > [code] > > > > @InjectService("UserService") > > > > private UserService _userService; > > > > > > > > String onSuccess() { > > > > [code here] > > > > _user = _userService.getAuthenticatedUser(_login.getLogin(), > > > > _login.getPassword()); > > > > > > > > But it doesn't compile and the notation found in the documentaiton : > > > > @Inject > > > > @Service("UserService") > > > > doesn't exist anymore in the tapestry-core... > > > > > > > > Any idea? > > > > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Howard M. Lewis Ship TWD Consulting, Inc. Independent J2EE / Open-Source Java Consultant Creator and PMC Chair, Apache Tapestry Creator, Apache HiveMind Professional Tapestry training, mentoring, support and project work. http://howardlewisship.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]