Ok. Great gadzooks!  Now I see. Thanks to you and Sven.

(I knew this was going to be obvious once pointed out!)

p.


Quoting 9902468 <[EMAIL PROTECTED]>:


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)
       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

org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
       at

$HttpServletRequestFilter_11b68bd4ff7.service($HttpServletRequestFilter_11b68bd4ff7.java)
       at

$HttpServletRequestHandler_11b68bd4ff9.service($HttpServletRequestHandler_11b68bd4ff9.java)
       at

$HttpServletRequestHandler_11b68bd4ff6.service($HttpServletRequestHandler_11b68bd4ff6.java)
       at
org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:168)
       at

org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
       at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
       at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
       at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
       at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:722)
       at
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:404)
       at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
       at org.mortbay.jetty.Server.handle(Server.java:324)
       at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
       at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:842)
       at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
       at
org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
       at
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
       at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
       at
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
Caused by: 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.structure.InternalComponentResourcesImpl.triggerContextEvent(InternalComponentResourcesImpl.java:182)
       at
org.apache.tapestry5.corelib.components.Form._$advised$onAction(Form.java:351)
       at

org.apache.tapestry5.corelib.components.Form$onAction$invocation_11b68bd8243.invokeAdvisedMethod(Form$onAction$invocation_11b68bd8243.java)
       at

org.apache.tapestry5.internal.services.AbstractComponentMethodInvocation.proceed(AbstractComponentMethodInvocation.java:71)
       at
org.apache.tapestry5.ioc.internal.services.LoggingAdvice.advise(LoggingAdvice.java:37)
       at
org.apache.tapestry5.internal.transform.LogWorker$1.advise(LogWorker.java:54)
       at

org.apache.tapestry5.internal.services.AbstractComponentMethodInvocation.proceed(AbstractComponentMethodInvocation.java:80)
       at
org.apache.tapestry5.corelib.components.Form.onAction(Form.java)
       at
org.apache.tapestry5.corelib.components.Form.dispatchComponentEvent(Form.java)
       at

org.apache.tapestry5.internal.structure.ComponentPageElementImpl.dispatchEvent(ComponentPageElementImpl.java:872)
       at

org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1025)
       ... 50 more
Caused by: java.lang.NullPointerException
       at
uk.bl.dlportal.pages.util.Security.authenticate(Security.java:26)
       at uk.bl.dlportal.pages.Index.onSubmitFromLoginForm(Index.java:27)
       at uk.bl.dlportal.pages.Index.dispatchComponentEvent(Index.java)
       at

org.apache.tapestry5.internal.structure.ComponentPageElementImpl.dispatchEvent(ComponentPageElementImpl.java:864)
       at

org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1025)
       ... 61 more




Quoting 9902468 <[EMAIL PROTECTED]>:

[Hide Quoted Text]


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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
with regards
Sven Homburg
http://tapestry5-components.googlecode.com
http://chenillekit.googlecode.com


-----
best regards
Sven


--
View this message in context: http://www.nabble.com/-T5-%3A-Hibernate-question-tp18634071p18686443.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]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to