Categories
General Java Web Development

Eclipse Subclipse SVN + Hostgator.com

I use Hostgator as my hosting company. I love them – great service, tons of space and no long term obligations. And the servers are fast. Now, another reason to love them – running Subversion repositories on your server with the caveat – you can only have one account to account to access that repository. If you develop by yourself, and I do for now, it’s not a problem. So how do you do it – assuming you are a Java coder using Eclipse on Windows?

  1. Send Hostgator support a request to get SSH access to your server. They will ask you to send in a picture id and once that is cleared, you should be good to go. A matter of a day or two.
  2. Install Subclipse SVN plugin for Eclipse. The Subversive plugin DOES NOT WORK.
  3. Install the really good Tortoise SVN client
  4. Set up an environment variable called SVN_SSH. To do that, go to the Windows Control Panel -> System -> Advanced -> Environment Variable -> New (under the bottom Window). For variable name enter the value SVN_SSH and for its value enter c:\\Program Files\\TortoiseSVN\\bin\\TortoisePlink.exe (assuming you installed Tortoise SVN in the default location).
  5. Start Eclipse and go to the Subclipse options: Window -> Preferences -> Team -> SVN . There, for the SVN Interface select “SVNKit (Pure Java)”. Click OK to store the setting.
  6. Now, using Putty or some other SSH tool, SSH to your account. You will need to set up a repository for your project. To do that, create the directory that will be used as repository, say /myrepo. Now, create an Subversion repository inside that directory: svnadmin create myrepo.
  7. Create a new project by checking out the repository from SVN. To do that, in Eclipse, go to: File -> New -> Other -> SVN -> Checkout Project From SVN.
  8. The ‘Checkout from SVN’ window will appear. There select to create a new repository location
  9. For the URL, enter: svn+ssh://<your hostgator admin user name>@<your domain name>:2222/home/<your hostgator admin user name>/<Repository directory path>. In other words, if your domain is example.com, your admin user name is joey and the path to your repository is /myrepo, then your URL will be svn+ssh://joey@example.com:2222/home/joey/myrepo
  10. Another popup window will follow that will ask you for your SSH user name. Enter the details and make sure they are saved.

You should be good to go at that point as the rest of the process is the normal project checkout scheme used by Subclipse.

Two resources were helpful: The support message board post on the subject and this blog entry.

Hope this helps!

Share
Categories
Java

Using session scoped beans in Spring

Spring 2.0 added a wonderful scope to the “Singleton” and “Prototype” scopes – “Session”.
For every request, Spring will create an instance of a bean and bind it to that user throughout that user’s session. This is ideal because it keeps the HTTP-connectivity layer outside the realm of the service layer.

It was a bit of a sad moment when Spring told us to shove it when we assigned the session scope to one of our beans. The error looked like

cope 'session' is not active for the current thread; consider defining a scoped proxy for this bean
if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException

Some searching uncovered what else is needed to make session scope happen:
1. In web.xml, define a RequestContextListener, for example:

<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

2. In the body of the session scoped bean, add the following element:
<aop:scoped-proxy/>

Read more.

Share
Categories
Java Oracle

Mapping Hibernate to Oracle Date fields

Sometimes less is more.
We are using Hibernate and one of the tables uses a Date field to store information on what Oracle calls ‘point in time’ – the date and time of an event. The table column was mapped to an object property specifying the property type as “date”. For some reason, that caused the application to only read and write the date part of the ‘point in time’ instead of both the date and the time.
Example:
<property name=”postDate” column=”POST_DATE” not-null=”true” type=”date” />
Thanks to the last comment in this post, I found out that if you remove the explicit type from the Hibernate mapping, the table will be read and written to with both the date and the time.
Example:
<property name=”postDate” column=”POST_DATE” not-null=”true”/>

Share
Share