-->
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: java.net.UnknownHostException: hibernate.sourceforge.net
PostPosted: Wed Jun 18, 2008 11:42 am 
Newbie

Joined: Wed Jun 18, 2008 11:29 am
Posts: 2
Hi,
Hoping someone can shed some light on this one, since I've got to the stage where I'm pulling my hair out after having wasted over a day trying to get to the bottom of it.

I'm just starting out with Hibernate, so please bear with me if my question seems a bit daft.

I'm just configuring Hibernate for the first time, and have hit this problem, where it appears that it can't find the DTD for either the hibernate-configuration or the hibernate-mapping. I have the hibernate-3.2.6.ga.jar in the lib directory of my application and also in the manifest of the war file, being deployed onto the webserver. This jar seems to contain the required DTDs.

I've also passed my webserver proxy parameters, so it can go and look online if it really feels the need to.

Unforuntately it's still not working. Here's what my DOCTYPE definitions look like in the config files,
Code:
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<!DOCTYPE hibernate-configuration PUBLIC
   "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">


Within the classes, where I'm trying to use Hibernate, I'm importing,

Code:
org.springframework.orm.hibernate3.support.HibernateDaoSupport


and have included, spring-hibernate3-2.0-m4.jar on my classpath.

My stacktrace looks like this;-

Code:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/spring/dao/hibernate-cfg.xml]; nested exception is java.net.UnknownHostException: hibernate.sourceforge.net
   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:416)
   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
   at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
   at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
   at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
   at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
   at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
   at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
   at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:353)
   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
   at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:829)
   at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:718)
   at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
   at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
   at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
   at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
   at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
   at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
   at org.apache.catalina.core.StandardService.start(StandardService.java:516)
   at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
   at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
   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 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
   at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.net.UnknownHostException: hibernate.sourceforge.net
   at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
   at java.net.Socket.connect(Socket.java:518)
   at java.net.Socket.connect(Socket.java:468)
   at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
   at sun.net.www.http.HttpClient.openServer(HttpClient.java:389)
   at sun.net.www.http.HttpClient.openServer(HttpClient.java:516)
   at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
   at sun.net.www.http.HttpClient.New(HttpClient.java:306)
   at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:795)
   at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:743)
   at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:654)
   at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:977)
   at java.net.URL.openStream(URL.java:1009)
   at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
   at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
   at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source)
   at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
   at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
   at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
   at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
   ... 37 more
18-Jun-2008 15:23:27 org.apache.catalina.core.StandardContext listenerStart


Please can someone help me before I pack this in, and go back to using Spring DAO! Thanks in advance. Seth


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 9:24 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Your parser is validating the doctype in the XML file, and as such, it is trying to access the network. This won't work if you can't get an internet connection.

One solution is to point right to the DTD file directly.

Check out this thread on the topic:



http://www.google.com/notebook/public/06175953054910363255/BDUU0IgoQ57Wi574h

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 9:49 am 
Newbie

Joined: Wed Jun 18, 2008 11:29 am
Posts: 2
Thanks for your help Cameron. I have to be honest, I gave up on this in the end and switched to using Hibernate annotations - tho am still questioning whether I like having code mapping my column names to attribute names in entity/value objects. For the sake of it working, I'll live with it! By using the annotations, I managed to do away with the need for the mapping file, and simply used the annotated Classes property within the AnnotationSessionFactoryBean class instead - much cleaner. For anyone wanting to do something similar, see below:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>

<bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
 
  <property name="hibernateProperties">
    <props>
      <prop key="hibernate.dialect">
        org.hibernate.dialect.MySQLDialect
      </prop>
    </props>
  </property>
 
  <property name="dataSource">
    <ref bean="localDataSource"/>
  </property>
 
  <property name="annotatedClasses">
    <list>
       <value>com.myPackage.vo.Report</value>
     </list>
   </property>
 
</bean>

<bean id="localDataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource">

    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    <property name="url" value="jdbc:mysql://localhost/test"/>
    <property name="username" value="root"/>
    <property name="password" value="letmein"/>
   
</bean>

</beans>


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.