-->
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: MySQL IP address in URL problems
PostPosted: Fri Sep 24, 2004 6:09 am 
Newbie

Joined: Tue Aug 24, 2004 1:14 pm
Posts: 14
Hibernate version:
2.1.4
Mapping documents:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<hibernate-configuration>

<session-factory>
<!-- properties -->
<property name="connection.username">rbbh</property>
<property name="connection.url">jdbc:mysql://192.168.0.1:3306/rbbh_freedom</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="connection.password">battle</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>

<!-- mapping files -->
<mapping resource="co/uk/fastest/foi/hibernate/Users.hbm.xml"/>
<mapping resource="co/uk/fastest/foi/hibernate/Organisation.hbm.xml"/>
<mapping resource="co/uk/fastest/foi/hibernate/OrganisationContacts.hbm.xml"/>
<mapping resource="co/uk/fastest/foi/hibernate/ThirdPartys.hbm.xml"/>
<mapping resource="co/uk/fastest/foi/hibernate/Requests.hbm.xml"/>
<mapping resource="co/uk/fastest/foi/hibernate/Applicants.hbm.xml"/>
<mapping resource="co/uk/fastest/foi/hibernate/Documents.hbm.xml"/>
<mapping resource="co/uk/fastest/foi/hibernate/Steps.hbm.xml"/>
<mapping resource="co/uk/fastest/foi/hibernate/Actions.hbm.xml"/>

</session-factory>

</hibernate-configuration>

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<!-- Created Thu Sep 23 18:56:30 BST 2004 -->
<hibernate-mapping package="co.uk.fastest.foi.hibernate">

<class name="Users" table="Users">
<id name="usersUsername" column="users_username" type="java.lang.String">
<generator class="assigned"/>
</id>

<property name="usersPassword" column="users_password" type="java.lang.String" not-null="true" />
<property name="usersLevel" column="users_level" type="java.lang.Integer" not-null="true" />
<property name="usersEmail" column="users_email" type="java.lang.String" not-null="true" />
<property name="usersDepartment" column="users_department" type="java.lang.String" not-null="true" />
<property name="usersTitle" column="users_title" type="java.lang.String" not-null="true" />
<property name="usersJobTitle" column="users_job_title" type="java.lang.String" />
<property name="usersFirstName" column="users_first_name" type="java.lang.String" not-null="true" />
<property name="usersInitials" column="users_initials" type="java.lang.String" not-null="true" />
<property name="usersSurname" column="users_surname" type="java.lang.String" not-null="true" />
<property name="usersTelephone" column="users_telephone" type="java.lang.Long" not-null="true" />
<property name="usersGenPassword" column="users_gen_password" type="java.lang.String" not-null="true" />
<property name="usersLastLogin" column="users_last_login" type="java.util.Date" />
<property name="usersLastLoginTime" column="users_last_login_time" type="java.util.Date" />
</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
public static Session currentSession() throws HibernateException {
Session session = (Session) threadLocal.get();

if (session == null) {
if (sessionFactory == null) {
try {
cfg.configure(CONFIG_FILE_LOCATION);
sessionFactory = cfg.buildSessionFactory();
}
catch (Exception e) {
System.err.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}
session = sessionFactory.openSession();
threadLocal.set(session);
}

return session;
}

public Users getUsers ( String username ) { // start of the method getUsers


try { // start o fthe try statement

// load a jdbc instance from the session factory
session = HibernateSessionFactory.currentSession ( );
return ( Users ) session.load ( Users.class, username );

} // end of the try statement

catch ( ObjectNotFoundException onfe ) { // start of the no object exception
return null;
} // end of the no object exception
catch ( HibernateException e ) { // start of the catch hibernate exception
return null;
} // end of the hibernate exception

/*
* finally { // start of the finally statement
*
* if ( session != null ) { // start of the if statement try { // start of the try statement session.close ( ); } // end of the try statement
*
* catch ( HibernateException e ) { // start of the hibernate exception throw new RuntimeException ( e ); } // end of the hibernate exception
* } // end of the if statement
* } // end of the finally
*/

} // end fo the method getUsers

Full stack trace of any exception that occurs:
2004-09-23 19:05:12,413 INFO [STDOUT] %%%% Error Creating SessionFactory %%%%
2004-09-23 19:05:12,568 INFO [STDOUT] net.sf.hibernate.HibernateException: /hibernate.cfg.xml not found
at net.sf.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:849)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:873)
at co.uk.fastest.foi.hibernate.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:48)
at co.uk.fastest.foi.hibernate.Database.getUsers(Database.java:93)
at co.uk.fastest.foi.struts.action.LoginAction.execute(LoginAction.java:37)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:44)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:169)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
2004-09-23 19:05:12,730 WARN [org.apache.struts.action.RequestProcessor] Unhandled Exception thrown: class java.lang.NullPointerException
2004-09-23 19:05:12,731 ERROR [org.jboss.web.localhost.Engine] StandardWrapperValve[action]: Servlet.service() for servlet action threw exception
java.lang.NullPointerException
at co.uk.fastest.foi.hibernate.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:56)
at co.uk.fastest.foi.hibernate.Database.getUsers(Database.java:93)
at co.uk.fastest.foi.struts.action.LoginAction.execute(LoginAction.java:37)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:44)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:169)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)

Name and version of the database you are using:
MySQL 4.0.18
The generated SQL (show_sql=true):
drop table if exists Users;
create table Users
(
users_username varchar(10) not null primary key,
users_password varchar(10) not null,
users_level int unsigned not null,
users_email varchar(125) not null,
users_department varchar(50) not null,
users_title varchar(5) not null,
users_job_title varchar(100),
users_first_name varchar(25) not null,
users_initials varchar(5) not null,
users_surname varchar(25) not null,
users_telephone bigint unsigned not null,
users_gen_password varchar(10) not null,
users_last_login date
);

This all worked all fine under RedHat Linux, i used localhost in the URL. I have moved to SuSE localhost i needed specifing the ip address instead. So i decided to be clever and have a central db server, on the internal network with the ip address 192.168.0.1.

The code above works fine when called in a java application calling the same code once put in a java application server it doesn't work. What have i done wrong.

This i find really wierd as the error seems to be that it can't find the hibernate.cfg.xml file.

Sorry to keep asking iratting questions and thanks in advance.

Tom


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 24, 2004 6:32 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Quote:
This i find really wierd as the error seems to be that it can't find the hibernate.cfg.xml file.

That's what is happening.

You have to understand how to set up the classpath in your app server or use one of the other configure() methods to access the file form a location outside your ear structure.

HTH
Ernst


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.