-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: BuildSessionFactory not working.
PostPosted: Mon Jan 31, 2011 5:48 am 
Newbie

Joined: Mon Jan 31, 2011 5:35 am
Posts: 3
The red colours are printed by me...



Initializing AppEngine server
The server is running at http://localhost:8888/
Jan 31, 2011 9:46:10 AM com.google.appengine.tools.development.LocalResourceFileServlet doGet
WARNING: No file found for: /war/LoginSample.css
Jan 31, 2011 9:46:10 AM com.google.appengine.tools.development.LocalResourceFileServlet doGet
WARNING: No file found for: /loginsample/war/LoginSample.css
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
UserName = a
asasasasassasasasasasaasasasassasas------======

31 [btpool0-1] INFO org.hibernate.cfg.Environment - Hibernate 3.3.2.GA
31 [btpool0-1] INFO org.hibernate.cfg.Environment - hibernate.properties not found
47 [btpool0-1] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
47 [btpool0-1] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
asasasasassasasasasasaasasasassasas------======2
204 [btpool0-1] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
204 [btpool0-1] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
344 [btpool0-1] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : javaObject/Login.hbm.xml
438 [btpool0-1] INFO org.hibernate.cfg.HbmBinder - Mapping class: javaObject/Login -> login
asasasasassasasasasasaasasasassasas------======3
469 [btpool0-1] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
578 [btpool0-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
578 [btpool0-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
578 [btpool0-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
594 [btpool0-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/test
594 [btpool0-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=root, password=****}
fffffffffffffffffffffffffffffffffff
Initial Session Factory creation failed : java.lang.ExceptionInInitializerError
Jan 31, 2011 9:46:25 AM com.google.appengine.tools.development.ApiProxyLocalImpl log
SEVERE: [1296467185917000] javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract boolean javaClass.client.LoginService.isValidLogin(java.lang.String,java.lang.String)' threw an unexpected exception: java.lang.ExceptionInInitializerError
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:378)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:581)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:188)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:51)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:121)
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:712)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:352)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:313)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:844)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:644)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
Caused by: java.lang.ExceptionInInitializerError
at javaObject.HibernateUtil.<clinit>(HibernateUtil.java:22)
at javaClass.server.LoginServiceImpl.isValidLogin(LoginServiceImpl.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562)
... 30 more
Caused by: java.lang.ExceptionInInitializerError
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:111)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2119)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2115)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1339)
at javaObject.HibernateUtil.<clinit>(HibernateUtil.java:16)
... 37 more
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:166)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkAccess(DevAppServerFactory.java:191)
at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:288)
at java.lang.Thread.init(Thread.java:332)
at java.lang.Thread.<init>(Thread.java:377)
at java.util.TimerThread.<init>(Timer.java:456)
at java.util.Timer.<init>(Timer.java:71)
at java.util.Timer.<init>(Timer.java:122)
at com.mysql.jdbc.ConnectionImpl.<clinit>(ConnectionImpl.java:208)
... 46 more


Top
 Profile  
 
 Post subject: Re: BuildSessionFactory not working.
PostPosted: Mon Jan 31, 2011 5:51 am 
Newbie

Joined: Mon Jan 31, 2011 5:35 am
Posts: 3
can any body tell me what is the cause for this error..I tried many thing..nothing is working.
This error is generated in a file whiose contentes are shown below...


package javaUtil;


import java.util.Iterator;
import javaObject.Student;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {
public static void main(String[] args){

final SessionFactory sessionFactory;
Session session = null;

try{
//SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();

System.out.println("asasasasassasasasasasaasasasassasas------======");
Configuration cfg = new Configuration();
System.out.println("asasasasassasasasasasaasasasassasas------======2");
Configuration cfg1 = cfg.configure();
System.out.println("asasasasassasasasasasaasasasassasas------======3");
sessionFactory = cfg1.buildSessionFactory();
System.out.println("asasasasassasasasasasaasasasassasas------======4");

session = sessionFactory.openSession();
String SQL = "from Student s";
Query query = session.createQuery(SQL);
System.out.println("\nS_Id\tF_Name\t\tL_Name\t\tD_No\n");
for(Iterator it=query.iterate();it.hasNext();){
Student s = (Student)it.next();
System.out.print(s.getStudentId());
System.out.print("\t"+s.getFirstName());
System.out.print("\t\t"+s.getLastName());
System.out.println("\t\t"+s.getDeptId());
}
session.close();
}catch(Exception e){
System.out.println(e.getMessage());
}
}
}



This above file "HibernateUtil.java" is called from the below file "LoginServiceImpl.java"

package javaClass.server;

import java.util.Iterator;

import org.hibernate.Query;
import org.hibernate.classic.Session;
import javaClass.client.LoginService;
import javaObject.HibernateUtil;
import javaObject.Login;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class LoginServiceImpl extends RemoteServiceServlet implements LoginService{
//private static final long serialVersionUID = 1L;
//private String VALID_USRNAME ;
//private String VALID_PSWD;

private Boolean flag = false;

public LoginServiceImpl(){
}

public boolean isValidLogin(String name, String pswd){
System.out.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
System.out.println("UserName = "+name);
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
//Session session = HibernateUtil.getSessionFactory().openSession();
System.out.println("Password = "+pswd);
session.beginTransaction();
System.out.println("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
String SQL = "from Login as l where l.username = "+name+" and l.password = "+pswd;
System.out.println("SQL ---------------------------------- : "+SQL);
Query query = session.createQuery(SQL);
for(Iterator it = query.iterate();it.hasNext();){
Login login = (Login)it.next();
if(name.equals(login.getUsername())&& pswd.equals(login.getPassword())){
flag = true;
}
}
//session.close();
session.getTransaction().commit();
return flag;
//return VALID_USRNAME.equals(name) && VALID_PSWD.equals(pswd);
}

}

This is a GWT+Hibernate+MySQL project....


Top
 Profile  
 
 Post subject: Re: BuildSessionFactory not working.
PostPosted: Mon Jan 31, 2011 9:53 am 
Regular
Regular

Joined: Sat Apr 23, 2005 7:28 am
Posts: 52
Code:
1 Student does not appear to be mapped in hibernate.cfg.xml
2 Hibernateutil looks all wrong for starters, I suggest you try somthing like:

Code:
package javaUtil;

import org.apache.log4j.Logger;
import org.apache.log4j.Priority;
import org.hibernate.*;
import org.hibernate.cfg.*;

public class HibernateUtil {
   
    public static final ThreadLocal     session = new ThreadLocal();
    private static Configuration        configuration;
    private static final SessionFactory sessionFactory;

    static {
        try {
            configuration  = new Configuration();
            sessionFactory = configuration.configure("hibernate.cfg.xml").buildSessionFactory();
        } catch (Throwable ex) {

           throw new ExceptionInInitializerError(ex);
        }
    }

    public static Session openSession() {
        Session s = (Session) session.get();
        if (s == null) {
            s = sessionFactory.openSession();
            session.set(s);
        }
        return s;
    }

    public static void closeSession() {
        Session s = (Session) session.get();

        if (s != null) {
            s.close();
        }
        session.set(null);
    }
}



Your isValidLogin method becomes:

Code:
public boolean isValidLogin(String name, String pswd){

System.out.println("UserName = "+name);
System.out.println("Password = "+pswd);
Session session = HibernateUtil.getSession();

String SQL = "from Login as l where l.username = "+name+" and l.password = "+pswd;
System.out.println("SQL ---------------------------------- : "+SQL);
Query query = session.createQuery(SQL);
for(Iterator it = query.iterate();it.hasNext();){
Login login = (Login)it.next();
if(name.equals(login.getUsername())&& pswd.equals(login.getPassword())){
flag = true;
HibernateUtil.closeSession();
}



Top
 Profile  
 
 Post subject: Re: BuildSessionFactory not working.
PostPosted: Tue Feb 01, 2011 1:02 am 
Newbie

Joined: Mon Jan 31, 2011 5:35 am
Posts: 3
Thanx bolsover..I will try it and let you know what happend. Thanx a lot.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.