T5 tapestry-hibernate error?
Something wired when tapestry try to get the HibernateSession : Error invoking service builder method org.apache.tapestry.hibernate.HibernateModule.build(HibernateSessionSource, ThreadCleanupHub) (at HibernateModule.java:62) (for service 'HibernateSessionManager'): Exception constructing service 'HibernateSessionSource': Error invoking constructor org.apache.tapestry.internal.hibernate.HibernateSessionSourceImpl(Log, Collection, ClassNameLocator) (at HibernateSessionSourceImpl.java:35) (for service 'HibernateSessionSource'): No service implements the interface org.apache.commons.logging.Log. java.lang.RuntimeException No service implements the interface org.apache.commons.logging.Log. Stack trace - org.apache.tapestry.ioc.internal.RegistryImpl.getService( RegistryImpl.java:553) - org.apache.tapestry.ioc.internal.services.MasterObjectProviderImpl.provide (MasterObjectProviderImpl.java:46) - org.apache.tapestry.ioc.internal.RegistryImpl.getObject( RegistryImpl.java:665) - org.apache.tapestry.ioc.internal.RegistryImpl.getObject( RegistryImpl.java:722) - org.apache.tapestry.ioc.internal.ObjectLocatorImpl.getObject( ObjectLocatorImpl.java:50) - org.apache.tapestry.ioc.internal.util.InternalUtils.calculateParameterValue (InternalUtils.java:217) - org.apache.tapestry.ioc.internal.util.InternalUtils.calculateParameters (InternalUtils.java:248) - org.apache.tapestry.ioc.internal.util.InternalUtils.calculateParametersForConstructor (InternalUtils.java:235) - org.apache.tapestry.ioc.internal.ConstructorServiceCreator.createObject (ConstructorServiceCreator.java:46) - org.apache.tapestry.ioc.internal.SingletonServiceLifecycle.createService (SingletonServiceLifecycle.java:31) - org.apache.tapestry.ioc.internal.LifecycleWrappedServiceCreator.createObject (LifecycleWrappedServiceCreator.java:54) - org.apache.tapestry.ioc.internal.InterceptorStackBuilder.createObject( InterceptorStackBuilder.java:54) - org.apache.tapestry.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject (RecursiveServiceCreationCheckWrapper.java:61) - org.apache.tapestry.ioc.internal.services.JustInTimeObjectCreator.createObject (JustInTimeObjectCreator.java:67) - org.apache.tapestry.internal.hibernate.HibernateSessionManagerImpl .init(HibernateSessionManagerImpl.java:31) - org.apache.tapestry.hibernate.HibernateModule.build( HibernateModule.java:62) - sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - sun.reflect.NativeMethodAccessorImpl.invoke( NativeMethodAccessorImpl.java:39) - sun.reflect.DelegatingMethodAccessorImpl.invoke( DelegatingMethodAccessorImpl.java:25) - java.lang.reflect.Method.invoke(Method.java:585) - org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvoker.createObject (ServiceBuilderMethodInvoker.java:76) - org.apache.tapestry.ioc.internal.services.PerThreadServiceCreator.initialValue (PerThreadServiceCreator.java:50) - java.lang.ThreadLocal$ThreadLocalMap.getAfterMiss(ThreadLocal.java :374) - java.lang.ThreadLocal$ThreadLocalMap.get(ThreadLocal.java:347) - java.lang.ThreadLocal$ThreadLocalMap.access$000(ThreadLocal.java :225) - java.lang.ThreadLocal.get(ThreadLocal.java:127) - org.apache.tapestry.ioc.internal.services.PerThreadServiceCreator.createObject (PerThreadServiceCreator.java:56) - papo.dao.impl.UserDaoImpl.getUser(UserDaoImpl.java:35) The origin of the problem is when trying to getSession() : public class UserDaoImpl implements UserDao { private static Log log = LogFactory.getLog(UserDaoImpl.class); private Session session; public Session getSession() { return session; } public void setSession(Session session) { this.session = session; } public UserDaoImpl(Session session) { setSession(session); } /** * Récupére un User pour un login et password donné * * @param login * @param password * @return Operateur */ public User getUser(String login, String password) { log.debug(Recherche du User login : + login); try { Query q = getSession().createQuery(from User u where u.login = :login and u.password = :pwd); ... } Tapestry-ioc is responsible to get the constructor call : public static void bind(ServiceBinder binder) { ... binder.bind(UserDao.class, UserDaoImpl.class); ... } No idea, still investigating. I tried to clear tomcat cache, check the libraries... maybe something missing somewhere. T5.0.6 for core/annotation and ioc and T5.0.5 for tapestry-hibernate, maybe it is that the problem. -- Michael Bernagou Java Developper
Re: T5 tapestry-hibernate error?
Ok, the problem is the lib version. So, synchronized all the libraries versions :D 2007/12/18, Michael Bernagou [EMAIL PROTECTED]: Something wired when tapestry try to get the HibernateSession : Error invoking service builder method org.apache.tapestry.hibernate.HibernateModule.build(HibernateSessionSource, ThreadCleanupHub) (at HibernateModule.java:62) (for service 'HibernateSessionManager'): Exception constructing service 'HibernateSessionSource': Error invoking constructor org.apache.tapestry.internal.hibernate.HibernateSessionSourceImpl(Log, Collection, ClassNameLocator) (at HibernateSessionSourceImpl.java:35) (for service 'HibernateSessionSource'): No service implements the interface org.apache.commons.logging.Log. java.lang.RuntimeException No service implements the interface org.apache.commons.logging.Log. Stack trace - org.apache.tapestry.ioc.internal.RegistryImpl.getService( RegistryImpl.java:553) - org.apache.tapestry.ioc.internal.services.MasterObjectProviderImpl.provide (MasterObjectProviderImpl.java :46) - org.apache.tapestry.ioc.internal.RegistryImpl.getObject( RegistryImpl.java:665) - org.apache.tapestry.ioc.internal.RegistryImpl.getObject( RegistryImpl.java:722) - org.apache.tapestry.ioc.internal.ObjectLocatorImpl.getObject ( ObjectLocatorImpl.java:50) - org.apache.tapestry.ioc.internal.util.InternalUtils.calculateParameterValue (InternalUtils.java:217) - org.apache.tapestry.ioc.internal.util.InternalUtils.calculateParameters (InternalUtils.java :248) - org.apache.tapestry.ioc.internal.util.InternalUtils.calculateParametersForConstructor (InternalUtils.java:235) - org.apache.tapestry.ioc.internal.ConstructorServiceCreator.createObject (ConstructorServiceCreator.java :46) - org.apache.tapestry.ioc.internal.SingletonServiceLifecycle.createService (SingletonServiceLifecycle.java:31) - org.apache.tapestry.ioc.internal.LifecycleWrappedServiceCreator.createObject (LifecycleWrappedServiceCreator.java :54) - org.apache.tapestry.ioc.internal.InterceptorStackBuilder.createObject (InterceptorStackBuilder.java:54) - org.apache.tapestry.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject (RecursiveServiceCreationCheckWrapper.java :61) - org.apache.tapestry.ioc.internal.services.JustInTimeObjectCreator.createObject (JustInTimeObjectCreator.java:67) - org.apache.tapestry.internal.hibernate.HibernateSessionManagerImpl .init(HibernateSessionManagerImpl.java :31) - org.apache.tapestry.hibernate.HibernateModule.build( HibernateModule.java:62) - sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - sun.reflect.NativeMethodAccessorImpl.invoke( NativeMethodAccessorImpl.java :39) - sun.reflect.DelegatingMethodAccessorImpl.invoke( DelegatingMethodAccessorImpl.java:25) - java.lang.reflect.Method.invoke(Method.java:585) - org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvoker.createObject( ServiceBuilderMethodInvoker.java:76) - org.apache.tapestry.ioc.internal.services.PerThreadServiceCreator.initialValue (PerThreadServiceCreator.java:50) - java.lang.ThreadLocal$ThreadLocalMap.getAfterMiss(ThreadLocal.java:374) - java.lang.ThreadLocal$ThreadLocalMap.get(ThreadLocal.java:347) - java.lang.ThreadLocal$ThreadLocalMap.access$000(ThreadLocal.java :225) - java.lang.ThreadLocal.get(ThreadLocal.java:127) - org.apache.tapestry.ioc.internal.services.PerThreadServiceCreator.createObject( PerThreadServiceCreator.java:56) - papo.dao.impl.UserDaoImpl.getUser(UserDaoImpl.java:35) The origin of the problem is when trying to getSession() : public class UserDaoImpl implements UserDao { private static Log log = LogFactory.getLog(UserDaoImpl.class); private Session session; public Session getSession() { return session; } public void setSession(Session session) { this.session = session; } public UserDaoImpl(Session session) { setSession(session); } /** * Récupére un User pour un login et password donné * * @param login * @param password * @return Operateur */ public User getUser(String login, String password) { log.debug(Recherche du User login : + login); try { Query q = getSession().createQuery(from User u where u.login= :login and u.password = :pwd); ... } Tapestry-ioc is responsible to get the constructor call : public static void bind(ServiceBinder binder) { ... binder.bind(UserDao.class, UserDaoImpl.class); ... } No idea, still investigating. I tried to clear tomcat cache, check the libraries... maybe something missing somewhere. T5.0.6 for core/annotation and ioc and T5.0.5 for tapestry-hibernate, maybe it is that the problem. -- Michael Bernagou Java Developper
Re: IoC global question
Hi Hugo, It is exactly that and I didn't understand how to do that. Whatever I test, it works but it is intrusive. I re-read the documentation about tapestry-ioc and I still not understand how to do that. I need an example of webapp with 3 layers around the ioc to see how tapestry-ioc gives the services instance to the layers. @Thiago, I read this part but I don't know enought Spring to decide if tapestry-ioc is really better than Spring. I'm not sure better is the word. I would prefer more adapt for Tapestry webapp but it's just my feelling. Just to argue a little more, if it is really better, why the way to use service injection is different between ioc - MVC and ioc - DAO or ioc - WS (example, declare a Logger in these all 3 layers and compare the howto)? Learning a way to do the same thing for each layer is not something better. I'm quite sure it can be better than Spring but for some developper, XML is better than Pojo... just a point of view ;o) For now, I want to try to use Tapestry-ioc because I think again it is more adapt to my needs 2007/12/14, Hugo Palma [EMAIL PROTECTED]: m, i think there's something missing here If i'm understanding correctly you want tapestry-ioc to manage all your services (either presentation stuf, db stuff, etc) and you don't want it to be intrusive. You don't want to reference any tapestry-ioc API inside you service classes. Does that describe the problem ? If so, tapestry-ioc can solve your problem really easily. Michael Bernagou wrote: So I have to call the current Registry (or to manage it myself) and call the myRegistry.getService(MyService.class); Hum, I think it's not ioc anymore if I have to setup my containers (Axis2, Hibernate) to call the tapestry-ioc or I have to create a sort of middle layer between the layer and the tapestry-ioc, and then my classes have to call this middleLayer... hum... How do you do yourself? Webapp have usually more than just a MVC layer. Are you using the tapestry-ioc only for the MVC layer? Its seems to me strange for one class having to use @Inject Logger log; and for another class Logger log = Logger.getLogger( ApplicationDaoImpl.class.getName()); 2 ways to get the logger in the same application for the same target log file... Maybe tapestry-ioc should be extended to take care also to the other layers. Maybe I'm totally wrong ;o) so, how should it be coded to respect ioc pattern between tapestr-ioc and other layers such as Axis2 and Hibernate3 (for T5 we know ;o) ) Thanks 2007/12/14, Michael Bernagou [EMAIL PROTECTED]: Ok I'm going to investigate about that Registry. So, what's the interrest to use tapestry-ioc instead of Spring ioc? If I need my ioc to provide all the services I need, I cannot use tapestry-ioc unless I need my other layers to call explicitely the ioc which is not recommended when you want independant layers working together. @Hugo, ok I'm going to reread again this part. 2007/12/14, Kristian Marinkovic [EMAIL PROTECTED] : hi michael, @Inject only works in Tapestry pages and components (and mixins). By default Tapestry will use the field type as an id and lookup the corresponding ioc service. I assume your Web Service Container was not started by the ioc container so it runs outside its control. Therefore you have to first obtain an ioc Registry first and then ask it explicitly for the service you want to call. The builder methods are not meant to be called except by the container :) g, kris Michael Bernagou [EMAIL PROTECTED] 14.12.2007 10:51 Bitte antworten an Tapestry users users@tapestry.apache.org An Tapestry users users@tapestry.apache.org Kopie Thema IoC global question Hi, I have a sort of general question about tapestry-ioc. In fact, I would like it to manage all the services of my webapp. In theory it should be the case, shouldn't be? So to provides services to my MVC, no problem the syntax @Inject MyService _myService; work perfectly. But, to provide services the same way for my Dao it's different. The same syntax doesn't provide any instance. I used the tapestry-hibernate and declare my dao as services : import org.hibernate.Session; public static UserDao buildUserDao(@InjectService(Session) Session session) { return new UserDaoImpl(session); } public static UserService buildUserService(@InjectService(UserDao) UserDao dao) { return new UserServiceImpl(dao); } So my implementation can work. But to use the service, all the callers have to know a session object! Ok, if my caller is a web service, and this web service want to call the UserService, @Inject UserService _userService; DOES NOT work and _userService is null! So I have to call explicitely the builder of my service FROM the web service... If I do that, I bypass the IoC purpose
Re: IoC global question
Sorry, I'm trying to understand enough well to develop my application correctly. So, imagine I have 2 classes ClassA and ClassB from 2 differents layers. With the IoC in ClassA I should have just a member named ServiceClassB sab with its getter and setter. ServiceClassB is the interface ClassB implements. Then the IoC should have the role to create the ClassB instance and call classA.setServiceClassB(classBInstance). But, today in my MVC I have to do that in ClassA : public class ClassA { @Inject ServiceClassB scb; String onSuccess() { User user = scb.getAuthenticatedUser(...); ... } } is THE way to use the IoC? This is an example for pages. I think it's ok but what about this second example, out of pages. So I need to create a ServiceFactory class. public class ServiceFactory { private ServiceClassB scb; private static ServiceFactory instance; static { instance = new ServiceFactory(); } public static ServiceFactory getInstance() { return instance; } private ServiceFactory() { scb = new ClassB(); } public ServiceClassB getSab() { return scb; } } In a ClassA (not anymore a Tapestry page) I have to do that : public class ClassA { private ServiceClassB sab; public ServiceClassB getSab() { return sab; } public void setSab(ServiceClassB sab) { this.sab = sab; } public String aMethod() { sab = ServiceFactory.getInstance().getUserService(); User user = sab.getAuthenticatedUser(...); ... } } I think this is not IoC. It's just management of services. So my goal is to make that IoC and something have to call setSab for me, or maybe it's should be the role of the ServiceFactory? Regarding what Hugo explained to me, (thanks a lot for your time!) one of the way is this : public class UserModule { public static ServiceClassB build(ServiceUserDao userDao){ ClassB cb = new ClassB(userDao); return cb; } public static ServiceUserDao build() { UserDao dao = new UserDao(); return dao; } } But I still don't know how to implement ClassA to get my ServiceClassB instance provided by the IoC. I cannot call the Module without creating a strong link between ClassA and the IoC, or maybe I have to create this link?? In my mind, nothing have to call the IoC since it's the IoC who should call the classes. So I have to say to the IoC which class need it and for now I just know how to tell the IoC which Services I have and the dependencies they have. Or maybe, I'm completely wrong, lol, and in fact the role of IoC is just to expose services to make them available to the all application and I have in ClassA to call explicitely the services via their builder in the module and use them via their interface! 2007/12/17, Hugo Palma [EMAIL PROTECTED]: Ok, as you can see in the tapestry-ioc documentation there are three ways of injecting dependencies into services. Only one of them is actually intrusive, the As parameters to the service implementation class' constructor (for autobuilt services) one. If you use this way then you will need to use the Inject annotation in your service implementation class which will create the dependency you don't want. So, this leaves you with the other two choices. The As parameters to the service builder method way has an example right in the beginning of the Injecting Dependencies sections of the docs. This way your service class can be completely independent of your IoC container. All the injection stuff is done in the module builder class. All you have to do is declare the dependencies in your service build method in the module builder and use the service class setters to set it's dependencies. Finally, you can use the As parameters passed to the constructor of the service's module builder (cached inside instance variables) way. This in not intrusive also because, again, all the injection stuff is done in the module builder. Only this time instead of the dependencies being injected as parameters in the build method they are injected in you module builder class constructor. Hope this helps... Michael Bernagou wrote: Hi Hugo, It is exactly that and I didn't understand how to do that. Whatever I test, it works but it is intrusive. I re-read the documentation about tapestry-ioc and I still not understand how to do that. I need an example of webapp with 3 layers around the ioc to see how tapestry-ioc gives the services instance to the layers. @Thiago, I read this part but I don't know enought Spring to decide if tapestry-ioc is really better than Spring. I'm not sure better is the word. I would prefer more adapt for Tapestry webapp but it's just my feelling. Just to argue a little more, if it is really better, why the way to use service injection is different between ioc - MVC and ioc - DAO or ioc - WS (example, declare a Logger in these all 3 layers and compare the howto)? Learning a way to do
Re: IoC global question
Thanks for the TYPO Thiago. Also thanks for the project examples, I'll need to wait beeing at home to test since the security system here at the office block them to be download. Making my ClassA a service? I'm going to try but it means ClassA will be instanciate only by Tapestry-ioc else I will not have my ServiceClassB instance (imagine a ClassC needs an instance of ClassA and doesn't care about services, will I have to make ClassC also a service??). And what about a custom ServiceFactory singleton class that call the Registry to get instances and/or be a sort of Global Service referenced in Tapestry-Ioc? Again, to create a Service is not a problem, my problem is to call them from layers without the @Inject which work only from tapestry-core but without making a link between the layer and tapestry-ioc. The only link I wish is between tapestry-ioc and layers in this order. ioc knows the layers, but the layers don't know the ioc, only the service. Still reading the documentation... 2007/12/17, Thiago H de Paula Figueiredo [EMAIL PROTECTED]: On Mon, 17 Dec 2007 08:33:52 -0200, Michael Bernagou [EMAIL PROTECTED] wrote: public class UserModule { public static ServiceClassB build(ServiceUserDao userDao){ ClassB cb = new ClassB(userDao); return cb; } public static ServiceUserDao build() { UserDao dao = new UserDao(); return dao; } } But I still don't know how to implement ClassA to get my ServiceClassB instance provided by the IoC. 1) Rename your build() method to buildServiceUserDao. 2) Your ClassA builder method would be something like that: public static ClassA buildClassA(ServiceClassB serviceClassB) { ServiceClassB object = new ServiceClassBImplementation(); object.setServiceClassB(serviceClassB); return object; } -- Thiago H. de Paula Figueiredo Desenvolvedor, Instrutor e Consultor de Tecnologia Eteg Tecnologia da Informação Ltda. http://www.eteg.com.br - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Michael Bernagou Java Developper
IoC global question
Hi, I have a sort of general question about tapestry-ioc. In fact, I would like it to manage all the services of my webapp. In theory it should be the case, shouldn't be? So to provides services to my MVC, no problem the syntax @Inject MyService _myService; work perfectly. But, to provide services the same way for my Dao it's different. The same syntax doesn't provide any instance. I used the tapestry-hibernate and declare my dao as services : import org.hibernate.Session; public static UserDao buildUserDao(@InjectService(Session) Session session) { return new UserDaoImpl(session); } public static UserService buildUserService(@InjectService(UserDao) UserDao dao) { return new UserServiceImpl(dao); } So my implementation can work. But to use the service, all the callers have to know a session object! Ok, if my caller is a web service, and this web service want to call the UserService, @Inject UserService _userService; DOES NOT work and _userService is null! So I have to call explicitely the builder of my service FROM the web service... If I do that, I bypass the IoC purpose because I link it directly : UserService us = AppModule.buildUserService( ... and then I have a problem! buildUserService need a UserDao, but my web service doesn't care about knowing any kind of dao! So, I should be able to use @Inject MyService _myService; anywhere in my project and the tapestry-ioc should be able to give instance to all the class... Did I (probably) missed something? -- Michael Bernagou Java Developper
Re: IoC global question
So I have to call the current Registry (or to manage it myself) and call the myRegistry.getService(MyService.class); Hum, I think it's not ioc anymore if I have to setup my containers (Axis2, Hibernate) to call the tapestry-ioc or I have to create a sort of middle layer between the layer and the tapestry-ioc, and then my classes have to call this middleLayer... hum... How do you do yourself? Webapp have usually more than just a MVC layer. Are you using the tapestry-ioc only for the MVC layer? Its seems to me strange for one class having to use @Inject Logger log; and for another class Logger log = Logger.getLogger( ApplicationDaoImpl.class.getName()); 2 ways to get the logger in the same application for the same target log file... Maybe tapestry-ioc should be extended to take care also to the other layers. Maybe I'm totally wrong ;o) so, how should it be coded to respect ioc pattern between tapestr-ioc and other layers such as Axis2 and Hibernate3 (for T5 we know ;o) ) Thanks 2007/12/14, Michael Bernagou [EMAIL PROTECTED]: Ok I'm going to investigate about that Registry. So, what's the interrest to use tapestry-ioc instead of Spring ioc? If I need my ioc to provide all the services I need, I cannot use tapestry-ioc unless I need my other layers to call explicitely the ioc which is not recommended when you want independant layers working together. @Hugo, ok I'm going to reread again this part. 2007/12/14, Kristian Marinkovic [EMAIL PROTECTED] : hi michael, @Inject only works in Tapestry pages and components (and mixins). By default Tapestry will use the field type as an id and lookup the corresponding ioc service. I assume your Web Service Container was not started by the ioc container so it runs outside its control. Therefore you have to first obtain an ioc Registry first and then ask it explicitly for the service you want to call. The builder methods are not meant to be called except by the container :) g, kris Michael Bernagou [EMAIL PROTECTED] 14.12.2007 10:51 Bitte antworten an Tapestry users users@tapestry.apache.org An Tapestry users users@tapestry.apache.org Kopie Thema IoC global question Hi, I have a sort of general question about tapestry-ioc. In fact, I would like it to manage all the services of my webapp. In theory it should be the case, shouldn't be? So to provides services to my MVC, no problem the syntax @Inject MyService _myService; work perfectly. But, to provide services the same way for my Dao it's different. The same syntax doesn't provide any instance. I used the tapestry-hibernate and declare my dao as services : import org.hibernate.Session; public static UserDao buildUserDao(@InjectService(Session) Session session) { return new UserDaoImpl(session); } public static UserService buildUserService(@InjectService(UserDao) UserDao dao) { return new UserServiceImpl(dao); } So my implementation can work. But to use the service, all the callers have to know a session object! Ok, if my caller is a web service, and this web service want to call the UserService, @Inject UserService _userService; DOES NOT work and _userService is null! So I have to call explicitely the builder of my service FROM the web service... If I do that, I bypass the IoC purpose because I link it directly : UserService us = AppModule.buildUserService ( ... and then I have a problem! buildUserService need a UserDao, but my web service doesn't care about knowing any kind of dao! So, I should be able to use @Inject MyService _myService; anywhere in my project and the tapestry-ioc should be able to give instance to all the class... Did I (probably) missed something? -- Michael Bernagou Java Developper -- Michael Bernagou Java Developper -- Michael Bernagou Java Developper
Re: IoC global question
Ok I'm going to investigate about that Registry. So, what's the interrest to use tapestry-ioc instead of Spring ioc? If I need my ioc to provide all the services I need, I cannot use tapestry-ioc unless I need my other layers to call explicitely the ioc which is not recommended when you want independant layers working together. @Hugo, ok I'm going to reread again this part. 2007/12/14, Kristian Marinkovic [EMAIL PROTECTED]: hi michael, @Inject only works in Tapestry pages and components (and mixins). By default Tapestry will use the field type as an id and lookup the corresponding ioc service. I assume your Web Service Container was not started by the ioc container so it runs outside its control. Therefore you have to first obtain an ioc Registry first and then ask it explicitly for the service you want to call. The builder methods are not meant to be called except by the container :) g, kris Michael Bernagou [EMAIL PROTECTED] 14.12.2007 10:51 Bitte antworten an Tapestry users users@tapestry.apache.org An Tapestry users users@tapestry.apache.org Kopie Thema IoC global question Hi, I have a sort of general question about tapestry-ioc. In fact, I would like it to manage all the services of my webapp. In theory it should be the case, shouldn't be? So to provides services to my MVC, no problem the syntax @Inject MyService _myService; work perfectly. But, to provide services the same way for my Dao it's different. The same syntax doesn't provide any instance. I used the tapestry-hibernate and declare my dao as services : import org.hibernate.Session; public static UserDao buildUserDao(@InjectService(Session) Session session) { return new UserDaoImpl(session); } public static UserService buildUserService(@InjectService(UserDao) UserDao dao) { return new UserServiceImpl(dao); } So my implementation can work. But to use the service, all the callers have to know a session object! Ok, if my caller is a web service, and this web service want to call the UserService, @Inject UserService _userService; DOES NOT work and _userService is null! So I have to call explicitely the builder of my service FROM the web service... If I do that, I bypass the IoC purpose because I link it directly : UserService us = AppModule.buildUserService( ... and then I have a problem! buildUserService need a UserDao, but my web service doesn't care about knowing any kind of dao! So, I should be able to use @Inject MyService _myService; anywhere in my project and the tapestry-ioc should be able to give instance to all the class... Did I (probably) missed something? -- Michael Bernagou Java Developper -- Michael Bernagou Java Developper
Re: CustomFilter
Yes exactly. I want to put the management of session lifecycle and transaction and commit in a filter. I don't want to use the Tapestry-hibernate right now since I'm new in Hibernate and want to integrate it by myself first but ok, I'm going to follow your clue and take a look at the source of RequestFilter ;) 2007/12/13, Kristian Marinkovic [EMAIL PROTECTED]: hi michael, are you trying to implement OpenSessionInView by yourself? tapestry-hibernate integration does it by default... you can take a look at the source to see where you can apply filter the tapestry way :) (see RequestFilter interface in Tapestry for example) g, kris Michael Bernagou [EMAIL PROTECTED] 12.12.2007 13:59 Bitte antworten an Tapestry users users@tapestry.apache.org An Tapestry users users@tapestry.apache.org Kopie Thema Re: CustomFilter In fact, I just noticed when I added the tapestry-core-5.0.6.jar in [tomcat]/common/lib I still have an error but NOT on the same class. So before it was on : java.lang.NoClassDefFoundError: org/apache/tapestry/TapestryFilter After put the tapestry-core jar in the lib of Tomcat : java.lang.NoClassDefFoundError: org/apache/tapestry/ioc/services/SymbolProvider So I added the tapestry-ioc jar and now I have this one : java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory I imagine I could put all the lib at the server side, BUT, it's not how it should work!! It seems the ClassLoader didn't load all the libs when apply the filter, so how to force the loading? Why TapestryFilter doesn't have the same problem than my CustomFilter?? 2007/12/12, Michael Bernagou [EMAIL PROTECTED]: Hum, any idea? 2007/12/11, Michael Bernagou [EMAIL PROTECTED]: The error is generated by this line offcourse : private TapestryFilter tapestryFilter = new TapestryFilter(); Still doesn't know why... 2007/12/11, Michael Bernagou [EMAIL PROTECTED]: Hi, I tried to creat emy own filter, a Hibernate filter in fact, like that : [code] // here the imports... compilation ok public class HibernateFilter implements Filter { private TapestryFilter tapestryFilter = new TapestryFilter(); private static Log log = LogFactory.getLog(HibernateFilter.class); public void init(FilterConfig filterConfig) throws ServletException { log.info(Servlet filter init, now opening/closing a Session for each request.); tapestryFilter.init(filterConfig); } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try { HibernateUtil.beginTransaction(); chain.doFilter(request, response); HibernateUtil.commitTransaction(); } catch (RuntimeException e) { HibernateUtil.rollbackTransaction (); throw e; } catch (Exception e) { HibernateUtil.rollbackTransaction(); throw new ServletException(e); } finally { HibernateUtil.closeSession (); } tapestryFilter.doFilter(request, response, chain); } public void destroy() { tapestryFilter.destroy(); } } [/code] then I adapt my web.xml like that : [code] filter filter-nameapp/filter-name filter-classorg.hibernate.util.HibernateFilter /filter-class /filter filter-mapping filter-nameapp/filter-name url-pattern/*/url-pattern /filter-mapping [/code] But I get that ERROR at runtime : [code] 11-Dec-2007 16:48:12 org.apache.catalina.core.StandardContextfilterStart SEVERE: Exception starting filter app java.lang.NoClassDefFoundError: org/apache/tapestry/TapestryFilter [/code] TapestryFilter is not loaded by the ClassLoader. Why and how can I do that? I tried to test by put the tapestry-core.jar directly in [ tomcat5.5]/common/lib without success. Any idea? Thanks! -- Michael Bernagou Java Developper -- Michael Bernagou Java Developper -- Michael Bernagou Java Developper -- Michael Bernagou Java Developper -- Michael Bernagou Java Developper
Re: CustomFilter
Hum, any idea? 2007/12/11, Michael Bernagou [EMAIL PROTECTED]: The error is generated by this line offcourse : private TapestryFilter tapestryFilter = new TapestryFilter(); Still doesn't know why... 2007/12/11, Michael Bernagou [EMAIL PROTECTED]: Hi, I tried to creat emy own filter, a Hibernate filter in fact, like that : [code] // here the imports... compilation ok public class HibernateFilter implements Filter { private TapestryFilter tapestryFilter = new TapestryFilter(); private static Log log = LogFactory.getLog(HibernateFilter.class); public void init(FilterConfig filterConfig) throws ServletException { log.info(Servlet filter init, now opening/closing a Session for each request.); tapestryFilter.init(filterConfig); } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try { HibernateUtil.beginTransaction(); chain.doFilter(request, response); HibernateUtil.commitTransaction(); } catch (RuntimeException e) { HibernateUtil.rollbackTransaction (); throw e; } catch (Exception e) { HibernateUtil.rollbackTransaction(); throw new ServletException(e); } finally { HibernateUtil.closeSession (); } tapestryFilter.doFilter(request, response, chain); } public void destroy() { tapestryFilter.destroy(); } } [/code] then I adapt my web.xml like that : [code] filter filter-nameapp/filter-name filter-classorg.hibernate.util.HibernateFilter/filter-class /filter filter-mapping filter-nameapp/filter-name url-pattern/*/url-pattern /filter-mapping [/code] But I get that ERROR at runtime : [code] 11-Dec-2007 16:48:12 org.apache.catalina.core.StandardContextfilterStart SEVERE: Exception starting filter app java.lang.NoClassDefFoundError: org/apache/tapestry/TapestryFilter [/code] TapestryFilter is not loaded by the ClassLoader. Why and how can I do that? I tried to test by put the tapestry-core.jar directly in [ tomcat5.5]/common/lib without success. Any idea? Thanks! -- Michael Bernagou Java Developper -- Michael Bernagou Java Developper -- Michael Bernagou Java Developper
Re: CustomFilter
In fact, I just noticed when I added the tapestry-core-5.0.6.jar in [tomcat]/common/lib I still have an error but NOT on the same class. So before it was on : java.lang.NoClassDefFoundError: org/apache/tapestry/TapestryFilter After put the tapestry-core jar in the lib of Tomcat : java.lang.NoClassDefFoundError: org/apache/tapestry/ioc/services/SymbolProvider So I added the tapestry-ioc jar and now I have this one : java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory I imagine I could put all the lib at the server side, BUT, it's not how it should work!! It seems the ClassLoader didn't load all the libs when apply the filter, so how to force the loading? Why TapestryFilter doesn't have the same problem than my CustomFilter?? 2007/12/12, Michael Bernagou [EMAIL PROTECTED]: Hum, any idea? 2007/12/11, Michael Bernagou [EMAIL PROTECTED]: The error is generated by this line offcourse : private TapestryFilter tapestryFilter = new TapestryFilter(); Still doesn't know why... 2007/12/11, Michael Bernagou [EMAIL PROTECTED]: Hi, I tried to creat emy own filter, a Hibernate filter in fact, like that : [code] // here the imports... compilation ok public class HibernateFilter implements Filter { private TapestryFilter tapestryFilter = new TapestryFilter(); private static Log log = LogFactory.getLog(HibernateFilter.class); public void init(FilterConfig filterConfig) throws ServletException { log.info(Servlet filter init, now opening/closing a Session for each request.); tapestryFilter.init(filterConfig); } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try { HibernateUtil.beginTransaction(); chain.doFilter(request, response); HibernateUtil.commitTransaction(); } catch (RuntimeException e) { HibernateUtil.rollbackTransaction (); throw e; } catch (Exception e) { HibernateUtil.rollbackTransaction(); throw new ServletException(e); } finally { HibernateUtil.closeSession (); } tapestryFilter.doFilter(request, response, chain); } public void destroy() { tapestryFilter.destroy(); } } [/code] then I adapt my web.xml like that : [code] filter filter-nameapp/filter-name filter-classorg.hibernate.util.HibernateFilter /filter-class /filter filter-mapping filter-nameapp/filter-name url-pattern/*/url-pattern /filter-mapping [/code] But I get that ERROR at runtime : [code] 11-Dec-2007 16:48:12 org.apache.catalina.core.StandardContextfilterStart SEVERE: Exception starting filter app java.lang.NoClassDefFoundError: org/apache/tapestry/TapestryFilter [/code] TapestryFilter is not loaded by the ClassLoader. Why and how can I do that? I tried to test by put the tapestry-core.jar directly in [ tomcat5.5]/common/lib without success. Any idea? Thanks! -- Michael Bernagou Java Developper -- Michael Bernagou Java Developper -- Michael Bernagou Java Developper -- Michael Bernagou Java Developper
CustomFilter
Hi, I tried to creat emy own filter, a Hibernate filter in fact, like that : [code] // here the imports... compilation ok public class HibernateFilter implements Filter { private TapestryFilter tapestryFilter = new TapestryFilter(); private static Log log = LogFactory.getLog(HibernateFilter.class); public void init(FilterConfig filterConfig) throws ServletException { log.info(Servlet filter init, now opening/closing a Session for each request.); tapestryFilter.init(filterConfig); } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try { HibernateUtil.beginTransaction(); chain.doFilter(request, response); HibernateUtil.commitTransaction(); } catch (RuntimeException e) { HibernateUtil.rollbackTransaction(); throw e; } catch (Exception e) { HibernateUtil.rollbackTransaction(); throw new ServletException(e); } finally { HibernateUtil.closeSession(); } tapestryFilter.doFilter(request, response, chain); } public void destroy() { tapestryFilter.destroy(); } } [/code] then I adapt my web.xml like that : [code] filter filter-nameapp/filter-name filter-classorg.hibernate.util.HibernateFilter/filter-class /filter filter-mapping filter-nameapp/filter-name url-pattern/*/url-pattern /filter-mapping [/code] But I get that ERROR at runtime : [code] 11-Dec-2007 16:48:12 org.apache.catalina.core.StandardContext filterStart SEVERE: Exception starting filter app java.lang.NoClassDefFoundError: org/apache/tapestry/TapestryFilter [/code] TapestryFilter is not loaded by the ClassLoader. Why and how can I do that? I tried to test by put the tapestry-core.jar directly in [tomcat5.5]/common/lib without success. Any idea? Thanks! -- Michael Bernagou Java Developper
Re: CustomFilter
The error is generated by this line offcourse : private TapestryFilter tapestryFilter = new TapestryFilter(); Still doesn't know why... 2007/12/11, Michael Bernagou [EMAIL PROTECTED]: Hi, I tried to creat emy own filter, a Hibernate filter in fact, like that : [code] // here the imports... compilation ok public class HibernateFilter implements Filter { private TapestryFilter tapestryFilter = new TapestryFilter(); private static Log log = LogFactory.getLog(HibernateFilter.class); public void init(FilterConfig filterConfig) throws ServletException { log.info(Servlet filter init, now opening/closing a Session for each request.); tapestryFilter.init(filterConfig); } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try { HibernateUtil.beginTransaction(); chain.doFilter(request, response); HibernateUtil.commitTransaction(); } catch (RuntimeException e) { HibernateUtil.rollbackTransaction (); throw e; } catch (Exception e) { HibernateUtil.rollbackTransaction(); throw new ServletException(e); } finally { HibernateUtil.closeSession (); } tapestryFilter.doFilter(request, response, chain); } public void destroy() { tapestryFilter.destroy(); } } [/code] then I adapt my web.xml like that : [code] filter filter-nameapp/filter-name filter-classorg.hibernate.util.HibernateFilter/filter-class /filter filter-mapping filter-nameapp/filter-name url-pattern/*/url-pattern /filter-mapping [/code] But I get that ERROR at runtime : [code] 11-Dec-2007 16:48:12 org.apache.catalina.core.StandardContext filterStart SEVERE: Exception starting filter app java.lang.NoClassDefFoundError: org/apache/tapestry/TapestryFilter [/code] TapestryFilter is not loaded by the ClassLoader. Why and how can I do that? I tried to test by put the tapestry-core.jar directly in [tomcat5.5]/common/lib without success. Any idea? Thanks! -- Michael Bernagou Java Developper -- Michael Bernagou Java Developper
Re: Tapestry 5: running tutoriel
Just to say her problem is fixed since she's my collegue. The Eclipse we use here is a custom (crap) Eclipse and jetty and maven plugins do not work normally. She used a normal Eclipse 3.2 WTP with the regular plugins (plus some proxy configuration) and it now it works. 2007/11/14, Jeffrey ai [EMAIL PROTECTED]: Eli, Your mvn command should run without any manual download or settings. I have seen the similar error message before. My problem is caused by a broken maven plugin in my local repository, which is gotten from our incorrectly-configured repository server. I would suggest you to try the following things: * Remove your $HOME/.m2/repository/org/apache/maven/plugins/maven-archetype-plugin or move it somewhere else * If you have $HOME/.m2/settings.xml setup, move it somewhere else * Try to run the command again. This will make you redownload the plugin from maven central repository, which should work. Good luck! Jeffrey Ai GUERARD Elisabeth wrote: Dear all, I try to run the tutoriel for Tapestry 5 at the following address: http://tapestry.apache.org/tapestry5/tutorial1/first.html I have problem with the first step: create an empty application by using feature of Maven, archetype. It 's the first time, i use Maven, I install it correctly, create an empty folder and run the following command: mvn archetype:create -DarchetypeGroupId=org.apache.tapestry -DarchetypeArtifactId=quickstart -DarchetypeVersion=5.0.5 -DgroupId=org.apache.tapestry -DartifactId=tapestry-tutorial1 -DpackageName=org.apache.tapestry.tutorial I had the following error: [ERROR] BUILD ERROR [INFO] [INFO] The plugin 'org.apache.maven.plugins:maven-archetype-plugin' does not exist or no valid version could be found By looking at Maven 's website, about archetype, I found configuration of pom.xml and archetype.xml. I need to do the same in this case, isn't it? Thanks in advance for your help. Eli -- Jeffrey Ai Software Developer Analyst MemberDirect(R) Product Development phone: 604 737 5957 email: [EMAIL PROTECTED] website: www.memberdirect.ca - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Michael Bernagou Java Developper
Re: T5.06 Project tree
No I didn't because I don't understand why the webroot should be in the src directory. About that : MyProject/src/papo/pages/ MyProject/src/papo/services/ It is what I have but I wrote in my message MyProject/src/papo.pages/ MyProject/src/papo.services/ instead, just to show it is packages in the point of view of eclipse and java. The debug mode show me the Start.java is normally compiled and Tapestry describe what it did with at runtime : replacing method, etc... 2007/11/14, Joachim Van der Auwera [EMAIL PROTECTED]: Have you started using the project archetype? This is the easiest way to have a correct directory srtucture. Anyway, I think the paths should be MyProject/src/papo/pages/ MyProject/src/papo/services/ Kind regards, Joachim Michael Bernagou wrote: I have something strange and it made me asking this question : What are the mandatory project tree elements? (sorry for my english I don't now how to write it differently). So, my project is : MyProject/src/papo.pages/[all pages such as Start.java and Start.properties] MyProject/src/papo.services/[ioc stuff] MyProject/webroot/[all template such as Start.tml and Start_fr.tml] But I have this error : java.lang.RuntimeException Page Start did not generate any markup when rendered. This could be because its template file could not be located, or because a render phase method in the page prevented rendering. Start.tml: !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns:t=http://tapestry.apache.org/schema/tapestry_5_0_0.xsd; head titlePaper and Pen Online/title /head body form t:type=BeanEditForm object=login t:parameter name=password label t:type=Label for=password/label input t:type=PasswordField t:id=password t:validate=required t:value=login.password / /t:parameter /form pSi vous n'avez pas encore de compte, t:pagelink page=Registercrees-en un!!/t:pagelink/p p color=red${message}/p /body /html *** Start.java: package papo.pages; import org.apache.tapestry.annotations.ApplicationState; import org.apache.tapestry.annotations.InjectPage; import org.apache.tapestry.annotations.Persist; import org.apache.tapestry.ioc.annotations.Inject; import papo.data.Login; import papo.data.UserLite; import papo.exception.PapoException; import papo.model.User; import papo.services.ApplicationService; import papo.services.UserService; /** * Start page of application papo. */ public class Start { private static final String SUCCESS = Home; private static final String FAILURE = Start; @Persist private Login login; public Login getLogin() { return login; } public void setLogin(Login login) { this.login = login; } private String message; public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } @ApplicationState private User user; @InjectPage private Home home; @Inject private UserService userService; @Inject private ApplicationService applicationService; String onSuccess() { try { user = userService.getAuthenticatedUser(login.getLogin(), login.getPassword()); if (user != null) { home.setUser(user); UserLite userLite = new UserLite(user.getLogin()); applicationService.makeOnline(userLite); home.setUsers(applicationService.getUserList().getUserList()); } else { message = Login ou Password inconnue. L'identification a échoué.; return FAILURE; } } catch (PapoException pe) { message = La procedure d'identification a rencontré un probleme !!; return null; } return SUCCESS; } } It didn't enter in Start.java (I put a debug point) because it was not able to compile or find the Start.tml. Usually, when it found a compilation problem, the error message explicitely explain where is the line in the template, but in my case, I have only a stack trace. When I see the Snapshot for the typicall project, there is something else as Project tree, and I don't want to follow the architecture. Having the webroot folder in the src/main and the java in the src/main/java is not logic for me. A web application is not defined like that usually, why to change the way? But this is another subject... -- Joachim Van der Auwera PROGS bvba, progs.be, blog.progs.be - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Michael Bernagou Java Developper
Re: T5.06 Project tree
So is it why my start.tml is not found?? If yes (I'm really not sure), I'm very surprised about the miss of flexibility T5 have... For an existing project build in the usual way (Project/src, Project/webroot), having to change this just for T5 is veru bad... 2007/11/14, Michael Courcy [EMAIL PROTECTED]: Well it's a matter of convention When maven build the project, things are in the place they have to be. Michael Bernagou a écrit : No I didn't because I don't understand why the webroot should be in the src directory. About that : MyProject/src/papo/pages/ MyProject/src/papo/services/ It is what I have but I wrote in my message MyProject/src/papo.pages/ MyProject/src/papo.services/ instead, just to show it is packages in the point of view of eclipse and java. The debug mode show me the Start.java is normally compiled and Tapestry describe what it did with at runtime : replacing method, etc... 2007/11/14, Joachim Van der Auwera [EMAIL PROTECTED]: Have you started using the project archetype? This is the easiest way to have a correct directory srtucture. Anyway, I think the paths should be MyProject/src/papo/pages/ MyProject/src/papo/services/ Kind regards, Joachim Michael Bernagou wrote: I have something strange and it made me asking this question : What are the mandatory project tree elements? (sorry for my english I don't now how to write it differently). So, my project is : MyProject/src/papo.pages/[all pages such as Start.java and Start.properties] MyProject/src/papo.services/[ioc stuff] MyProject/webroot/[all template such as Start.tml and Start_fr.tml] But I have this error : java.lang.RuntimeException Page Start did not generate any markup when rendered. This could be because its template file could not be located, or because a render phase method in the page prevented rendering. Start.tml: !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns:t=http://tapestry.apache.org/schema/tapestry_5_0_0.xsd; head titlePaper and Pen Online/title /head body form t:type=BeanEditForm object=login t:parameter name=password label t:type=Label for=password/label input t:type=PasswordField t:id=password t:validate=required t:value=login.password / /t:parameter /form pSi vous n'avez pas encore de compte, t:pagelink page=Registercrees-en un!!/t:pagelink/p p color=red${message}/p /body /html *** Start.java: package papo.pages; import org.apache.tapestry.annotations.ApplicationState; import org.apache.tapestry.annotations.InjectPage; import org.apache.tapestry.annotations.Persist; import org.apache.tapestry.ioc.annotations.Inject; import papo.data.Login; import papo.data.UserLite; import papo.exception.PapoException; import papo.model.User; import papo.services.ApplicationService; import papo.services.UserService; /** * Start page of application papo. */ public class Start { private static final String SUCCESS = Home; private static final String FAILURE = Start; @Persist private Login login; public Login getLogin() { return login; } public void setLogin(Login login) { this.login = login; } private String message; public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } @ApplicationState private User user; @InjectPage private Home home; @Inject private UserService userService; @Inject private ApplicationService applicationService; String onSuccess() { try { user = userService.getAuthenticatedUser(login.getLogin(), login.getPassword()); if (user != null) { home.setUser(user); UserLite userLite = new UserLite(user.getLogin()); applicationService.makeOnline(userLite); home.setUsers(applicationService.getUserList().getUserList()); } else { message = Login ou Password inconnue. L'identification a échoué.; return FAILURE; } } catch (PapoException pe) { message = La procedure d'identification a rencontré un probleme !!; return null; } return SUCCESS; } } It didn't enter in Start.java (I put a debug point) because it was not able to compile or find the Start.tml. Usually, when it found a compilation problem, the error message explicitely explain where is the line in the template, but in my case, I have only a stack trace. When I see the Snapshot for the typicall project, there is something else as Project tree, and I don't want to follow the architecture. Having the webroot folder in the src/main and the java in the src/main/java is not logic for me
T5 no root element??
I copied and paste my Eclipse project from my Home computer to my work computer. And it works at home, not at works and the error is this one : [ERROR] DefaultRequestExceptionHandler Processing of request failed with uncaught exception: No root element has been defined. java.lang.IllegalStateException: No root element has been defined. at org.apache.tapestry.dom.Document.toMarkup(Document.java:89) at org.apache.tapestry.internal.services.MarkupWriterImpl.toMarkup( MarkupWriterImpl.java:51) at org.apache.tapestry.internal.services.PageResponseRendererImpl.renderPageResponse (PageResponseRendererImpl.java:49) at $PageResponseRenderer_116146572a8.renderPageResponse($PageResponseRenderer_116146572a8.java) I thought it was a problem of localization since I had only Start_fr.tml but I added Start.tml (same for my 2 others _fr.tml pages) but I still have the error. The code is exactly the same and I don't have any error in my compilation, neither xml validation error. Any idea? -- Michael Bernagou Java Developper
Re: 3 new French Tapestry5 tutorials
Merci :) Je sais pas pourquoi le firewall de ma boite bloque le site... Le 05/11/07, Michael Courcy [EMAIL PROTECTED] a écrit : Bravo et merci. #Cyrille37# a écrit : Hello, Bonjour, There are 3 new tutorials for Tapestry5 in French. Il y a 3 nouveaux tutoriels en français pour Tapestry5. Thanks to Baptiste Meurant ! Merci à Baptiste Meurant ! Premier projet avec Tapestry5, Spring et Hibernate : http://baptiste-meurant.developpez.com/tutoriaux/tapestry5-spring-hibernate/ Intégration simple et élégante d'AJAX avec DWR: http://baptiste-meurant.developpez.com/tutoriaux/dwr-tapestry5-spring-hibernate/ Sécurisation d'une application Web avec Acegi Security: http://baptiste-meurant.developpez.com/tutoriaux/acegi-dwr-tapestry5-spring-hibernate/ I've added them on http://wiki.apache.org/tapestry/TapestryTutorials but it should be nice to add them to http://tapestry.apache.org/articles.html Bye, Salut Cyrille. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Michael Bernagou Java Developper
Re: T5.0.6 I'm lost after upgrade T5
I already tried to add the setters, without success. But Itried to access Home and I got an error regarding my Logger : My Home.java public class Home { ... @Inject private Logger logger; String refreshList() { try { logger.debug(Processiong refreshList...); users = applicationService.getUserList().getUserList(); logger.debug(User lists set to page.); } catch (PapoException pe) { logger.error(Failed to get the user list. Nothing set in the page!); return FAILURE; } return SUCCESS; } } And now I have this error : org.apache.tapestry.internal.services.TransformationException: Error obtaining injected value for field papo.pages.Home.logger: No service implements the interface org.apache.log4j.Logger. I thought Tapestry know everything about logging and in the documentation it says @Inject private Logger logger; was enought. Usually I used log4j like that : private static Logger logger = Logger.getLogger(MyClass.class.getName()); but Howard told me in a old and previous mailing to not use the logging like that... So, how to use the logger in T5? 2007/11/4, Nick Westgate [EMAIL PROTECTED]: Try adding setters to your fields. Cheers, Nick. Josh Canfield wrote: @InjectPage private Home home; The error message seems a little strange, but the code above is injecting a page called Home. Does that page load correctly if accessed directly? Josh On 11/3/07, Michael Bernagou [EMAIL PROTECTED] wrote: Everything worked perfectly, but since I upgraded to T5.0.6, it fails for an understandable reason! I replaced my html by tml and placed them in the right place. I upgrade log4j to get the latest and add the new logging api (to avoid runtime error). The thing is really strange... My Start.tml !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns:t=http://tapestry.apache.org/schema/tapestry_5_0_0.xsd; head titlePaper and Pen Online - Identification/title /head body p style=color:red;b${message}/b/p t:form tracker=login t:errors/ t:parameter name=password t:label for=password/ t:passwordfield t:id=password t:validate=required value= login.password/ /t:parameter /t:form pSi vous n'avez pas encore de compte, t:pagelink page=Registercrees-en un!!/t:pagelink/p /body /html My Start.java public class Start { private static final String SUCCESS = Home; private static final String FAILURE = Start; @ApplicationState private Login login; public Login getLogin() { return login; } @Persist private String message; public String getMessage() { return message; } @ApplicationState private User user; @InjectPage private Home home; @Inject private UserService userService; @Inject private ApplicationService applicationService; String onSuccess() { message = null; try { user = userService.getAuthenticatedUser(login.getLogin(), login.getPassword()); if (user != null) { home.setUser(user); UserLite userLite = new UserLite(user.getLogin()); applicationService.makeOnline(userLite); home.setUsers(applicationService.getUserList().getUserList()); } else { message = Login ou Password inconnue. L'identification a échoué.; return FAILURE; } } catch (PapoException pe) { message = La procedure d'identification a rencontré un probleme !!; return FAILURE; } return SUCCESS; } } And the error : Could not convert 'message' into a component parameter binding: java.lang.NoClassDefFoundError: papo/pages/Home location context:Start_fr.tml, line 8, column 363html xmlns:t= http://tapestry.apache.org/schema/tapestry_5_0_0.xsd 4head5titlePaper and Pen Online - Identification/title6/head7body8p style=color:red;b${message}/b/p9t:form tracker=login10t:errors/ 11 t:parameter name=password12 t:label for=password/13t:passwordfield t:id=password t:validate=required value= login.password/So, the tml is found, read, interpreted but for a reason I don't understand it refer to my class Home which is in the same package than my class Start. I have a Register page (tml + java) and it give me exactly the same error! No error at runtime, no compilation error (Inject are the new Inject, for example). Thanks -- Michael Bernagou Java Developper - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Michael Bernagou Java Developper
Re: T5.0.6 I'm lost after upgrade T5
Ok, I got it It was not the right import ;o) I used this : import org.apache.log4j.Logger; instead of import org.slf4j.Logger; Thanks :) 2007/11/4, Michael Bernagou [EMAIL PROTECTED]: I already tried to add the setters, without success. But Itried to access Home and I got an error regarding my Logger : My Home.java public class Home { ... @Inject private Logger logger; String refreshList() { try { logger.debug(Processiong refreshList...); users = applicationService.getUserList().getUserList(); logger.debug(User lists set to page.); } catch (PapoException pe) { logger.error(Failed to get the user list. Nothing set in the page!); return FAILURE; } return SUCCESS; } } And now I have this error : org.apache.tapestry.internal.services.TransformationException: Error obtaining injected value for field papo.pages.Home.logger: No service implements the interface org.apache.log4j.Logger. I thought Tapestry know everything about logging and in the documentation it says @Inject private Logger logger; was enought. Usually I used log4j like that : private static Logger logger = Logger.getLogger(MyClass.class.getName()); but Howard told me in a old and previous mailing to not use the logging like that... So, how to use the logger in T5? 2007/11/4, Nick Westgate [EMAIL PROTECTED]: Try adding setters to your fields. Cheers, Nick. Josh Canfield wrote: @InjectPage private Home home; The error message seems a little strange, but the code above is injecting a page called Home. Does that page load correctly if accessed directly? Josh On 11/3/07, Michael Bernagou [EMAIL PROTECTED] wrote: Everything worked perfectly, but since I upgraded to T5.0.6, it fails for an understandable reason! I replaced my html by tml and placed them in the right place. I upgrade log4j to get the latest and add the new logging api (to avoid runtime error). The thing is really strange... My Start.tml !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns:t= http://tapestry.apache.org/schema/tapestry_5_0_0.xsd head titlePaper and Pen Online - Identification/title /head body p style=color:red;b${message}/b/p t:form tracker=login t:errors/ t:parameter name=password t:label for=password/ t:passwordfield t:id=password t:validate=required value= login.password/ /t:parameter /t:form pSi vous n'avez pas encore de compte, t:pagelink page=Registercrees-en un!!/t:pagelink/p /body /html My Start.java public class Start { private static final String SUCCESS = Home; private static final String FAILURE = Start; @ApplicationState private Login login; public Login getLogin() { return login; } @Persist private String message; public String getMessage() { return message; } @ApplicationState private User user; @InjectPage private Home home; @Inject private UserService userService; @Inject private ApplicationService applicationService; String onSuccess() { message = null; try { user = userService.getAuthenticatedUser(login.getLogin(), login.getPassword()); if (user != null) { home.setUser(user); UserLite userLite = new UserLite(user.getLogin ()); applicationService.makeOnline(userLite); home.setUsers(applicationService.getUserList ().getUserList()); } else { message = Login ou Password inconnue. L'identification a échoué.; return FAILURE; } } catch (PapoException pe) { message = La procedure d'identification a rencontré un probleme !!; return FAILURE; } return SUCCESS; } } And the error : Could not convert 'message' into a component parameter binding: java.lang.NoClassDefFoundError: papo/pages/Home location context:Start_fr.tml, line 8, column 363html xmlns:t= http://tapestry.apache.org/schema/tapestry_5_0_0.xsd 4head5titlePaper and Pen Online - Identification/title6/head7body8p style=color:red;b${message}/b/p9t:form tracker=login10t:errors/ 11 t:parameter name=password12 t:label for=password/13t:passwordfield t:id=password t:validate=required value= login.password/So, the tml is found, read, interpreted but for a reason I don't understand it refer to my class Home which is in the same package than my class Start. I have a Register page (tml + java) and it give me exactly the same error! No error at runtime, no compilation error (Inject are the new Inject, for example). Thanks -- Michael Bernagou Java Developper
T5.0.6 I'm lost after upgrade T5
Everything worked perfectly, but since I upgraded to T5.0.6, it fails for an understandable reason! I replaced my html by tml and placed them in the right place. I upgrade log4j to get the latest and add the new logging api (to avoid runtime error). The thing is really strange... My Start.tml !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns:t=http://tapestry.apache.org/schema/tapestry_5_0_0.xsd; head titlePaper and Pen Online - Identification/title /head body p style=color:red;b${message}/b/p t:form tracker=login t:errors/ t:parameter name=password t:label for=password/ t:passwordfield t:id=password t:validate=required value= login.password/ /t:parameter /t:form pSi vous n'avez pas encore de compte, t:pagelink page=Registercrees-en un!!/t:pagelink/p /body /html My Start.java public class Start { private static final String SUCCESS = Home; private static final String FAILURE = Start; @ApplicationState private Login login; public Login getLogin() { return login; } @Persist private String message; public String getMessage() { return message; } @ApplicationState private User user; @InjectPage private Home home; @Inject private UserService userService; @Inject private ApplicationService applicationService; String onSuccess() { message = null; try { user = userService.getAuthenticatedUser(login.getLogin(), login.getPassword()); if (user != null) { home.setUser(user); UserLite userLite = new UserLite(user.getLogin()); applicationService.makeOnline(userLite); home.setUsers(applicationService.getUserList().getUserList()); } else { message = Login ou Password inconnue. L'identification a échoué.; return FAILURE; } } catch (PapoException pe) { message = La procedure d'identification a rencontré un probleme !!; return FAILURE; } return SUCCESS; } } And the error : Could not convert 'message' into a component parameter binding: java.lang.NoClassDefFoundError: papo/pages/Home location context:Start_fr.tml, line 8, column 363html xmlns:t= http://tapestry.apache.org/schema/tapestry_5_0_0.xsd;4head5titlePaper and Pen Online - Identification/title6/head7body8p style=color:red;b${message}/b/p9t:form tracker=login10t:errors/ 11 t:parameter name=password12 t:label for=password/13t:passwordfield t:id=password t:validate=required value= login.password/So, the tml is found, read, interpreted but for a reason I don't understand it refer to my class Home which is in the same package than my class Start. I have a Register page (tml + java) and it give me exactly the same error! No error at runtime, no compilation error (Inject are the new Inject, for example). Thanks -- Michael Bernagou Java Developper
[T5]onSessionClose?
hi, I'm looking for catching the event onSessionClose. In fact, I would like to change the status online to offline of a user whose session is close/lost. Any idea? I thought about a timer at the application level able to get the full list of sessions and make a full update but it seems to me there is maybe another solution. M. -- Michael Bernagou Java Developper
Re: [T5]Global object?
Hi, So I created a singleton class with static field, created at the first session since the last server restart, but I didn't understand why I should use the ASO notation also. I don't need, I think, to store the object in the session, would be redundant, wouldn't be? The object is already available at the page level since I created services to get and update info from this object. Mainly, my UserList store a list of User objects with live fields online/offline, lastIP, lastTimeConnected I don't want to store in my DB (maybe only one of them, if really needed). When the server will restart, new sessions will be created and this creation will update the user status - something like a shared contact list. M. 2007/7/11, Howard Lewis Ship [EMAIL PROTECTED]: You can use the @ApplicationState annotation on a field to mark it as an application-wide state object. It will be stored in the HttpSession. Most of the infrastructure for storing such an object in the ServletContext is available; see the ApplicationStatePersistenceStrategySource service. What's missing is to define a context application state persistence strategy, contribute it to the service, and contribute a ApplicationStateContribution to the ApplicationStateManager service to defne that your ASO belongs in the context, not the (default) session. Again, these are things that will eventually be cooked right into Tapestry (hint: add a JIRA issue) but in the meantime, can be added on an ad-hoc basis. Now that's what I call Dependency Injection! Side note: and that's why we need T5 IoC and not Guice or Spring. Those don't have a concept similar to Tapestry's service configuration / contribution system. On 7/11/07, Michael Bernagou [EMAIL PROTECTED] wrote: Hi, I search into the mailing list and didn't find how to declare an object such as an ArrayList at the context level. ASO is for session and @Persist for requests, but what about the Application/Context level? My site needs to maintains a list of users with their status without having to reload it from the database at each new session created. Thanks M. -- 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] -- Michael Bernagou Java Developper
[T5]Global object?
Hi, I search into the mailing list and didn't find how to declare an object such as an ArrayList at the context level. ASO is for session and @Persist for requests, but what about the Application/Context level? My site needs to maintains a list of users with their status without having to reload it from the database at each new session created. Thanks M.