-->
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.  [ 3 posts ] 
Author Message
 Post subject: ERROR Configuration:403 - Could not configure datastore from
PostPosted: Sun Mar 19, 2006 9:53 pm 
Newbie

Joined: Sun Mar 19, 2006 9:21 pm
Posts: 3
Hi there,

I am having the darndest time trying to get hibernate working for a pretty simple example I have. It most likely however is because I am doing something wrong :-) I'm kind of a newbie to this.


Okay, so here is my situation. I keep getting an error when hibernate tries to load one of my mapping files. The error is the same one as I have placed in the subject line of this topic. I have the following simple relationship:


A single User (which is one of my POJOs) may have many Role (which is one of my POJOs)s. So, I'm modeling this relationship as a one-to-many relationship.

Here are my three tables. I'm using one table for the User class (called "users"), one table for the Role class (called "roles") and one table for the one-to-many association (called "role_map").

Here is the DDL schema for them:

create table role_map (
role_map_id INTEGER not null,
role_id INTEGER not null,
user_id INTEGER not null, constraint role_map_PK primary key (role_map_id) );

create table user(
user_id INTEGER not null,
user_name VARCHAR(255) not null, constraint user_PK primary key (user_id) );

create table roles (
role_id INTEGER not null,
role_name VARCHAR(255) not null, constraint roles_PK primary key (role_id) );


Here are the POJO java classes:

public class User {

private long id = -1;

private String displayname = null;

private String username = null;

private String password = null;

private Set userRoles = new HashSet();


public User() {

}


/**
* @return Returns the username.
* @hibernate.property
* @hibernate.column name="nyu_uid"
*/
public String getUsername() {
return username;
}

/**
* @param id
* The username to set.
*/
public void setUsername(String id) {
username = id;
}

/**
* @return Returns the userRole.
* @hibernate.set inverse="false" table="role_map" name="userRoles"
* @hibernate.collection-key column="user_id"
* @hibernate.collection-one-to-many class="gov.nasa.jpl.edrn.nyu.ctscan.structs.Role"
*/
public Set getUserRoles() {
return userRoles;
}

/**
* @param userRole
* The userRole to set.
*/
public void setUserRoles(Set r) {
this.userRoles = r;
}
/**
* @return Returns the id.
* @hibernate.id generator-class="increment" column="user_id"
*/
public long getId() {
return id;
}

private void setId(long id) {
this.id = id;
}
}


public class Role{

/* the ID of the role object */
private long id = -1;

/* the name of the role object */
private String roleName = null;


public Role(){

}


/**
* @return Returns the id.
* @hibernate.id generator-class="increment" column="role_id"
*/
public long getId() {
return id;
}

private void setId(long id) {
this.id = id;
}

/**
* @return Returns the roleName.
* @hibernate.property
* @hibernate.column name="role_name"
*/
public String getRoleName() {
return roleName;
}

public void setRoleName(String roleName) {
this.roleName = roleName;
}


public String toString(){
return this.roleName;
}
}


As you can tell, I'm using the XDoclet tags to automatically generate the .hbm.xml files for Role and for User. Here are the generated .hbm.xml files:

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 1.1//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd">

<hibernate-mapping>
<class
name="gov.nasa.jpl.edrn.nyu.ctscan.structs.User"
table="users"
>

<id
name="id"
column="user_id"
type="long"
>
<generator class="increment">
</generator>
</id>

<property
name="username"
type="java.lang.String"
>
<column
name="nyu_uid"
/>
</property>

<set
role="userRoles"
table="role_map"
lazy="false"
readonly="false"
cascade="none"
sort="unsorted"
>

<key
column="user_id"
/>

<one-to-many
class="gov.nasa.jpl.edrn.nyu.ctscan.structs.Role"
/>
</set>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-User.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 1.1//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd">

<hibernate-mapping>
<class
name="gov.nasa.jpl.edrn.nyu.ctscan.structs.Role"
table="roles"
>

<id
name="id"
column="role_id"
type="long"
>
<generator class="increment">
</generator>
</id>

<property
name="roleName"
type="java.lang.String"
>
<column
name="role_name"
/>
</property>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Role.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>

Okay. So, I've verified that the hbm.xml files are getting placed at the right point in the classpath because it's able to load the Roles.hbm.xml fine, without any errors. Where I get errors is when it starts to load the User.hbm.xml file. Here is the output from my Tomcat log. By the way, I happen to be using Hibernate within Tomcat 5.5.19 (with JDK 1.4 compabability classes):

INFO: Undeploying context [/ctscan]
Mar 19, 2006 5:13:48 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading this Context has started
17:13:54,085 INFO Environment:460 - Hibernate 3.0
17:13:54,099 INFO Environment:473 - hibernate.properties not found
17:13:54,105 INFO Environment:506 - using CGLIB reflection optimizer
17:13:54,107 INFO Environment:536 - using JDK 1.4 java.sql.Timestamp handling
17:13:54,319 INFO Configuration:1159 - configuring from resource: /hibernate.cfg.xml
17:13:54,320 INFO Configuration:1130 - Configuration resource: /hibernate.cfg.xml
17:13:54,483 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath under org/hibernate/
17:13:54,486 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath
17:13:54,555 DEBUG Configuration:1116 - connection.driver_class=com.mysql.jdbc.Driver
17:13:54,557 DEBUG Configuration:1116 - connection.url=jdbc:mysql://XXX:3306/ctscan?autoReconnect=true
17:13:54,561 DEBUG Configuration:1116 - connection.username=XXX
17:13:54,562 DEBUG Configuration:1116 - connection.password=XXX
17:13:54,568 DEBUG Configuration:1116 - connection.pool_size=1
17:13:54,569 DEBUG Configuration:1116 - dialect=org.hibernate.dialect.MySQLDialect
17:13:54,570 DEBUG Configuration:1116 - current_session_context_class=thread
17:13:54,572 DEBUG Configuration:1116 - show_sql=true
17:13:54,574 DEBUG Configuration:1311 - null<-org.dom4j.tree.DefaultAttribute@bf3d7c [Attribute: name resource value "gov/nasa/jpl/edrn/nyu/ctscan/structs/CTScan.hbm.xml"]
17:13:54,579 INFO Configuration:440 - Mapping resource: gov/nasa/jpl/edrn/nyu/ctscan/structs/CTScan.hbm.xml
17:13:54,594 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-1.1.dtd in classpath under org/hibernate/
17:13:54,604 DEBUG DTDEntityResolver:49 - http://hibernate.sourceforge.net/hibern ... ng-1.1.dtd not found in classpath
17:13:56,402 INFO HbmBinder:258 - Mapping class: gov.nasa.jpl.edrn.nyu.ctscan.structs.CTScan -> ctscan
17:13:56,431 DEBUG HbmBinder:1089 - Mapped property: id -> ctscan_id
17:13:56,458 DEBUG HbmBinder:1089 - Mapped property: ctscanLabel -> ctscan_lbl
17:13:56,460 DEBUG HbmBinder:1089 - Mapped property: imageDiskUri -> image_disk_uri
17:13:56,462 DEBUG HbmBinder:1089 - Mapped property: lastModifiedBy -> last_modified_by
17:13:56,464 DEBUG HbmBinder:1089 - Mapped property: lastModifiedDateTime -> last_modified_timestamp
17:13:56,468 DEBUG HbmBinder:1089 - Mapped property: nextFollowup -> next_followup
17:13:56,472 DEBUG HbmBinder:1089 - Mapped property: nextFollowupUnit -> next_followup_unit
17:13:56,475 DEBUG HbmBinder:1089 - Mapped property: noChange -> no_change
17:13:56,480 DEBUG HbmBinder:1089 - Mapped property: numberOfNodules -> number_of_nodules
17:13:56,495 DEBUG HbmBinder:1089 - Mapped property: participantNum -> participant_num
17:13:56,513 DEBUG HbmBinder:1089 - Mapped property: radiologistUid -> radiologist_uid
17:13:56,516 DEBUG HbmBinder:1089 - Mapped property: readingDate -> reading_date
17:13:56,545 DEBUG HbmBinder:1089 - Mapped property: studyDate -> study_date
17:13:56,762 DEBUG HbmBinder:1089 - Mapped property: followUp -> ct_followup_id
17:13:56,764 DEBUG HbmBinder:1089 - Mapped property: location -> location_id
17:13:56,766 DEBUG Configuration:1311 - null<-org.dom4j.tree.DefaultAttribute@9caf98 [Attribute: name resource value "gov/nasa/jpl/edrn/nyu/ctscan/structs/Role.hbm.xml"]
17:13:56,767 INFO Configuration:440 - Mapping resource: gov/nasa/jpl/edrn/nyu/ctscan/structs/Role.hbm.xml
17:13:56,777 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-1.1.dtd in classpath under org/hibernate/
17:13:56,781 DEBUG DTDEntityResolver:49 - http://hibernate.sourceforge.net/hibern ... ng-1.1.dtd not found in classpath
17:13:57,365 INFO HbmBinder:258 - Mapping class: gov.nasa.jpl.edrn.nyu.ctscan.structs.Role -> roles
17:13:57,373 DEBUG HbmBinder:1089 - Mapped property: id -> role_id
17:13:57,375 DEBUG HbmBinder:1089 - Mapped property: roleName -> role_name
17:13:57,376 DEBUG Configuration:1311 - null<-org.dom4j.tree.DefaultAttribute@cc5532 [Attribute: name resource value "gov/nasa/jpl/edrn/nyu/ctscan/structs/CTFollowupReason.hbm.xml"]
17:13:57,392 INFO Configuration:440 - Mapping resource: gov/nasa/jpl/edrn/nyu/ctscan/structs/CTFollowupReason.hbm.xml
17:13:57,399 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-1.1.dtd in classpath under org/hibernate/
17:13:57,401 DEBUG DTDEntityResolver:49 - http://hibernate.sourceforge.net/hibern ... ng-1.1.dtd not found in classpath
17:13:58,328 INFO HbmBinder:258 - Mapping class: gov.nasa.jpl.edrn.nyu.ctscan.structs.CTFollowupReason -> ct_followups
17:13:58,329 DEBUG HbmBinder:1089 - Mapped property: id -> ct_followup_id
17:13:58,330 DEBUG HbmBinder:1089 - Mapped property: followupReason -> ct_followup_reason
17:13:58,331 DEBUG Configuration:1311 - null<-org.dom4j.tree.DefaultAttribute@ed5a07 [Attribute: name resource value "gov/nasa/jpl/edrn/nyu/ctscan/structs/CTScanLocation.hbm.xml"]
17:13:58,332 INFO Configuration:440 - Mapping resource: gov/nasa/jpl/edrn/nyu/ctscan/structs/CTScanLocation.hbm.xml
17:13:58,340 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-1.1.dtd in classpath under org/hibernate/
17:13:58,343 DEBUG DTDEntityResolver:49 - http://hibernate.sourceforge.net/hibern ... ng-1.1.dtd not found in classpath
17:13:59,305 INFO HbmBinder:258 - Mapping class: gov.nasa.jpl.edrn.nyu.ctscan.structs.CTScanLocation -> ctscan_locations
17:13:59,309 DEBUG HbmBinder:1089 - Mapped property: id -> location_id
17:13:59,312 DEBUG HbmBinder:1089 - Mapped property: locationName -> location_name
17:13:59,313 DEBUG Configuration:1311 - null<-org.dom4j.tree.DefaultAttribute@b1aeaa [Attribute: name resource value "gov/nasa/jpl/edrn/nyu/ctscan/structs/CTScanType.hbm.xml"]
17:13:59,317 INFO Configuration:440 - Mapping resource: gov/nasa/jpl/edrn/nyu/ctscan/structs/CTScanType.hbm.xml
17:13:59,408 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-1.1.dtd in classpath under org/hibernate/
17:13:59,444 DEBUG DTDEntityResolver:49 - http://hibernate.sourceforge.net/hibern ... ng-1.1.dtd not found in classpath
17:14:00,385 INFO HbmBinder:258 - Mapping class: gov.nasa.jpl.edrn.nyu.ctscan.structs.CTScanType -> ctscan_types
17:14:00,393 DEBUG HbmBinder:1089 - Mapped property: id -> ctscan_type_id
17:14:00,395 DEBUG HbmBinder:1089 - Mapped property: scanType -> ctscan_type
17:14:00,396 DEBUG Configuration:1311 - null<-org.dom4j.tree.DefaultAttribute@422b27 [Attribute: name resource value "gov/nasa/jpl/edrn/nyu/ctscan/structs/User.hbm.xml"]
17:14:00,401 INFO Configuration:440 - Mapping resource: gov/nasa/jpl/edrn/nyu/ctscan/structs/User.hbm.xml
17:14:00,500 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-1.1.dtd in classpath under org/hibernate/
17:14:00,504 DEBUG DTDEntityResolver:49 - http://hibernate.sourceforge.net/hibern ... ng-1.1.dtd not found in classpath
17:14:01,307 INFO HbmBinder:258 - Mapping class: gov.nasa.jpl.edrn.nyu.ctscan.structs.User -> users
17:14:01,308 DEBUG HbmBinder:1089 - Mapped property: id -> user_id
17:14:01,309 DEBUG HbmBinder:1089 - Mapped property: username -> nyu_uid
17:14:01,315 ERROR Configuration:403 - Could not configure datastore from input stream
java.lang.NullPointerException
at org.hibernate.util.StringHelper.qualify(StringHelper.java:229)
at org.hibernate.cfg.HbmBinder.bindCollection(HbmBinder.java:1113)
at org.hibernate.cfg.HbmBinder$2.create(HbmBinder.java:2453)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:1676)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:317)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:235)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:151)
at org.hibernate.cfg.Configuration.add(Configuration.java:359)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:396)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:445)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1312)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1284)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1266)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1233)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1161)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1147)
at gov.nasa.jpl.edrn.nyu.ctscan.util.HibernateUtil.<clinit>(HibernateUtil.java:31)
at gov.nasa.jpl.edrn.nyu.ctscan.system.HibernateCTScanSystem.retrieveObjectByIdAndClass(HibernateCTScanSystem.java:105)
at gov.nasa.jpl.edrn.nyu.ctscan.authentication.DummyAuthenticator.authenticate(DummyAuthenticator.java:39)
at org.apache.jsp.login_jsp._jspService(login_jsp.java:86)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:552)
Initial SessionFactory creation failed.org.hibernate.MappingException: Error reading resource: gov/nasa/jpl/edrn/nyu/ctscan/structs/User.hbm.xml


Top
 Profile  
 
 Post subject: 2c
PostPosted: Mon Mar 20, 2006 7:16 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
If you are using Hibernate 3 then mapping should say
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

That will make many things easier and faster.

Check if that will help

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 20, 2006 8:00 pm 
Newbie

Joined: Sun Mar 19, 2006 9:21 pm
Posts: 3
Hi There,

Thanks, that fixed it! I was using Hibernate 3.0 style mappings with the wrong DTD. I had my XDoc setttings incorrectly. Thanks for the help!

Cheers,
Chris


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