Archive for February, 2011

27
Feb
11

making cakephp work with xampp under windows


To make CakePHP work under XAMPP, I extracted the CakePHP zip to my htdocs folder, in the folder named app. But, everytime I wanted to access the http://localhost/app I’d receive the Object not found error message. To fix this, I added the following in my httpd.conf:

<Directory “d:\work\my_sites”>
Order Deny,Allow
Allow from all
Options All
AllowOverride All
</Directory>

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
DocumentRoot “d:\work\my_sites\app1”
ServerName app1.local
</VirtualHost>

And, of course I moved everything to d:\work\my_sites\app1 as you can see from the settings. To make DNS resolution work, I modified the c:\Windows\System32\drivers\etc\hosts file, and added this:

127.0.0.1 app1.local

After which, I navigated to http://app1.local and everything worked.

26
Feb
11

changing brightness in xubuntu

echo -n 100 > /proc/acpi/video/VGA/LCD/brightness

will set the display on maximum brightness. Solution found here.

26
Feb
11

Hibernate exceptions 0.04 Exception in thread “main” org.hibernate.SessionException: Session was already closed


I received this exception:

Exception in thread "main" org.hibernate.SessionException: Session was already closed

A solution is presented in this post. Another solution would be to modify your code to use this:

HibernateUtil.getSessionFactory().openSession();

the first time, instead of :

HibernateUtil.getSessionFactory().getCurrentSession();

The above solution was found on this stackoverflow answer

26
Feb
11

Hibernate exceptions 0.03 Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: javax/persistence/JoinTable


If you receive this error, Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: javax/persistence/JoinTable, make sure you have the ejb3-persistence.jar added to your classpath.

26
Feb
11

Hibernate-Mapping package attribute


The package attribute in <hibernate-mapping package=”some.package”> is used so that you can write:

<hibernate-mapping package=”h1″>

<class name=”Whatever” table=”WHATEVER”>
<id name=”id” column=”WHATEVER_ID”>
<generator class=”native”/>
</id>
</class>

</hibernate-mapping>

instead of:

<hibernate-mapping>

<class name=”h1.Whatever” table=”WHATEVER”>
<id name=”id” column=”WHATEVER_ID”>
<generator class=”native”/>
</id>
</class>

</hibernate-mapping>

26
Feb
11

Hibernate exceptions 0.02 Exception in thread “main” org.hibernate.HibernateException: No CurrentSessionContext configured!


This will appear if you didn’t define the current_session_context_class property. One possible way of fixing this would be adding:

<property name=”current_session_context_class”>thread</property>

to your hibernate.cfg.xml

26
Feb
11

Hibernate exceptions 0.01 Caused by: org.xml.sax.SAXParseException: The content of element type “session-factory” must match “(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)”.


I received this:


Caused by: org.xml.sax.SAXParseException: The content of element type "session-factory" must match "(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)".

Seems to have been caused because I had this in my hibernate.cfg.xml:


<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
    <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
    <property name="hibernate.connection.url">jdbc:hsqldb:hsql://localhost</property>
    <property name="hibernate.connection.username">sa</property>
    <mapping class="h1.User" file="" jar="" package="" resource="User.hbm.xml"/>
    <property name="hbm2ddl.auto">update</property>
  </session-factory>
</hibernate-configuration>

It got fixed after I put the properties sequentially, like this:


<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
    <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
    <property name="hibernate.connection.url">jdbc:hsqldb:hsql://localhost</property>
    <property name="hibernate.connection.username">sa</property>
    <property name="hbm2ddl.auto">update</property>
    <mapping class="h1.User" file="" jar="" package="" resource="User.hbm.xml"/>
  </session-factory>
</hibernate-configuration>




Blog Stats

  • 219,948 hits