Re: [T5]: Hibernate question - session is null
Is the hibernate service initialized at all? When Tapestry starts it lists all known services, is Hibernate in that list? - 99 photos-4 wrote: Thanks for your help, but so far no joy: Quoting 9902468 [EMAIL PROTECTED]: And of course, check that you have Hibernate and hibernate annotation in your libraries, they are NOT included automatically by maven if maven is used. The libraries appear in my repository and appear under sources in the Eclipse Run Configuration. Tapestry should be quite verbose about hibernate if tapestry is configured to run in debug mode: http://tapestry.apache.org/tapestry5/tapestry-core/guide/conf.html add: I placed -Dtapestry.production-mode=false on the command line, which, according to the docs, does the same thing. I see no output about Hibernate at all. It never gets mentioned... Also see that your entities are in correct place (same root package as pages and components, in entities package.) src/main/java/uk.bl.dlportal.entities src/main/java/uk.bl.dlportal.components src/main/java/uk.bl.dlportal.pages looks ok to me. Also perhaps use org.hibernate.dialect.MySQLInnoDBDialect to support foreign keys? (Change to hibernate config.) You should be able to see that Hibernate starts in the logs and maps User etc. classes. Remember to configure your Log4J or what ever logging u use to debug. I added some lines to log4j.properties to turn on hibernate logging (debug), but I see no output - just the usual Tapestry debug output that I've seen before. I'm really stumped... :-( Hibernate never gets called and yet everything appears to be in place. p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/-T5-%3A-Hibernate-question-tp18634071p18684648.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
Quoting 9902468 [EMAIL PROTECTED]: Is the hibernate service initialized at all? When Tapestry starts it lists all known services, is Hibernate in that list? - 99 It looks like it: ... FieldValidationSupport: DEFINED FieldValidatorDefaultSource: DEFINED FieldValidatorSource: DEFINED FormSupport: DEFINED HibernateEntityPackageManager: DEFINED HibernateSessionManager: DEFINED HibernateSessionSource: DEFINED HibernateTransactionDecorator: DEFINED HiddenFieldLocationRules: DEFINED HttpServletRequest: DEFINED HttpServletRequestHandler: VIRTUAL IgnoredPathsFilter: DEFINED InjectionProvider: DEFINED InternalRequestGlobals: VIRTUAL LinkFactory: DEFINED ... I still haven't figured out what is going on. I see no evidence of Hibernate ever being called. Are any Hibernate services missing from the above list? p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
Check also that you have the mysql-connector-java-5.1.6.jar or similar in your libraries. I have the following list: FieldValidatorSource: DEFINED FormDAO: DEFINED FormSupport: DEFINED FreeMarkerService: DEFINED FulfillmentDAO: DEFINED GoogleMapService: DEFINED HibernateEntityPackageManager: DEFINED HibernateSessionManager: DEFINED HibernateSessionSource: DEFINED HibernateTransactionDecorator: DEFINED HiddenFieldLocationRules: DEFINED HiveMind: DEFINED HttpServletRequest: DEFINED HttpServletRequestHandler: VIRTUAL IgnoredPathsFilter: DEFINED So that one should be ok. Is the page that you are testing with _really_ calling session.something? Tapestry lazy loads everything so Hibernate is not really initialized without the call. Can we have the stack trace? - 99 photos-4 wrote: Quoting 9902468 [EMAIL PROTECTED]: Is the hibernate service initialized at all? When Tapestry starts it lists all known services, is Hibernate in that list? - 99 It looks like it: ... FieldValidationSupport: DEFINED FieldValidatorDefaultSource: DEFINED FieldValidatorSource: DEFINED FormSupport: DEFINED HibernateEntityPackageManager: DEFINED HibernateSessionManager: DEFINED HibernateSessionSource: DEFINED HibernateTransactionDecorator: DEFINED HiddenFieldLocationRules: DEFINED HttpServletRequest: DEFINED HttpServletRequestHandler: VIRTUAL IgnoredPathsFilter: DEFINED InjectionProvider: DEFINED InternalRequestGlobals: VIRTUAL LinkFactory: DEFINED ... I still haven't figured out what is going on. I see no evidence of Hibernate ever being called. Are any Hibernate services missing from the above list? p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/-T5-%3A-Hibernate-question-tp18634071p18685754.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
Ok, I have just checked. I have mysql-connector-java-5.1.5.jar in the maven repository. Code is: - package uk.bl.dlportal.pages.util; import java.util.List; import org.apache.tapestry5.ioc.annotations.Inject; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.Session; import uk.bl.dlportal.entities.User; public class Security { @Inject private Session session; private final static Security security = new Security(); public User authenticate(String userName, String password) { System.out.println(SESSION +session); Criteria c = session.createCriteria(User.class); List result = c.list(); System.out.println(SESSION +session); return null; } public static Security getSecurity() { return security; } } Stack trace is: 84.73% unrealized services (111/131) [INFO] mortbay.log Started [EMAIL PROTECTED]:8080 [DEBUG] AppModule.TimingFilter Creating service 'TimingFilter'. [DEBUG] AppModule.TimingFilter Invoking method uk.bl.dlportal.services.AppModule.buildTimingFilter(Logger) (at AppModule.java:71). [INFO] AppModule.TimingFilter Request time: 4846 ms [INFO] AppModule.TimingFilter Request time: 0 ms [INFO] AppModule.TimingFilter Request time: 16 ms SESSION null [INFO] AppModule.TimingFilter Request time: 251 ms [ERROR] TapestryModule.RequestExceptionHandler Processing of request failed with uncaught exception: org.apache.tapestry5.runtime.ComponentEventException org.apache.tapestry5.runtime.ComponentEventException [at context:Index.tml, line 7, column 28] at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1042) at org.apache.tapestry5.internal.services.ComponentEventRequestHandlerImpl.handle(ComponentEventRequestHandlerImpl.java:67) at org.apache.tapestry5.internal.services.ImmediateActionRenderResponseFilter.handle(ImmediateActionRenderResponseFilter.java:42) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at org.apache.tapestry5.internal.services.AjaxFilter.handle(AjaxFilter.java:42) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at org.apache.tapestry5.services.TapestryModule$37.handle(TapestryModule.java:1987) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at $ComponentEventRequestHandler_11b68bd500b.handle($ComponentEventRequestHandler_11b68bd500b.java) at org.apache.tapestry5.internal.services.ComponentEventDispatcher.dispatch(ComponentEventDispatcher.java:135) at $Dispatcher_11b68bd500e.dispatch($Dispatcher_11b68bd500e.java) at $Dispatcher_11b68bd5000.dispatch($Dispatcher_11b68bd5000.java) at org.apache.tapestry5.services.TapestryModule$12.service(TapestryModule.java:938) at uk.bl.dlportal.services.AppModule$1.service(AppModule.java:84) at $RequestFilter_11b68bd4fff.service($RequestFilter_11b68bd4fff.java) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.LocalizationFilter.service(LocalizationFilter.java:42) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:586) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93) at org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84) at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:75) at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:106) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at $RequestHandler_11b68bd4ff8.service($RequestHandler_11b68bd4ff8.java) at org.apache.tapestry5.services.TapestryModule$11.service(TapestryModule.java:918) at
Re: [T5]: Hibernate question - session is null
its look like, that your Security class is only a helper class and no page component. in such classes the @Inject annotation doesnt work 2008/7/28 [EMAIL PROTECTED] Ok, I have just checked. I have mysql-connector-java-5.1.5.jar in the maven repository. Code is: - package uk.bl.dlportal.pages.util; import java.util.List; import org.apache.tapestry5.ioc.annotations.Inject; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.Session; import uk.bl.dlportal.entities.User; public class Security { @Inject private Session session; private final static Security security = new Security(); public User authenticate(String userName, String password) { System.out.println(SESSION +session); Criteria c = session.createCriteria(User.class); List result = c.list(); System.out.println(SESSION +session); return null; } public static Security getSecurity() { return security; } } Stack trace is: 84.73% unrealized services (111/131) [INFO] mortbay.log Started [EMAIL PROTECTED]:8080 [DEBUG] AppModule.TimingFilter Creating service 'TimingFilter'. [DEBUG] AppModule.TimingFilter Invoking method uk.bl.dlportal.services.AppModule.buildTimingFilter(Logger) (at AppModule.java:71). [INFO] AppModule.TimingFilter Request time: 4846 ms [INFO] AppModule.TimingFilter Request time: 0 ms [INFO] AppModule.TimingFilter Request time: 16 ms SESSION null [INFO] AppModule.TimingFilter Request time: 251 ms [ERROR] TapestryModule.RequestExceptionHandler Processing of request failed with uncaught exception: org.apache.tapestry5.runtime.ComponentEventException org.apache.tapestry5.runtime.ComponentEventException [at context:Index.tml, line 7, column 28] at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1042) at org.apache.tapestry5.internal.services.ComponentEventRequestHandlerImpl.handle(ComponentEventRequestHandlerImpl.java:67) at org.apache.tapestry5.internal.services.ImmediateActionRenderResponseFilter.handle(ImmediateActionRenderResponseFilter.java:42) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at org.apache.tapestry5.internal.services.AjaxFilter.handle(AjaxFilter.java:42) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at org.apache.tapestry5.services.TapestryModule$37.handle(TapestryModule.java:1987) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at $ComponentEventRequestHandler_11b68bd500b.handle($ComponentEventRequestHandler_11b68bd500b.java) at org.apache.tapestry5.internal.services.ComponentEventDispatcher.dispatch(ComponentEventDispatcher.java:135) at $Dispatcher_11b68bd500e.dispatch($Dispatcher_11b68bd500e.java) at $Dispatcher_11b68bd5000.dispatch($Dispatcher_11b68bd5000.java) at org.apache.tapestry5.services.TapestryModule$12.service(TapestryModule.java:938) at uk.bl.dlportal.services.AppModule$1.service(AppModule.java:84) at $RequestFilter_11b68bd4fff.service($RequestFilter_11b68bd4fff.java) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.LocalizationFilter.service(LocalizationFilter.java:42) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:586) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93) at org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84) at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:75) at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:106) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at
Re: [T5]: Hibernate question - session is null
Yep, Injection works only in page and component classes that live the ordinary Page or component lifecycle, and are requested from the web. :) Move the session to a real page and have that util to take the session as parameter, or even better move your logic to service that a page can use. (SecurityService perhaps?) - 99 Sven Homburg wrote: its look like, that your Security class is only a helper class and no page component. in such classes the @Inject annotation doesnt work 2008/7/28 [EMAIL PROTECTED] Ok, I have just checked. I have mysql-connector-java-5.1.5.jar in the maven repository. Code is: - package uk.bl.dlportal.pages.util; import java.util.List; import org.apache.tapestry5.ioc.annotations.Inject; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.Session; import uk.bl.dlportal.entities.User; public class Security { @Inject private Session session; private final static Security security = new Security(); public User authenticate(String userName, String password) { System.out.println(SESSION +session); Criteria c = session.createCriteria(User.class); List result = c.list(); System.out.println(SESSION +session); return null; } public static Security getSecurity() { return security; } } Stack trace is: 84.73% unrealized services (111/131) [INFO] mortbay.log Started [EMAIL PROTECTED]:8080 [DEBUG] AppModule.TimingFilter Creating service 'TimingFilter'. [DEBUG] AppModule.TimingFilter Invoking method uk.bl.dlportal.services.AppModule.buildTimingFilter(Logger) (at AppModule.java:71). [INFO] AppModule.TimingFilter Request time: 4846 ms [INFO] AppModule.TimingFilter Request time: 0 ms [INFO] AppModule.TimingFilter Request time: 16 ms SESSION null [INFO] AppModule.TimingFilter Request time: 251 ms [ERROR] TapestryModule.RequestExceptionHandler Processing of request failed with uncaught exception: org.apache.tapestry5.runtime.ComponentEventException org.apache.tapestry5.runtime.ComponentEventException [at context:Index.tml, line 7, column 28] at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1042) at org.apache.tapestry5.internal.services.ComponentEventRequestHandlerImpl.handle(ComponentEventRequestHandlerImpl.java:67) at org.apache.tapestry5.internal.services.ImmediateActionRenderResponseFilter.handle(ImmediateActionRenderResponseFilter.java:42) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at org.apache.tapestry5.internal.services.AjaxFilter.handle(AjaxFilter.java:42) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at org.apache.tapestry5.services.TapestryModule$37.handle(TapestryModule.java:1987) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at $ComponentEventRequestHandler_11b68bd500b.handle($ComponentEventRequestHandler_11b68bd500b.java) at org.apache.tapestry5.internal.services.ComponentEventDispatcher.dispatch(ComponentEventDispatcher.java:135) at $Dispatcher_11b68bd500e.dispatch($Dispatcher_11b68bd500e.java) at $Dispatcher_11b68bd5000.dispatch($Dispatcher_11b68bd5000.java) at org.apache.tapestry5.services.TapestryModule$12.service(TapestryModule.java:938) at uk.bl.dlportal.services.AppModule$1.service(AppModule.java:84) at $RequestFilter_11b68bd4fff.service($RequestFilter_11b68bd4fff.java) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.LocalizationFilter.service(LocalizationFilter.java:42) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:586) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93) at org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84)
Re: [T5]: Hibernate question - session is null
Hi, I also had some trouble configuring hibernate, my session was also null. After searching for a while I found this tutorial: http://linuxboy.javaeye.com/blog/68311 Since I dont use a DAO, my code looks something like the following. my db entity: ... import org.hibernate.Session; @Entity @Table(name = EVENT) public class EventDBEntity { public EventDBEntity() {} public EventDBEntity(Session session) {_session = session;} @Transient private Session _session; // more stuff here.. methods to access the db ... in my appmodule.java: ... public static void bind(ServiceBinder binder) { binder.bind(TourDBEntity.class); } ... then I call an @Inject on the db-entity: ... // db entity object @Inject private EventDBEntity _dbEntity; // now tapestry injects the hibernate session in my _dbEntity ... Hope this helps! Greetings, Mark -- Mark Weißenberg Tel. +49 228 9599630 startext Unternehmensberatung GmbH Kennedyallee 2, D-53175 Bonn Geschäftsführer Paul Bantzer, HRB Bonn 2741 Sitz der Gesellschaft: Bonn - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
I'm using Eclipse. The XML config appears in target/classes and appears to be in the classpath. I'm afraid I'm rather new to Tap 5 and also to Hibernate. I'm just following what is in the Tutorial. Unfortunately the session is still coming out as null. Is there anywhere I can see that Tapestry is actually using Hibernate as a service? I get the following in the console when I start my application: ... HibernateEntityPackageManager: DEFINED HibernateSessionManager: DEFINED HibernateSessionSource: DEFINED HibernateTransactionDecorator: DEFINED ... Quoting Andreas Andreou [EMAIL PROTECTED]: Perhaps hibernate.cfg.xml isn't in your runtime classpath? Are you sure your IDE includes it to the output? On Thu, Jul 24, 2008 at 6:09 PM, [EMAIL PROTECTED] wrote: I am following the tutorial at http://tapestry.apache.org/tapestry5/tutorial1/forms2.html but I find that the session (supposedly injected) is null. I'm not sure how to proceed. Could someone point me to documents/better tutorials on how to use Tapestry with Hibernate? Thanks, p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr Tapestry / Tacos developer Open Source / JEE Consulting - 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]
Re: [T5]: Hibernate question - session is null
Check that the @Inject private Session session; session is org.hibernate.Session. - 99 photos-4 wrote: I'm using Eclipse. The XML config appears in target/classes and appears to be in the classpath. I'm afraid I'm rather new to Tap 5 and also to Hibernate. I'm just following what is in the Tutorial. Unfortunately the session is still coming out as null. Is there anywhere I can see that Tapestry is actually using Hibernate as a service? I get the following in the console when I start my application: ... HibernateEntityPackageManager: DEFINED HibernateSessionManager: DEFINED HibernateSessionSource: DEFINED HibernateTransactionDecorator: DEFINED ... Quoting Andreas Andreou [EMAIL PROTECTED]: Perhaps hibernate.cfg.xml isn't in your runtime classpath? Are you sure your IDE includes it to the output? On Thu, Jul 24, 2008 at 6:09 PM, [EMAIL PROTECTED] wrote: I am following the tutorial at http://tapestry.apache.org/tapestry5/tutorial1/forms2.html but I find that the session (supposedly injected) is null. I'm not sure how to proceed. Could someone point me to documents/better tutorials on how to use Tapestry with Hibernate? Thanks, p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr Tapestry / Tacos developer Open Source / JEE Consulting - 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] -- View this message in context: http://www.nabble.com/-T5-%3A-Hibernate-question-tp18634071p18650658.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
Tapestry should be quite verbose about hibernate if tapestry is configured to run in debug mode: http://tapestry.apache.org/tapestry5/tapestry-core/guide/conf.html add: //This is the time in seconds that Tapestry waits before checking if a file is modified //Use a big number in production to imporve perfomance. configuration.add(SymbolConstants.FILE_CHECK_INTERVAL, 1 s); // 600 to production! // The factory default is true but during the early stages of an application // overriding to false is a good idea. In addition, this is often overridden // on the command line as -Dtapestry.production-mode=false configuration.add(SymbolConstants.PRODUCTION_MODE, false); to your AppModule.java's public static void contributeApplicationDefaults(MappedConfigurationString, String configuration) { method. Also see that your entities are in correct place (same root package as pages and components, in entities package.) Also perhaps use org.hibernate.dialect.MySQLInnoDBDialect to support foreign keys? (Change to hibernate config.) You should be able to see that Hibernate starts in the logs and maps User etc. classes. Remember to configure your Log4J or what ever logging u use to debug. - 99 photos-4 wrote: I'm using Eclipse. The XML config appears in target/classes and appears to be in the classpath. I'm afraid I'm rather new to Tap 5 and also to Hibernate. I'm just following what is in the Tutorial. Unfortunately the session is still coming out as null. Is there anywhere I can see that Tapestry is actually using Hibernate as a service? I get the following in the console when I start my application: ... HibernateEntityPackageManager: DEFINED HibernateSessionManager: DEFINED HibernateSessionSource: DEFINED HibernateTransactionDecorator: DEFINED ... Quoting Andreas Andreou [EMAIL PROTECTED]: Perhaps hibernate.cfg.xml isn't in your runtime classpath? Are you sure your IDE includes it to the output? On Thu, Jul 24, 2008 at 6:09 PM, [EMAIL PROTECTED] wrote: I am following the tutorial at http://tapestry.apache.org/tapestry5/tutorial1/forms2.html but I find that the session (supposedly injected) is null. I'm not sure how to proceed. Could someone point me to documents/better tutorials on how to use Tapestry with Hibernate? Thanks, p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr Tapestry / Tacos developer Open Source / JEE Consulting - 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] -- View this message in context: http://www.nabble.com/-T5-%3A-Hibernate-question-tp18634071p18651481.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
And of course, check that you have Hibernate and hibernate annotation in your libraries, they are NOT included automatically by maven if maven is used. - 99 photos-4 wrote: I'm using Eclipse. The XML config appears in target/classes and appears to be in the classpath. I'm afraid I'm rather new to Tap 5 and also to Hibernate. I'm just following what is in the Tutorial. Unfortunately the session is still coming out as null. Is there anywhere I can see that Tapestry is actually using Hibernate as a service? I get the following in the console when I start my application: ... HibernateEntityPackageManager: DEFINED HibernateSessionManager: DEFINED HibernateSessionSource: DEFINED HibernateTransactionDecorator: DEFINED ... Quoting Andreas Andreou [EMAIL PROTECTED]: Perhaps hibernate.cfg.xml isn't in your runtime classpath? Are you sure your IDE includes it to the output? On Thu, Jul 24, 2008 at 6:09 PM, [EMAIL PROTECTED] wrote: I am following the tutorial at http://tapestry.apache.org/tapestry5/tutorial1/forms2.html but I find that the session (supposedly injected) is null. I'm not sure how to proceed. Could someone point me to documents/better tutorials on how to use Tapestry with Hibernate? Thanks, p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr Tapestry / Tacos developer Open Source / JEE Consulting - 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] -- View this message in context: http://www.nabble.com/-T5-%3A-Hibernate-question-tp18634071p18651522.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
Quoting 9902468 [EMAIL PROTECTED]: Check that the @Inject private Session session; session is org.hibernate.Session. - 99 It is. I notice that when I switch on the mysql log that no attempt is ever made to access the db. Is there any kind of logging I can switch on from Tapestry (or maybe Hibernate) to tell me what is going on? (I am quite sure the xml file is correct and in the classpath, so I am running out of ideas! Although it must be something simple as these things usually are). session is always null when this code is run. Code and XML below: package uk.bl.dlportal.pages.util; import java.util.List; import org.apache.tapestry5.ioc.annotations.Inject; import org.hibernate.Query; import org.hibernate.Session; import uk.bl.dlportal.entities.User; public class Security { @Inject private Session session; private final static Security security = new Security(); public User authenticate(String userName, String password) { System.out.println(SESSION +session); List result = session.createCriteria(User.class).list(); return null; } public static Security getSecurity() { return security; } } XML hibernate.cfg.xml is in src/main/resources: !DOCTYPE hibernate-configuration PUBLIC -//Hibernate/Hibernate Configuration DTD 3.0//EN http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd; hibernate-configuration session-factory property name=hibernate.connection.driver_classcom.mysql.jdbc.Driver/property property name=hibernate.connection.urljdbc:mysql://localhost:3306/dlportal/property property name=hibernate.dialectorg.hibernate.dialect.MySQLDialect/property property name=hibernate.connection.usernameroot/property property name=hibernate.connection.passwordadmin/property property name=hbm2ddl.autoupdate/property property name=hibernate.show_sqltrue/property property name=hibernate.format_sqltrue/property /session-factory /hibernate-configuration - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
Thanks for your help, but so far no joy: Quoting 9902468 [EMAIL PROTECTED]: And of course, check that you have Hibernate and hibernate annotation in your libraries, they are NOT included automatically by maven if maven is used. The libraries appear in my repository and appear under sources in the Eclipse Run Configuration. Tapestry should be quite verbose about hibernate if tapestry is configured to run in debug mode: http://tapestry.apache.org/tapestry5/tapestry-core/guide/conf.html add: I placed -Dtapestry.production-mode=false on the command line, which, according to the docs, does the same thing. I see no output about Hibernate at all. It never gets mentioned... Also see that your entities are in correct place (same root package as pages and components, in entities package.) src/main/java/uk.bl.dlportal.entities src/main/java/uk.bl.dlportal.components src/main/java/uk.bl.dlportal.pages looks ok to me. Also perhaps use org.hibernate.dialect.MySQLInnoDBDialect to support foreign keys? (Change to hibernate config.) You should be able to see that Hibernate starts in the logs and maps User etc. classes. Remember to configure your Log4J or what ever logging u use to debug. I added some lines to log4j.properties to turn on hibernate logging (debug), but I see no output - just the usual Tapestry debug output that I've seen before. I'm really stumped... :-( Hibernate never gets called and yet everything appears to be in place. p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]