-->
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.  [ 2 posts ] 
Author Message
 Post subject: package org.hibernate.* doesn't exists
PostPosted: Wed Jan 13, 2010 7:35 pm 
Newbie

Joined: Wed Jan 13, 2010 7:11 pm
Posts: 2
Hi people...

I'm using a java kickstarter project named appFuse... I'm trying to override some features, for instance, i'm trying to manage my own connections, so i've created a class for that. I was watching other people's samples to do my own, i think i was getting it, but when i want to compile it I get the package org.hibernate.* doesn't exists...

I've configured the build path in eclipse so it recognize the imports, but when i want to deploy it, it fails...

This is my class

Code:
package py.cbvpapp.webapp.util;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Hashtable;

import javax.servlet.http.HttpSession;

import org.acegisecurity.Authentication;
import org.acegisecurity.context.SecurityContextHolder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.connection.ConnectionProvider;
import org.hibernate.util.JDBCExceptionReporter;
import org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider;

import py.cbvpapp.Constants;
import py.cbvpapp.dao.hibernate.BaseDaoHibernate;
import py.cbvpapp.model.User;

public class CustomConnectionProvider extends LocalDataSourceConnectionProvider implements ConnectionProvider{

   private static final Log log = LogFactory.getLog(CustomConnectionProvider.class);
   private static final ThreadLocal<HttpSession> threadHttpSession = new ThreadLocal<HttpSession>();
   private static Hashtable<String, Connection> userCons = new Hashtable<String, Connection>();
   private static Hashtable<String, String> userAuthType = new Hashtable<String, String>();

   public synchronized static void setThreadHttpSession(HttpSession session) {
      threadHttpSession.set(session);
   }

   public synchronized static HttpSession getThreadHttpSession() {
      return threadHttpSession.get();
   }

   public void closeConnection(Connection con) throws SQLException {
      try {
         if (userCons.get(con.getMetaData().getUserName()) == null)
               con.close();
      }
      catch (SQLException ex) {
         JDBCExceptionReporter.logExceptions(ex);
         throw ex;
      }
   }

   public static void closeConnection(String username) throws SQLException {
      try
      {
         Connection con = userCons.get(username);

         if (con != null) {
            con.close();
            userCons.remove(username);
         }
      }catch (SQLException ex) {
         JDBCExceptionReporter.logExceptions(ex);
         throw ex;
      }
   }

   public Connection getConnection() throws SQLException {

      try {

         Authentication auth = SecurityContextHolder.getContext().getAuthentication();
         Connection con = null;
         String username = null, password = null;

         if (auth != null && auth.isAuthenticated()) {
            Object tmp = auth.getPrincipal();
            username = tmp instanceof User ? ((User)tmp).getUsername() : tmp.toString();
            password = auth.getCredentials().toString();
         }

         if (username == null || password == null || "".equals(password.trim()))
            // || !Constants.AUTH_TYPE_DATABASE.equals(userAuthType.get(username))
          {
            log.warn("[CONNECTION PROVIDER] Returning generic connection for username: " + username);
            return super.getConnection();
         }

         con = userCons.get(username);

         if (con != null && !username.equals(con.getMetaData().getUserName())) {
            log.fatal("[CONNECTION PROVIDER] getting connection for username: " + username +
                 ". Connection username is:" +
                 (con != null ? con.getMetaData().getUserName() : "STILL NO CONNECTION"));
         }

         if (con == null || con.isClosed()) {
            try {
               String authType = userAuthType.get(username);
            
               if (authType == null || Constants.AUTH_TYPE_DATABASE.equals(authType)) {
                  con = BaseDaoHibernate.getDataBaseConnection(username, password);
                  userCons.put(username, con);
                  userAuthType.put(username, Constants.AUTH_TYPE_DATABASE);
               } else {
                  log.debug("Returning generic connection for user with username: " + username);
                  userAuthType.put(username,Constants.AUTH_TYPE_USERTABLE);
                  return super.getConnection();
               }
            } catch(SQLException e) {
               log.debug("Returning generic connection for username: " + username + e.getMessage() +
                       ". Probably an user authenticated agains user table.\n");
               
               userAuthType.put(username,Constants.AUTH_TYPE_USERTABLE);
               return super.getConnection();
            }
         }

         return con;

      } catch (Exception e) {
         log.debug("Error getting connection from ConnectionProvider: " + e.getMessage());
         return super.getConnection();
      }
   }

}


and this are the errors i get...

Code:
compile-web:
     [echo] Compiling web...
    [javac] Compiling 182 source files to D:\Source\cbvpapp\build\web\classes
    [javac] D:\Source\cbvpapp\src\web\py\cbvpapp\webapp\util\CustomConnectionProvider.java:13: package org.hibernate.connection does not exist
    [javac] import org.hibernate.connection.ConnectionProvider;
    [javac]                                ^
    [javac] D:\Source\cbvpapp\src\web\py\cbvpapp\webapp\util\CustomConnectionProvider.java:14: package org.hibernate.util does not exist
    [javac] import org.hibernate.util.JDBCExceptionReporter;
    [javac]                          ^
    [javac] D:\Source\cbvpapp\src\web\py\cbvpapp\webapp\util\CustomConnectionProvider.java:21: cannot access org.hibernate.connection.ConnectionProvider
    [javac] class file for org.hibernate.connection.ConnectionProvider not found
    [javac] public class CustomConnectionProvider extends LocalDataSourceConnectionProvider implements ConnectionProvider{
    [javac]        ^
    [javac] D:\Source\cbvpapp\src\web\py\cbvpapp\webapp\util\CustomSessionFactory.java:3: package org.hibernate does not exist
    [javac] import org.hibernate.HibernateException;
    [javac]                     ^
    [javac] D:\Source\cbvpapp\src\web\py\cbvpapp\webapp\util\CustomSessionFactory.java:4: package org.hibernate.cfg does not exist
    [javac] import org.hibernate.cfg.Configuration;
    [javac]                         ^
    [javac] D:\Source\cbvpapp\src\web\py\cbvpapp\webapp\util\CustomSessionFactory.java:5: package org.hibernate.cfg does not exist
    [javac] import org.hibernate.cfg.Environment;
    [javac]                         ^
    [javac] D:\Source\cbvpapp\src\web\py\cbvpapp\webapp\util\CustomSessionFactory.java:10: cannot find symbol
    [javac] symbol  : class Configuration
    [javac] location: class py.cbvpapp.webapp.util.CustomSessionFactory
    [javac]    protected void postProcessConfiguration(Configuration config) throws HibernateException {
    [javac]                                            ^
    [javac] D:\Source\cbvpapp\src\web\py\cbvpapp\webapp\util\CustomSessionFactory.java:10: cannot find symbol
    [javac] symbol  : class HibernateException
    [javac] location: class py.cbvpapp.webapp.util.CustomSessionFactory
    [javac]    protected void postProcessConfiguration(Configuration config) throws HibernateException {
    [javac]                                                                         ^
    [javac] D:\Source\cbvpapp\src\web\py\cbvpapp\webapp\util\CustomConnectionProvider.java:46: cannot find symbol
    [javac] symbol  : variable JDBCExceptionReporter
    [javac] location: class py.cbvpapp.webapp.util.CustomConnectionProvider
    [javac]          JDBCExceptionReporter.logExceptions(ex);
    [javac]          ^
    [javac] D:\Source\cbvpapp\src\web\py\cbvpapp\webapp\util\CustomConnectionProvider.java:61: cannot find symbol
    [javac] symbol  : variable JDBCExceptionReporter
    [javac] location: class py.cbvpapp.webapp.util.CustomConnectionProvider
    [javac]          JDBCExceptionReporter.logExceptions(ex);
    [javac]          ^
    [javac] D:\Source\cbvpapp\src\web\py\cbvpapp\webapp\util\CustomConnectionProvider.java:87: cannot find symbol
    [javac] symbol  : variable super
    [javac] location: class py.cbvpapp.webapp.util.CustomConnectionProvider
    [javac]             return super.getConnection();
    [javac]                    ^
    [javac] D:\Source\cbvpapp\src\web\py\cbvpapp\webapp\util\CustomConnectionProvider.java:111: cannot find symbol
    [javac] symbol  : variable super
    [javac] location: class py.cbvpapp.webapp.util.CustomConnectionProvider
    [javac]                   return super.getConnection();
    [javac]                          ^
    [javac] D:\Source\cbvpapp\src\web\py\cbvpapp\webapp\util\CustomConnectionProvider.java:119: cannot find symbol
    [javac] symbol  : variable super
    [javac] location: class py.cbvpapp.webapp.util.CustomConnectionProvider
    [javac]                return super.getConnection();
    [javac]                       ^
    [javac] D:\Source\cbvpapp\src\web\py\cbvpapp\webapp\util\CustomConnectionProvider.java:127: cannot find symbol
    [javac] symbol  : variable super
    [javac] location: class py.cbvpapp.webapp.util.CustomConnectionProvider
    [javac]          return super.getConnection();
    [javac]                 ^
    [javac] D:\Source\cbvpapp\src\web\py\cbvpapp\webapp\util\CustomSessionFactory.java:11: cannot find symbol
    [javac] symbol  : variable Environment
    [javac] location: class py.cbvpapp.webapp.util.CustomSessionFactory
    [javac]       config.setProperty(Environment.CONNECTION_PROVIDER, CustomConnectionProvider.class.getName());
    [javac]                          ^
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
    [javac] 15 errors

BUILD FAILED


The weird thing is that eclipse recognize the package... this is a print from my current workspace...

Image

I hope you can help me, and sorry for my english... :)


Top
 Profile  
 
 Post subject: Re: package org.hibernate.* doesn't exists
PostPosted: Thu Jan 14, 2010 8:51 pm 
Newbie

Joined: Wed Jan 13, 2010 7:11 pm
Posts: 2
Anybody? I really need to find a solution for this :S


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.