Monday, March 24, 2014

org.springframework.data.mapping.PropertyReferenceException: No property change found for type

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property change found for type Login!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:359)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:270)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:241)
at org.springframework.data.repository.query.parser.Part.<init>(Part.java:76)
at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:201)
at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:291)
at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:271)
at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:80)
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:57)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:91)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:162)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:69)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:304)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:161)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:224)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:210)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:84)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
... 51 more
null
null


The exception above is caused by Named Queries whose names are not properly namespaced.


@NamedQueries({
@NamedQuery(
name = "Login.findLogins",
query = "SELECT login FROM Login login WHERE login.login = :login"
),
@NamedQuery(
name = "Login.changePassword",
query = "Some query"
)})

Saturday, October 19, 2013

Basic web application with SBT for Netbeans from scratch

If you haven't read my previous post SBT application for Netbeans from scratch, you will find it helpful to read it.
This post will illustrate how to create a webapplication from scratch. We will assume some knowledge of setting up a basic scala application with sbt. We won't be creating any scala code. Instead we will try to render a basic index.html page.
  • Create a project directory and name it what you want. cd into the project directory.
  • Create the following directories
mkdir -p src/main/resources src/main/scala src/main/webapp src/main/webapp/WEB-INF src/main/webapp/META-INF src/test/scala src/test/resources project

Application build, dependencies, plugins setup

  • Create build.sbt inside the project root directory and copy the text below into the file.
 name := "scalatra-sbt-1"

 version := "1.0"

 scalaVersion := "2.10.2"

 sbtVersion := "0.12.4"

 seq(webSettings :_*)

 libraryDependencies ++= Seq(
    "ch.qos.logback" % "logback-classic" % "1.0.6" % "runtime",
    "org.mortbay.jetty" % "jetty" % "6.1.22" % "container"
  )
Make sure that each setting is separated by an empty line.
  • Create a new file inside the project directory and name it build.properties. Copy the text below into the build.properties file.
sbt.version=0.12.4
  • Create another file plugins.sbt inside the project directory. Copy the text blow into that file.
// you can also add multiple repositories at the same time
resolvers ++= Seq(
  "Scala Tools Releases" at "http://scala-tools.org/repo-releases/",
  "Java.net Maven2 Repository" at "http://download.java.net/maven/2/"
)

addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "0.4.2")

addSbtPlugin("com.mojolly.scalate" % "xsbt-scalate-generator" % "0.4.2")

addSbtPlugin("org.scalatra.sbt" % "scalatra-sbt" % "0.3.2")

addSbtPlugin( "org.netbeans.nbsbt" % "nbsbt-plugin" % "1.0.2" )
Once again, make sure each sbt task above is followed by an empty line, other wise sbt will complain.

web application setup

  • Create a new file src/main/webapp/index.html and copy the following text into it.
<html>
   <head>
      <title> First Scala WebApp</title>
   </head>
   <body>
      <h1>Hello, world from Scala webapp</h1>
   </body>
</html>
  • Create a new file src/main/webapp/WEB-INF/web.xml file and add the following lines into it.
  <xml version="1.0" encoding="UTF-8">

 <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

 <web-app>

 </web-app>

At this point you should be good to run the application. Use the following commands.
 > sbt clean compile
 >
 > sbt container:start
Now go to app by clicking on the link.
Bingo ! you got your first scala webapp running.

SBT application for Netbeans from scratch

  • mkdir NetbeansSBT
  • mkdir NetbeansSBT
  • Create a new file called build.sbt in the NetbeansSBT directory and add the following lines to it.

name := "netbeans-sbt-1"

version := "1.0"

scalaVersion := "2.10.2"

sbtVersion := "0.12.4"

  • Don't forget to seperate them with empty lines
  • Create a directory called project in the root project directory.
  • Create two files build.properties and plugins.sbt.
  • Open project/build.properties and add the following line

sbt.version=0.12.4

  • Open project/plugins.sbt and add the following line to it.

addSbtPlugin( "org.netbeans.nbsbt" % "nbsbt-plugin" % "1.0.2" )

Notice how the sbt version inside the build.sbt and build.properties match. This is needed.

  • Run the following command from the root directory.

mkdir -p src/main/scala src/main/resources src/test/scala src/test/resources

At this point you should have your project setup. You can now run the following command to compile the project.

sbt clean compile publish-local

We still have to generate netbeans project files so that it can be opened in Netbeans for editing. Use the following commands to do that.

  • Run sbt

    sbt

If you are able to run sbt command ok, you should see output similar to this.

[info] Loading global plugins from /home/venkat/.sbt/plugins

[info] Loading project definition from /home/venkat/Documents/Scala/Scalatra/scalatra-sbt-1/project

[info] Set current project to scalatra-sbt-1 (in build file:/home/venkat/Documents/Scala/Scalatra/scalatra-sbt-1/)`

  • From sbt prompt run the netbeans command. This should generate netbeans files.

> netbeans

[info] About to create NetBeans project files for your project(s).

[info] Successfully created NetBeans project files for project(s):

[info] scalatra-sbt-1

Bingo ! Open the project up in Netbeans. Rant and rave in the comment section.

Friday, August 9, 2013

Perforce Command line tips

  • How to search changelists by user. 
 p4 changes -u vakkive -L
  •  How to apply a patch ?
There is no perforce way to do this. However, IntelliJ has a way to apply patches . Look inside the VCS drop down menu.
 

Thursday, December 13, 2012

Javascript Unit Testing


The following posts will use QUnit functions for testing. There is no explicit marking of QUnit functoins. So, when in doubt search in QUnit API.


Testing if a button was clicked



The following code shows you how to unit test weather a button was clicked in javascript. I found need for this while trying to test the following scenario: When user presses enter while an input box has focus then fire a click event on the button next to the input box.
test(“button clicked”, function(){
$(“#button”).on(‘click’, function(event){
$(this).data(‘clicked’, true);
});

$(“#button”).click();
ok($(“#button”).data(‘clicked’), “button clicked”)
});
As you can see the sky is the limit to what can be tested with such a technique.

Friday, October 5, 2012

Ramaze on OpenShift

Ramaze App on OpenShift



  • Create an account with Openshift.
  • Install rhc gem using the following command.

sudo gem install rhc


  • Complete rhc setup using the OpenShift's get-started page.
  • Log into your OpenShift account and create an application using the web interface.
    • This will create a git repo on openshift.
    • Once application creation is completed a git repo link is provided.
  • Clone the repo to your local workstation using link provided. Url looks something like this. 

ssh://54038126c5ca47f5aa549052cc11cd8d@${app-name}-${namespace}.rhcloud.com/~/git/${app-name}.git/

  • Let's say you have cloned it to $HOME/projects/app

cd app
mv config.ru config.ru.orig
cd ..

ramaze create app
cp $HOME/app/* $HOME/projects/app/ 
cd $HOME/projects/app

  • Openshift uses bundler to manage dependencies. Install bundler using
sudo gem install bundler
  • Create a Gemfile and Gemfile.lock
  • Add the following entries to Gemfile 

gem 'ramaze', '2012.04.14'


gem 'sequel', '3.40.0'


gem 'pg', '0.14.1'
  • Run bundle install. This will update Gemfile.lock file with dependencies.
  • Add all the files to git, commit and push.
  • What's great about Openshift is for every push, it stops the server, builds, redepoys application and starts the server.
  • Now go to the application link provided on your application creation page, you should see the "Welcome to Ramaze" Page.

Here is a deployed application if you want to look at it.










Friday, May 18, 2012

Basic TFS Commands


Checkout Files

tf get /force /overwrite /login:${username}@{domain},${password} 
Links

diff/merge configuration in Team Foundation - common Command and Argument values



Some TFS commands for the rainy day when your TFS goes broke.
Replace the following in the command below with your own information.
$USERNAME = your username
$PASSWORD = your password
$DOMAINNAME = your domain name ( TLR by default. )

Commands

Q.) List my shelves.
A.) tf /login:$USERNAME@$DOMAINNAME,$PASSWORD shelvesets /owner:c138884
Q.) List files modified in working copy.
A.) tf /login:$USERNAME@$DOMAINNAME,$PASSWORD status /recursive .
NOTE: The last dot refers to current directory. If that argument is not specified tfs lists all changes in the workspace. If you have multiple projects inside the workspace the changes are listed per directory.
Q.) List working copy changeset number.
A.) tf /login:$USERNAME@$DOMAINNAME,$PASSWORD history /recursive /stopafter:1 .
Q.) Update project source code to latest version.
A.) tf /login:$USERNAME@$DOMAINNAME,$PASSWORD get /recursive
Q.) Update to specific changeset.
A.) tf /login:$USERNAME@$DOMAINNAME,$PASSWORD get /recursive /version:171568