This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Hibernate Error when inserting into a table  RSS feed

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

ALthough I really like Hibernate, its getting on to my nerves now. All I want to do is to insert in a table and retrieve it back. I was successfull in creating the mapping and I verified that the table gets created.

Our B2B system gets a XML document from a mainframe and the XML file contains unique identifiers which should serve as primary keys of their respective tables.

I have made a very simple mapping file as follows :

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

<hibernate-mapping>

<class name="com.islandpacific.hibernate.ShipmentAddress"
table="shipping_address" dynamic-update="true">

<id name="ship_id" type="int" column="id" unsaved-value="0" length="5" >
<column name="ship_id" sql-type="integer" not-null="true" length="5" />
<generator class="vm"/>
</id>

<property name="storeName" column="store_name"
type="string" not-null="true" />
<property name="addressLine1" column="addr_line1" type="string" not-null="true" length="25" />
<property name="addressLine2" column="addr_line2"
type="string" not-null="false" length="25" />
<property name="city" column="city"
type="string" not-null="true" length="20" />
<property name="state" column="state"
type="string" not-null="true" length="3" />
<property name="zip" column="zip"
type="string" not-null="true" length="10" />
<property name="countryCode" column="country_code"
type="string" not-null="true" />
</class>
</hibernate-mapping>

The following piece of code
try {
session.save(shipmentAddress);
session.flush();
session.connection().commit();
} catch (Exception e) {
session.connection().rollback();
throw e;
}

I am getting the following error message

[CachedConnectionManager] Closing a connection for you. Please close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection@5f7e8f
java.lang.Exception: STACKTRACE
at org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection(CachedCon
nectionManager.java:322)
at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnec
tionManager2.java:475)
at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.alloca
teConnection(BaseConnectionManager2.java:836)
at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:10
2)
at net.sf.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnecti
onProvider.java:59)
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3297)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3277)
at com.islandpacific.web.security.access.ResourceAccessManager.<init>(ResourceAccessManager.
java:84)
at com.islandpacific.struts.actions.ViewUsersAction.execute(ViewUsersAction.java:78)
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.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
ava:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)

at com.islandpacific.web.security.access.AccessControlFilter.doFilter(AccessControlFilter.ja
va:171)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
ava: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:19
8)
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.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:277
)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.ja
va:80)
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:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:122)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:535)
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:793)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11P
rotocol.java:702)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
at java.lang.Thread.run(Thread.java:534)

Please give any pointers ... driving me mad.

Thanks,

Rave.
 
Praveen Kumar
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well it was a problem with Application Server (JBoss). My work mate changed some configurations in config files and I was ready to run.

Hope this helps somebody,

Rave.
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please, post your hibernate config file ....

I thing , it have something wrong in this file.
[ July 09, 2004: Message edited by: somkiat puisungnoen ]
 
Ranch Hand
Posts: 538
Eclipse IDE Hibernate Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rave !

You seem to forget in the shown piece of code
the "session.close();" which usually comes inside a "finally" after commit/rollback attempt, hence "Closing a connection for you. Please close them yourself" issue. If you forget it connection is kept open for very long until server runs out of resources.
Close your sessions after commit/rollback so as to free (and unlock) resources, any system will be angry for you to take so many resources without releasing them.

Best regards.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!