Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7821891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:46:47+00:00 2026-06-02T07:46:47+00:00

I’m currently experiencing an interesting problem. My Situation: I am currently developing a web

  • 0

I’m currently experiencing an interesting problem.

My Situation:

  • I am currently developing a web service (I’m using VAADIN for programming with JAVA in eclipse)
  • My database behind is java derby
  • I am using hibernate for my database
  • I’m currently deploying it on Tomcat v7.0

My Problem:

  • When I change something in my code (doesn’t matter what), the server should reload it without the need of being restarted – I guess that’s the overall expected behaviour
  • The server reloads the application successfull, but if I try to click on something (so after the reloading), e.g. the login-Button, I get an error

Error Message:

Cause: org.hibernate.exception.GenericJDBCException: Could not open
connection] with root cause ERROR XSDB6: Another instance of Derby may
have already booted the database C:\HTML-Ausgabe\database\DocumentDB.
at org.apache.derby.iapi.error.StandardException.newException(Unknown
Source) …

My Thoughts on this

It seems that somehow on the reloading process the connection/context to hibernate doesnt get destroyed/closed and so the error occures when the server tries to reconnect to the database

My Code

I have a class, called Hibernate Listener:

public class HibernateListener implements ServletContextListener {

    public void contextInitialized(ServletContextEvent event) {
        HibernateUtil.getSessionFactory(); // Just call the static initializer of that class    
    }

    public void contextDestroyed(ServletContextEvent event) {
        HibernateUtil.getSessionFactory().close(); // Free all resources
    }
}

My hibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">org.apache.derby.jdbc.EmbeddedDriver</property>
        <property name="hibernate.connection.url">jdbc:derby:C:\HTML-Ausgabe\database\DocumentDB;create=true</property>
        <property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
        <property name="hibernate.current_session_context_class">thread</property>
        <property name="hibernate.hbm2ddl.auto">create-drop</property>
        <property name="hibernate.show_sql">true</property>

        <mapping class="view.model.database.User"/>
        <mapping class="view.model.database.Document"/>
        <mapping class="view.model.database.Version"/>
        <mapping class="view.model.database.VersionData"/>
    </session-factory>
</hibernate-configuration>

My (VAADIN) web.xml, in which I added a “listener” for the upper shown HibernateListener (check the text at listener ):

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>Bachelorprojekt</display-name>
    <context-param>
        <description>Vaadin production mode</description>
        <param-name>productionMode</param-name>
        <param-value>false</param-value>
    </context-param>
    <servlet>
        <servlet-name>Bachelorprojekt Application</servlet-name>
        <servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
        <init-param>
            <description>Vaadin application class to start</description>
            <param-name>application</param-name>
            <param-value>view.view.WebsiteFrame</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>Bachelorprojekt Application</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

    <listener>
        <listener-class>view.model.database.HibernateListener</listener-class>
    </listener>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
</web-app>

I did research, posted also on the hibernate forum (still without even a single answer 🙁 ) and now did not find a matching theme on this website. So I hope I didn’t do something wrong.

If anyone of you could help me somehow, I would be really happy. Currently I dont know what to change to stop this error happening. And, of course, I cant always restart the whole server later when my application is on the internet, if I change one line of code.

Thanks a lot for every answer and thought that you’re sharing with me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:46:48+00:00Added an answer on June 2, 2026 at 7:46 am

    I found the solution to my problem.

    First of all, it was an apache derby problem, as I forced it to close with

    public void contextDestroyed(ServletContextEvent event) {
        HibernateUtil.getSessionFactory().close(); // Free all resources
        try {
              DriverManager.getConnection("jdbc:derby:;shutdown=true");
        } catch (SQLException e) {}
        }
    }
    

    it worked fine for me.

    Now I swichted my database vom apache derby to mysql and noticed that the problem, described in my question above, didn’t occur anymore.

    So, lesson learned: Don’t use apache derby. I hope this helps someone else someday. Thanks a lot for your help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am currently running into a problem where an element is coming back from
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.