JPA w/Scala

33 views
Skip to first unread message

Charles F. Munat

unread,
Sep 2, 2008, 10:29:40 PM9/2/08
to Lift
Has anyone followed the JPA tutorial using pure Scala instead of Java?
I've got it very close to running, but I am getting the following error:

[WARNING]
/private/var/www/wsbg/webapp/src/main/scala/com/foo/jpaweb/snippet/AuthorOps.scala:22:
error: value getName is not a member of com.foo.jpaweb.model.Author
[WARNING] "name" --> Text(author.getName()),
[WARNING] ^
[WARNING] one error found

I'm neither a Scala nor a Java programmer, but I'm guessing that the
getter for the name attribute in Scala is not "getName". Is this correct?

Chas.

Charles F. Munat

unread,
Sep 2, 2008, 10:35:39 PM9/2/08
to lif...@googlegroups.com
I figured it out, I think. Should be author.name, without the parentheses.

Derek Chen-Becker

unread,
Sep 3, 2008, 3:41:01 PM9/3/08
to lif...@googlegroups.com
Sorry I didn't get back to you on that. I'm working on an improved version of the tutorial to include a complete example but it's dependent on 0.10-SNAPSHOT right now. As soon as 0.10 goes GA I'll revise the tutorial page.

Derek

Charles F. Munat

unread,
Sep 3, 2008, 4:51:40 PM9/3/08
to lif...@googlegroups.com
Great!

Derek Chen-Becker wrote:
> Sorry I didn't get back to you on that. I'm working on an improved
> version of the tutorial to include a complete example but it's dependent
> on 0.10-SNAPSHOT right now. As soon as 0.10 goes GA I'll revise the
> tutorial page.
>
> Derek
>
> On Tue, Sep 2, 2008 at 8:35 PM, Charles F. Munat <ch...@munat.com
> <mailto:ch...@munat.com>> wrote:
>
>
> I figured it out, I think. Should be author.name

> <http://author.name>, without the parentheses.

Tim Perrett

unread,
Sep 3, 2008, 5:23:34 PM9/3/08
to Lift
@derek Awesome, is that new example using scala in the persistence
module?

Cheers

Tim

Derek Chen-Becker

unread,
Sep 3, 2008, 6:03:58 PM9/3/08
to lif...@googlegroups.com
Yes, 100% pure Scala. It means you have to use orm.xml for some things, but that's pretty easy to deal with.

Derek

Viktor Klang

unread,
Sep 4, 2008, 3:53:55 AM9/4/08
to lif...@googlegroups.com
Chas,

You'll have to give us more than that, i.e. the definition of Author.

Cheers,
Viktor
--
Viktor Klang
Rogue Software Architect

Charles F. Munat

unread,
Sep 4, 2008, 4:18:59 PM9/4/08
to lif...@googlegroups.com
Oh, sorry, Victor. I think I posted a response to my own question almost
immediately after I posted it. I was aiming this question at anyone who
had used the JPA tutorial because I figured that the problem was in the
difference between using POJOs and POSOs (hence, I assumed they would
have not just the Author model, but the entire sample app, available). I
should have tried a few things before posting. As it turned out, using
author.name worked fine.

Thanks for the help.

Chas.

Tim Perrett

unread,
Sep 4, 2008, 11:50:17 PM9/4/08
to Lift
I think Viktor was asking you to post the scala code for the entity;
or alternatively update the wiki page so that its correct

Interestingly, didn't the term POJO come about because it made the
distinct difference between EJB beans and normal classes but as we
don't have EJB etc etc in Scala, arnt they all POSO's as it were?!

Cheers

Tim

Oliver

unread,
Sep 5, 2008, 12:05:19 AM9/5/08
to lif...@googlegroups.com
They aint plain and they aint old, So we have to call them all SO's

Viktor Klang

unread,
Sep 5, 2008, 3:19:27 AM9/5/08
to lif...@googlegroups.com
Sorry Chas,

I think I expressed myself somewhat unfortunate,
what I meant was: "Can you paste in the code for the Author-class"?


Cheers,
Viktor

Charles F. Munat

unread,
Sep 5, 2008, 5:20:31 AM9/5/08
to lif...@googlegroups.com
I think Derek has a new version of the tutorial. I've been communicating
with him about it, and am trying to get his Scala-only version working.
I'll check with him to make sure my suspicions are correct. Then one of
us will update the tutorial.

I was planning to revise the tutorial myself, but since he has a revised
one pretty much ready to go (I think), I'm just trying to help him to
debug it.

Either way, it will be fixed shortly.

Chas.

Viktor Klang wrote:
> Sorry Chas,
>
> I think I expressed myself somewhat unfortunate,
> what I meant was: "Can you paste in the code for the Author-class"?
>
>
> Cheers,
> Viktor
>
> On Thu, Sep 4, 2008 at 10:18 PM, Charles F. Munat <ch...@munat.com
> <mailto:ch...@munat.com>> wrote:
>
>
> Oh, sorry, Victor. I think I posted a response to my own question almost
> immediately after I posted it. I was aiming this question at anyone who
> had used the JPA tutorial because I figured that the problem was in the
> difference between using POJOs and POSOs (hence, I assumed they would
> have not just the Author model, but the entire sample app, available). I
> should have tried a few things before posting. As it turned out, using

> author.name <http://author.name> worked fine.


>
> Thanks for the help.
>
> Chas.
>
> Viktor Klang wrote:
> > Chas,
> >
> > You'll have to give us more than that, i.e. the definition of Author.
> >
> > Cheers,
> > Viktor
> >
> > On Wed, Sep 3, 2008 at 4:29 AM, Charles F. Munat <ch...@munat.com
> <mailto:ch...@munat.com>

Tim Perrett

unread,
Sep 5, 2008, 7:26:30 AM9/5/08
to lif...@googlegroups.com
Chas,

It would be usefull if you just posted the entity code - if it's from
the tutorial, or a varient of that, I don't see why your not giving
others their chance to contribute? Just post up the code... There are
a lot of talented people on this list who I'm sure can a) help improve
the implementation, and b) would be very interested to see scala JPA.

Cheers

Tim

Sent from my iPhone

Derek Chen-Becker

unread,
Sep 5, 2008, 9:01:22 AM9/5/08
to lif...@googlegroups.com
I think Chas didn't post up the code because I had said I wanted to wait to release this until the kinks were worked out, not because he's obstructionist :). I've attached the current form of the tutorial project. The code in question is JPADemo/perscala/src/main/scala/com/jpaweb/foo/model/Author.scala. Chas is helping me work out the kinks and I'm waiting for 0.10 to go GA before we update the actual tutorial page on the wiki to match. Right now it's mostly down to some maven issues, which I'd appreciate any help on:

  1. The webapp module is dependent on the perscala module. As the project is currently layed out, you need to run "mvn install" in the perscala project before you can go into the webapp project and run "mvn jetty:run". I was hoping there would be a way for the webapp module to trigger the "mvn install" when you try to run things (test, jetty:run, etc), but I'm no maven guru
  2. I had some problems with my dependencies that meant you had to manually install some jars. I'm hoping to get it down to completely automatic on the dependency updates.
Cheers

Derek
jpademo.tar.gz

David Pollak

unread,
Sep 5, 2008, 9:41:50 AM9/5/08
to lif...@googlegroups.com
Derek,

Thanks for posting up the code.

In general, I like to keep conversations on-list.  People learn a lot by seeing back and forth communications rather than simply the magic result.  Additionally, there are a number of folks who have different skills and different perspectives and allowing them to be part of the conversation is very important as well... as they will contribute to the over-all result.

To put this in perspective, I have very, very few off-list communications (and they are mainly in the form of IMs related to small, timely decisions) with the other committers about what we commit to Lift.  We intensionally keep our communications visible.

Thanks,

David
--
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

Derek Chen-Becker

unread,
Sep 5, 2008, 11:16:33 AM9/5/08
to lif...@googlegroups.com
I agree with keeping the discussions on-list. I've actually been asking the relevant questions on-list, just not in the thread of the final JPA demo project. I didn't intend to be seen as hiding it, I just didn't want to post up code and a tutorial that were based on a SNAPSHOT version. In hindsight maybe that wasn't appropriate and I apologize if that came off negatively; I really enjoy being part of such a vibrant project/community and I'm hoping this work helps others using JPA get their feet wet with Lift :)

Cheers,

Derek

Charles F. Munat

unread,
Sep 5, 2008, 2:08:58 PM9/5/08
to lif...@googlegroups.com
Currently, when I run mvn test on the perscala subproject, I get this:

mvn test

[17:12]
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Building perscala
[INFO] task-segment: [test]
[INFO]
------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [scala:compile {execution: default}]
[INFO] suggestion: remove the scalaVersion from pom.xml
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [scala:testCompile {execution: default}]
[INFO] suggestion: remove the scalaVersion from pom.xml
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test]
[INFO] Surefire report directory:
/private/var/www/JPADemo/perscala/target/surefire-reports

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.foo.jpaweb.model.TestJPAWeb
Sep 4, 2008 8:22:15 PM org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.3.0.GA
Sep 4, 2008 8:22:15 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.4
Sep 4, 2008 8:22:15 PM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Sep 4, 2008 8:22:15 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
Sep 4, 2008 8:22:15 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Sep 4, 2008 8:22:15 PM org.hibernate.ejb.Version <clinit>
INFO: Hibernate EntityManager 3.3.1.GA
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: com.foo.jpaweb.model.Book
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.QueryBinder bindQuery
INFO: Binding Named query: findBooksByAuthor => from Book b where
b.author.id = :id order by b.title
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.QueryBinder bindQuery
INFO: Binding Named query: findBooksByDate => from Book b where
b.published between :startDate and :endDate
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.QueryBinder bindQuery
INFO: Binding Named query: findBooksByTitle => from Book b where
lower(b.title) like :title order by b.title
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.QueryBinder bindQuery
INFO: Binding Named query: findAllBooks => from Book b order by b.title
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity com.foo.jpaweb.model.Book on table Book
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: com.foo.jpaweb.model.Author
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.QueryBinder bindQuery
INFO: Binding Named query: findAllAuthors => from Author a order by a.name
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity com.foo.jpaweb.model.Author on table Author
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.CollectionBinder
bindOneToManySecondPass
INFO: Mapping collection: com.foo.jpaweb.model.Author.books -> Book
Sep 4, 2008 8:22:16 PM org.hibernate.validator.Version <clinit>
INFO: Hibernate Validator 3.0.0.GA
Sep 4, 2008 8:22:16 PM
org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Sep 4, 2008 8:22:16 PM
org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Sep 4, 2008 8:22:16 PM
org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: true
Sep 4, 2008 8:22:16 PM
org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:file:jpaweb
Sep 4, 2008 8:22:16 PM
org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=sa, password=****, autocommit=true,
release_mode=auto}
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: HSQL Database Engine, version: 1.8.0
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: HSQL Database Engine Driver, version: 1.8.0
Sep 4, 2008 8:22:16 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.HSQLDialect
Sep 4, 2008 8:22:16 PM
org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
Sep 4, 2008 8:22:16 PM
org.hibernate.transaction.TransactionManagerLookupFactory
getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of
read-write or transactional second-level cache is not recommended)
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): disabled
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 3
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL inserts for batching: disabled
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory
createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Sep 4, 2008 8:22:16 PM org.hibernate.hql.ast.ASTQueryTranslatorFactory
<init>
INFO: Using ASTQueryTranslatorFactory
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: enabled
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
Sep 4, 2008 8:22:16 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
Sep 4, 2008 8:22:16 PM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Sep 4, 2008 8:22:17 PM org.hibernate.impl.SessionFactoryObjectFactory
addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Sep 4, 2008 8:22:17 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: Running hbm2ddl schema update
Sep 4, 2008 8:22:17 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: fetching database metadata
Sep 4, 2008 8:22:17 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: updating schema
Sep 4, 2008 8:22:17 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
getTableMetadata
INFO: table not found: Author
Sep 4, 2008 8:22:17 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
getTableMetadata
INFO: table not found: Book
Sep 4, 2008 8:22:17 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
getTableMetadata
INFO: table not found: Author
Sep 4, 2008 8:22:17 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
getTableMetadata
INFO: table not found: Book
Sep 4, 2008 8:22:17 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: schema update complete
Sep 4, 2008 8:22:17 PM org.hibernate.impl.SessionFactoryImpl close
INFO: closing
Sep 4, 2008 8:22:17 PM
org.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:hsqldb:file:jpaweb
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.095
sec <<< FAILURE!

Results :

Tests in error:
save_stuff(com.foo.jpaweb.model.TestJPAWeb)

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

[INFO]
------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] There are test failures.

Please refer to
/private/var/www/JPADemo/perscala/target/surefire-reports for the
individual test results.
[INFO]
------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Thu Sep 04 20:22:17 PDT 2008
[INFO] Final Memory: 9M/17M
[INFO]
------------------------------------------------------------------------


This was after making the following change to perscala/pom.xml suggested
by Derek:

<dependency>
<groupId>javax.persistence</groupId>
<artifactId>ejb</artifactId>
<version>3.0</version>
</dependency>

to

<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0</version>
</dependency>

Here is what is in my perscala/src/main/resources folder. The same jars
are in the webapp/src/main/resources folder.

ejb3-persistence.jar
hibernate-testing.jar*
jta.jar
slf4j-jcl-1.5.2.jar
antlr-2.7.6.jar
hibernate-annotations.jar
hibernate3.jar*
lift_chef.properties
commons-collections-3.1.jar
hibernate-commons-annotations.jar
javassist-3.4.GA.jar
slf4j-api-1.4.2.jar
dom4j-1.6.1.jar
hibernate-core.jar
javassist.jar
slf4j-api-1.5.2.jar
dom4j.jar
hibernate-entitymanager.jar
jta-1.1.jar
slf4j-api.jar

Obviously, I don't need all of these, but I haven't figured out which
ones go where yet.

The remaining code is identical to what Derek just posted.

Any ideas?

Chas.

Derek Chen-Becker wrote:
> I agree with keeping the discussions on-list. I've actually been asking
> the relevant questions on-list, just not in the thread of the final JPA
> demo project. I didn't intend to be seen as hiding it, I just didn't
> want to post up code and a tutorial that were based on a SNAPSHOT
> version. In hindsight maybe that wasn't appropriate and I apologize if
> that came off negatively; I really enjoy being part of such a vibrant
> project/community and I'm hoping this work helps others using JPA get
> their feet wet with Lift :)
>
> Cheers,
>
> Derek
>
> On Fri, Sep 5, 2008 at 7:41 AM, David Pollak

> <feeder.of...@gmail.com <mailto:feeder.of...@gmail.com>>

> 1. The webapp module is dependent on the perscala module. As


> the project is currently layed out, you need to run "mvn
> install" in the perscala project before you can go into
> the webapp project and run "mvn jetty:run". I was hoping
> there would be a way for the webapp module to trigger the
> "mvn install" when you try to run things (test, jetty:run,
> etc), but I'm no maven guru

> 2. I had some problems with my dependencies that meant you


> had to manually install some jars. I'm hoping to get it
> down to completely automatic on the dependency updates.
>
> Cheers
>
> Derek
>
>
> On Fri, Sep 5, 2008 at 5:26 AM, Tim Perrett
> <he...@timperrett.com <mailto:he...@timperrett.com>> wrote:
>
>
> Chas,
>
> It would be usefull if you just posted the entity code - if
> it's from
> the tutorial, or a varient of that, I don't see why your not
> giving
> others their chance to contribute? Just post up the code...
> There are
> a lot of talented people on this list who I'm sure can a)
> help improve
> the implementation, and b) would be very interested to see
> scala JPA.
>
> Cheers
>
> Tim
>
> Sent from my iPhone
>
> On 5 Sep 2008, at 10:20, "Charles F. Munat" <ch...@munat.com

> >> <mailto:ch...@munat.com <mailto:ch...@munat.com>>> wrote:
> >>
> >>
> >> Oh, sorry, Victor. I think I posted a response to my own
> >> question almost
> >> immediately after I posted it. I was aiming this
> question at
> >> anyone who
> >> had used the JPA tutorial because I figured that the
> problem was
> >> in the
> >> difference between using POJOs and POSOs (hence, I
> assumed they
> >> would
> >> have not just the Author model, but the entire sample
> app,
> >> available). I
> >> should have tried a few things before posting. As it
> turned out,
> >> using

> >> author.name <http://author.name> <http://author.name>

Derek Chen-Becker

unread,
Sep 5, 2008, 3:06:59 PM9/5/08
to lif...@googlegroups.com
There shouldn't be any JARs in your src/main/resources folder... Maven is supposed to manage those JARs for you. Maybe that's why things are breaking in weird ways. Here's what my src/main/resources in perscala looks like:

$ tree src/main/resources/
src/main/resources/
`-- META-INF
    |-- orm.xml
    `-- persistence.xml

And for webapp:

$ tree src/main/resources/
src/main/resources/
`-- lift_chef.properties

Did you put those JARs there?

Derek

Charles F. Munat

unread,
Sep 5, 2008, 3:06:59 PM9/5/08
to lif...@googlegroups.com
The code I have for my attempt to follow the JPA tutorial is -- with one
very minor exception -- exactly the code that is in the tutorial. A
couple of days ago, I posted to the list the one question I had, and the
answer I came up with. Sorry if I wasn't clear about this.

The exception was this code, which is directly from the JPA tutorial on
the wiki:

def list (xhtml : NodeSeq) : NodeSeq = {
val authors = Model.em.createQuery("from
Author").getResultList().asInstanceOf[java.util.List[Author]]

authors.flatMap(author =>
bind("auth", xhtml,
"name" --> Text(author.getName()),
"count" --> Text(author.getBooks().size().toString)))
}

This was written for the POJO version of the code. But when I tried
substituting the Scala objects (for Author and Book) later in the
tutorial, this code broke on author.getName(). I am not a Java
programmer, but I assumed that this was a difference between the getters
of Java and Scala. I tried author.name instead and that seemed to work.
I posted the change back to the list.

As for changing the tutorial on the wiki, I would not change another's
work without first asking him. So I contacted Derek with an offer either
to provide a list of changes to his tutorial -- most of them having to
do with clarity for newbies like me -- or to make the changes myself,
and he told me that he had a new one in the bag and was only waiting for
0.10 to post it. I was very happy I had not wasted a lot of time
changing a tutorial which will be shortly obsolete.

He also sent me the completed code for the the new tutorial. I looked at
the code for the new tutorial and the above issue was resolved (and
differently from the way I had done it).

I'm assuming that Derek will make the changes shortly. Maybe he can be
persuaded to do so before 0.10, since it seems that version is still a
ways off and others might want to use the tutorial in the meantime.

As for our conversation off the list, it only involved a couple of
questions from me about how to get his new code to run on my machine,
and would have been difficult to explain without posting all the code.
That, IMO, was Derek's prerogative, not mine. Now he has now posted it I
am more than happy to direct questions to the list.

I hope this clears up any misunderstandings.

Chas.

Charles F. Munat

unread,
Sep 5, 2008, 3:15:37 PM9/5/08
to lif...@googlegroups.com
I added those jars because I was getting errors with things not defined
(this was earlier), so I presumed that maven wasn't finding the right
jars. I understand that maven is supposed to do this, but I was trying
to figure out what maven was missing. If I add a jar and things start
working, then I know which jar maven is not accessing. That was my
thinking anyway.

I removed them all, but still get the exact same error on mvn test.

Chas.

> INFO: Hibernate Annotations 3.3.0.GA <http://3.3.0.GA>


> Sep 4, 2008 8:22:15 PM org.hibernate.cfg.Environment <clinit>
> INFO: Hibernate 3.2.4
> Sep 4, 2008 8:22:15 PM org.hibernate.cfg.Environment <clinit>
> INFO: hibernate.properties not found
> Sep 4, 2008 8:22:15 PM org.hibernate.cfg.Environment
> buildBytecodeProvider
> INFO: Bytecode provider name : cglib
> Sep 4, 2008 8:22:15 PM org.hibernate.cfg.Environment <clinit>
> INFO: using JDK 1.4 java.sql.Timestamp handling
> Sep 4, 2008 8:22:15 PM org.hibernate.ejb.Version <clinit>

> INFO: Hibernate EntityManager 3.3.1.GA <http://3.3.1.GA>


> Sep 4, 2008 8:22:16 PM org.hibernate.cfg.AnnotationBinder bindClass
> INFO: Binding entity from annotated class: com.foo.jpaweb.model.Book
> Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.QueryBinder
> bindQuery
> INFO: Binding Named query: findBooksByAuthor => from Book b where

> b.author.id <http://b.author.id> = :id order by b.title


> Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.QueryBinder
> bindQuery
> INFO: Binding Named query: findBooksByDate => from Book b where
> b.published between :startDate and :endDate
> Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.QueryBinder
> bindQuery
> INFO: Binding Named query: findBooksByTitle => from Book b where
> lower(b.title) like :title order by b.title
> Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.QueryBinder
> bindQuery
> INFO: Binding Named query: findAllBooks => from Book b order by b.title
> Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.EntityBinder
> bindTable
> INFO: Bind entity com.foo.jpaweb.model.Book on table Book
> Sep 4, 2008 8:22:16 PM org.hibernate.cfg.AnnotationBinder bindClass
> INFO: Binding entity from annotated class: com.foo.jpaweb.model.Author
> Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.QueryBinder
> bindQuery
> INFO: Binding Named query: findAllAuthors => from Author a order by

> a.name <http://a.name>


> Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.EntityBinder
> bindTable
> INFO: Bind entity com.foo.jpaweb.model.Author on table Author
> Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.CollectionBinder
> bindOneToManySecondPass
> INFO: Mapping collection: com.foo.jpaweb.model.Author.books -> Book
> Sep 4, 2008 8:22:16 PM org.hibernate.validator.Version <clinit>

> INFO: Hibernate Validator 3.0.0.GA <http://3.0.0.GA>

> <mailto:feeder.of...@gmail.com


> <mailto:feeder.of...@gmail.com>>>
> > wrote:
> >
> > Derek,
> >
> > Thanks for posting up the code.
> >
> > In general, I like to keep conversations on-list. People learn a
> > lot by seeing back and forth communications rather than
> simply the
> > magic result. Additionally, there are a number of folks who have
> > different skills and different perspectives and allowing them
> to be
> > part of the conversation is very important as well... as they
> will
> > contribute to the over-all result.
> >
> > To put this in perspective, I have very, very few off-list
> > communications (and they are mainly in the form of IMs related to
> > small, timely decisions) with the other committers about what we
> > commit to Lift. We intensionally keep our communications
> visible.
> >
> > Thanks,
> >
> > David
> >
> >
> > On Fri, Sep 5, 2008 at 6:01 AM, Derek Chen-Becker
> > <dchen...@gmail.com <mailto:dchen...@gmail.com>

> <mailto:he...@timperrett.com <mailto:he...@timperrett.com>>> wrote:
> >
> >
> > Chas,
> >
> > It would be usefull if you just posted the entity
> code - if
> > it's from
> > the tutorial, or a varient of that, I don't see why
> your not
> > giving
> > others their chance to contribute? Just post up the
> code...
> > There are
> > a lot of talented people on this list who I'm sure can a)
> > help improve
> > the implementation, and b) would be very interested
> to see
> > scala JPA.
> >
> > Cheers
> >
> > Tim
> >
> > Sent from my iPhone
> >
> > On 5 Sep 2008, at 10:20, "Charles F. Munat"
> <ch...@munat.com <mailto:ch...@munat.com>

Derek Chen-Becker

unread,
Sep 5, 2008, 3:21:11 PM9/5/08
to lif...@googlegroups.com
OK, can you send the full error report that it's producing? It should be under perscala/target/surefire-reports/com.foo.jpaweb.model.TestJPAWeb.txt

BTW, has anyone else tried this code?

Derek

Tim Perrett

unread,
Sep 5, 2008, 3:21:42 PM9/5/08
to Lift
Derek, by all means keep working on this stuff, its brilliant, really
it is.

I think there are a lot of people that want JPA / Lift, so its
important that we keep it public as who knows what type of great ideas
people might come up with whilst the discussion evolves!

Kudos again tho, Lift <-> JPA love is awesome

Tim

Derek Chen-Becker

unread,
Sep 5, 2008, 3:27:51 PM9/5/08
to lif...@googlegroups.com
I agree about keeping it public. I have a bad habit of sitting on things when I don't think they're up to snuff but I realize that doing that doesn't really help anyone in this case :)

Derek

Derek Chen-Becker

unread,
Sep 5, 2008, 3:28:31 PM9/5/08
to lif...@googlegroups.com
Well, the only thing it helps is my ego, which I guess is the problem ;)

Charles F. Munat

unread,
Sep 5, 2008, 4:34:19 PM9/5/08
to lif...@googlegroups.com
Sorry, forgot about that. Here it is:

-------------------------------------------------------------------------------
Test set: com.foo.jpaweb.model.TestJPAWeb
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.577
sec <<< FAILURE!
save_stuff(com.foo.jpaweb.model.TestJPAWeb) Time elapsed: 2.531 sec
<<< ERROR!
java.lang.NoClassDefFoundError: javax/transaction/SystemException
at
org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:37)
at
org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:32)
at com.foo.jpaweb.model.TestJPAWeb.save_stuff(Test.scala:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at
org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at
org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
at
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)

Chas.

> > b.author.id <http://b.author.id> <http://b.author.id> = :id


> order by b.title
> > Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.QueryBinder
> > bindQuery
> > INFO: Binding Named query: findBooksByDate => from Book b where
> > b.published between :startDate and :endDate
> > Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.QueryBinder
> > bindQuery
> > INFO: Binding Named query: findBooksByTitle => from Book b where
> > lower(b.title) like :title order by b.title
> > Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.QueryBinder
> > bindQuery
> > INFO: Binding Named query: findAllBooks => from Book b order
> by b.title
> > Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.EntityBinder
> > bindTable
> > INFO: Bind entity com.foo.jpaweb.model.Book on table Book
> > Sep 4, 2008 8:22:16 PM org.hibernate.cfg.AnnotationBinder
> bindClass
> > INFO: Binding entity from annotated class:
> com.foo.jpaweb.model.Author
> > Sep 4, 2008 8:22:16 PM org.hibernate.cfg.annotations.QueryBinder
> > bindQuery
> > INFO: Binding Named query: findAllAuthors => from Author a
> order by

> > a.name <http://a.name> <http://a.name>

David Pollak

unread,
Sep 5, 2008, 5:00:32 PM9/5/08
to lif...@googlegroups.com


Derek Chen-Becker wrote:
Well, the only thing it helps is my ego, which I guess is the problem ;)
If you need ego help... you're doing a frickin' amazing job of helping out the Lift community and you're clearly the wicked smart and caring kind of person that enhances the Lift community.

Derek Chen-Becker

unread,
Sep 5, 2008, 5:13:32 PM9/5/08
to lif...@googlegroups.com
OK, to test this out, I completely erased my local maven repository. I then did a "mvn clean" on the top-level jpademo project, then went into the perscala module and ran a "mvn test" there. That fails on finding the JTA jar:

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) javax.transaction:jta:jar:1.0.1B

  Try downloading the file manually from:
      http://java.sun.com/products/jta

  Then, install it using the command:
      mvn install:install-file -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B -Dpackaging=jar -Dfile=/path/to/file


So I went to the website listed, downloaded the zip file there, converted the zip file into a jar (unzip jta-1_0_1B-classes.zip && jar cvf jta.jar javax/ && rm -rf javax jta*.zip), then import the jta.jar file into my local repository:

mvn install:install-file -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B -Dpackaging=jar -Dfile=jta.jar

After I do that I can rerun "mvn test" and it builds fine. I have a feeling that the JTA jar file in your local repository is somehow corrupt. You might try doing the import steps I've listed above to see if that will replace it. I can't remember if that will force overwrite it, so you might have to manually remove the jar from your local repo (standard is under ~/.m2/repository).

Derek

Keith Short

unread,
Sep 5, 2008, 5:33:21 PM9/5/08
to lif...@googlegroups.com
I saw exactly the same javax.transaction.jta exception when trying to do the same thing. My maven installation was clean since I'm just getting started with maven and had just downloaded it (on OS X).

Keith

Derek Chen-Becker

unread,
Sep 5, 2008, 5:46:14 PM9/5/08
to lif...@googlegroups.com
Am I the only one that this works for? I don't think I have anything special in my environment:

$ mvn -v
Maven version: 2.0.8
Java version: 1.6.0_07
OS name: "linux" version: "2.6.24-19-generic" arch: "amd64" Family: "unix"

I checked my JTA jar in my maven repo and it shows the proper class:

$ jar tvf /home/software/mavenrepo/javax/transaction/jta/1.0.1B/jta-1.0.1B.jar | grep SystemException
   408 Thu Oct 31 15:21:24 MST 2002 javax/transaction/SystemException.class

Can you both confirm that you have the proper JTA jar file in your repository and that it contains the SystemException class? This is getting bizarre...

Derek

Charles F. Munat

unread,
Sep 5, 2008, 6:01:05 PM9/5/08
to lif...@googlegroups.com
OK, did that, and mvn test ran successfully. So then I went to the
webapp directory and ran mvn jetty:run -U and got the following:

mvn jetty:run -U

[14:57]
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'jetty'.
[INFO] org.apache.maven.plugins: checking for updates from scala-tools.org
[INFO] org.apache.maven.plugins: checking for updates from central
[INFO] org.codehaus.mojo: checking for updates from scala-tools.org
[INFO] org.codehaus.mojo: checking for updates from central
[INFO] artifact org.scala-tools:maven-scala-plugin: checking for updates
from scala-tools.org
[INFO] artifact org.scala-tools:maven-scala-plugin: checking for updates
from central
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking
for updates from scala-tools.org
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking
for updates from central
[INFO] artifact org.mortbay.jetty:maven-jetty-plugin: checking for
updates from scala-tools.org
[INFO] artifact org.mortbay.jetty:maven-jetty-plugin: checking for
updates from central
[INFO] artifact net.sf.alchim:yuicompressor-maven-plugin: checking for
updates from scala-tools.org
[INFO] artifact net.sf.alchim:yuicompressor-maven-plugin: checking for
updates from central
[INFO]
------------------------------------------------------------------------
[INFO] Building webapp
[INFO] task-segment: [jetty:run]
[INFO]
------------------------------------------------------------------------
[INFO] Preparing jetty:run


[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.

Downloading:
http://scala-tools.org/repo-releases/rhino/js/1.6R7/js-1.6R7.pom
Downloading:
http://wicketstuff.org/maven/repository//rhino/js/1.6R7/js-1.6R7.pom
Downloading: http://repo1.maven.org/maven2/rhino/js/1.6R7/js-1.6R7.pom
786b downloaded
Downloading:
http://scala-tools.org/repo-releases/net/sf/retrotranslator/retrotranslator-runtime/1.2.1/retrotranslator-runtime-1.2.1.pom
Downloading:
http://wicketstuff.org/maven/repository//net/sf/retrotranslator/retrotranslator-runtime/1.2.1/retrotranslator-runtime-1.2.1.pom
Downloading:
http://repo1.maven.org/maven2/net/sf/retrotranslator/retrotranslator-runtime/1.2.1/retrotranslator-runtime-1.2.1.pom
1K downloaded
Downloading:
http://scala-tools.org/repo-releases/backport-util-concurrent/backport-util-concurrent/3.0/backport-util-concurrent-3.0.pom
Downloading:
http://wicketstuff.org/maven/repository//backport-util-concurrent/backport-util-concurrent/3.0/backport-util-concurrent-3.0.pom
Downloading:
http://repo1.maven.org/maven2/backport-util-concurrent/backport-util-concurrent/3.0/backport-util-concurrent-3.0.pom
909b downloaded
Downloading:
http://scala-tools.org/repo-releases/rhino/js/1.6R7/js-1.6R7.jar
Downloading:
http://wicketstuff.org/maven/repository//rhino/js/1.6R7/js-1.6R7.jar
Downloading: http://repo1.maven.org/maven2/rhino/js/1.6R7/js-1.6R7.jar
794K downloaded
Downloading:
http://scala-tools.org/repo-releases/net/sf/retrotranslator/retrotranslator-runtime/1.2.1/retrotranslator-runtime-1.2.1.jar
Downloading:
http://wicketstuff.org/maven/repository//net/sf/retrotranslator/retrotranslator-runtime/1.2.1/retrotranslator-runtime-1.2.1.jar
Downloading:
http://repo1.maven.org/maven2/net/sf/retrotranslator/retrotranslator-runtime/1.2.1/retrotranslator-runtime-1.2.1.jar
245K downloaded
Downloading:
http://scala-tools.org/repo-releases/backport-util-concurrent/backport-util-concurrent/3.0/backport-util-concurrent-3.0.jar
Downloading:
http://wicketstuff.org/maven/repository//backport-util-concurrent/backport-util-concurrent/3.0/backport-util-concurrent-3.0.jar
Downloading:
http://scala-tools.org/repo-releases/backport-util-concurrent/backport-util-concurrent/3.0/backport-util-concurrent-3.0.jar
Downloading:
http://repo1.maven.org/maven2/backport-util-concurrent/backport-util-concurrent/3.0/backport-util-concurrent-3.0.jar
320K downloaded
[INFO] [yuicompressor:compress {execution: default}]
[INFO] datePicker.css (2283b) -> datePicker.css (1658b)[72%]
[WARNING] .../src/main/webapp/scripts/date.js:line -1:column -1:Try to
use a single 'var' statement per scope.
){var f=Date.format; ---> var <--- d=new Date("01/01/1977");var iY
[WARNING] .../src/main/webapp/scripts/date.js:line -1:column -1:Try to
use a single 'var' statement per scope.
var d=new Date("01/01/1977"); ---> var <--- iY=f.indexOf("yyyy");if
[WARNING] .../src/main/webapp/scripts/date.js:line -1:column -1:Try to
use a single 'var' statement per scope.
"yy"),2)));} ---> var <--- iM=f.indexOf("mmm");if
[WARNING] .../src/main/webapp/scripts/date.js:line -1:column -1:Try to
use a single 'var' statement per scope.
;if(iM>-1){ ---> var <--- mStr=s.substr(iM,3)
[WARNING] .../src/main/webapp/scripts/date.js:line -1:column -1:Try to
use a single 'var' statement per scope.
substr(iM,3);for( ---> var <--- i=0;i<Date.abbrMonthNames.
[INFO] date.js (11520b) -> date.js (2888b)[25%]
[INFO] jquery.bgiframe.js (4825b) -> jquery.bgiframe.js (1028b)[21%]
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
showHeader!=$.dpConst.SHOW_HEADER_NONE){ ---> var <--- headRow=$(dc("tr"));
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
(dc("tr"));for( ---> var <--- i=Date.firstDayOfWeek;i<Date.
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
.firstDayOfWeek+7;i++){ ---> var <--- weekday=i%7;var day=Date
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
){var weekday=i%7; ---> var <--- day=Date.dayNames[weekday];headRow
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
1):day));}} ---> var <--- calendarTable=$(dc("table")).
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
):dc("thead"))); ---> var <--- tbody=$(dc("tbody"));
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
=$(dc("tbody")); ---> var <--- today=(new Date()).zeroTime
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
Date()).zeroTime(); ---> var <--- month=s.month==undefined?today.
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
.getMonth():s.month; ---> var <--- year=s.year||today.getFullYear(
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
.year||today.getFullYear(); ---> var <--- currentDate=new Date(year,month,1
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
Date(year,month,1); ---> var <---
firstDayOffset=Date.firstDayOfWeek-currentDate.getDay(
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
>1){firstDayOffset-=7;} ---> var <--- weeksToDraw=Math.ceil(((-1
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
currentDate.addDays(firstDayOffset-1); ---> var <--- doHover=function
(){if(s.
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
(s.hoverClass);}}; ---> var <--- unHover=function (){if(s.
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
(s.hoverClass);}}; ---> var <--- w=0;while(w++<weeksToDraw
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
;while(w++<weeksToDraw){ ---> var <--- r=jQuery(dc("tr"));
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
(dc("tr"));for( ---> var <--- i=0;i<7;i++
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:The variable i has already been declared in the same scope...
dc("tr"));for(var ---> i <--- =0;i<7;i++)
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
;i<7;i++){ ---> var <--- thisMonth=currentDate.getMonth()==month;
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
=currentDate.getMonth()==month; ---> var <--- d=$(dc("td")).
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
{var $this=$(this); ---> var <--- alreadyExists=true;if(!this._dpId
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
false;$this.empty();} ---> var <--- controller=$.event._dpCache[this.
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
.dpDisplay();});} ---> var <--- d=Date.fromString(this.value)
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
);s.setDate(1); ---> var <--- e=new Date(this.endDate.getTime
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
);e.setDate(1); ---> var <--- t;if((!m&&!y
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
this.ele;var c=this; ---> var <--- $ele=$(eleAlignTo);var eleOffset=
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
;var $ele=$(eleAlignTo); ---> var <--- eleOffset=$ele.offset();var
$createIn
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
var eleOffset=$ele.offset(); ---> var <--- $createIn;var attrs;var
attrsCalendarHolder;var cssRules
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
$ele.offset();var $createIn; ---> var <--- attrs;var
attrsCalendarHolder;var cssRules;if(
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
();var $createIn;var attrs; ---> var <--- attrsCalendarHolder;var
cssRules;if(c.inline
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
var $createIn;var attrs;var attrsCalendarHolder; ---> var <---
cssRules;if(c.inline){$createIn
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
eleOffset.left+c.horizontalOffset}; ---> var <--- _checkMouse=function
(e){var el=
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
){var el=e.target; ---> var <--- cal=$("#dp-popup")[0];
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
"dp-calendar")).bgIframe()); ---> var <--- $pop=this.inline?$(".dp-popup",
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
){var c=this.dpController; ---> var <--- d=new Date(thisDate.getTime()
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
".selected")||!c.selectMultiple); ---> var <--- s=c.isSelected(d);$
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
.addClass("selected");}for( ---> var <--- i=0;i<c.renderCallback.
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
.context).removeClass("disabled"); ---> var <---
d=this.startDate.getDate();
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:The variable d has already been declared in the same scope...
context).removeClass("disabled");var ---> d <---
=this.startDate.getDate();if
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
);if(d>20){ ---> var <--- sd=new Date(this.startDate.getTime
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
addClass("disabled");}}); ---> var <--- d=this.endDate.getDate();
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:The variable d has already been declared in the same scope...
("disabled");}});var ---> d <--- =this.endDate.getDate();$
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
.context).removeClass("disabled"); ---> var <--- d=this.endDate.getDate();
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:The variable d has already been declared in the same scope...
context).removeClass("disabled");var ---> d <--- =this.endDate.getDate();if
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
);if(d<13){ ---> var <--- ed=new Date(this.endDate.getTime
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Try to use a single 'var' statement per scope.
event._dpCache||[];for( ---> var <--- i in els){$(els[i
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Found an undeclared symbol: $e
},setDisabled:function (s){ ---> $e <--- =$(this.ele);$e[
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:Found an undeclared symbol: s
{var r=[];for( ---> s <--- in this.selectedDates){if(this.
[WARNING] .../src/main/webapp/scripts/jquery.datePicker.js:line
-1:column -1:The symbol attrsCalendarHolder is declared but is
apparently never used.
This code can probably be written in a more compact way.
);var $createIn;var attrs;var ---> attrsCalendarHolder <--- ;var
cssRules;if(c.inline)
[INFO] jquery.datePicker.js (37645b) -> jquery.datePicker.js (13021b)[34%]
[INFO] total input (56273b) -> output (18595b)[33%]
[INFO] nb warnings: 54, nb errors: 0
[INFO] snapshot net.liftweb:lift-webkit:0.10-SNAPSHOT: checking for
updates from scala-tools.org
Downloading:
http://scala-tools.org/repo-releases/net/liftweb/lift-webkit/0.10-SNAPSHOT/lift-webkit-0.10-SNAPSHOT.pom
Downloading:
http://scala-tools.org/repo-releases/javax/servlet/servlet-api/2.5/servlet-api-2.5.pom
Downloading:
http://repo1.maven.org/maven2/javax/servlet/servlet-api/2.5/servlet-api-2.5.pom
157b downloaded
[INFO] artifact org.mortbay.jetty:jetty: checking for updates from
scala-tools.org
[INFO] artifact org.mortbay.jetty:jetty: checking for updates from central
Downloading:
http://scala-tools.org/repo-releases/org/mortbay/jetty/jetty/6.1.11/jetty-6.1.11.pom
Downloading:
http://repo1.maven.org/maven2/org/mortbay/jetty/jetty/6.1.11/jetty-6.1.11.pom
4K downloaded
Downloading:
http://scala-tools.org/repo-releases/org/mortbay/jetty/project/6.1.11/project-6.1.11.pom
Downloading:
http://repo1.maven.org/maven2/org/mortbay/jetty/project/6.1.11/project-6.1.11.pom
12K downloaded
Downloading:
http://scala-tools.org/repo-releases/org/mortbay/jetty/jetty-util/6.1.11/jetty-util-6.1.11.pom
Downloading:
http://repo1.maven.org/maven2/org/mortbay/jetty/jetty-util/6.1.11/jetty-util-6.1.11.pom
3K downloaded
Downloading:
http://scala-tools.org/repo-releases/org/mortbay/jetty/servlet-api-2.5/6.1.11/servlet-api-2.5-6.1.11.pom
Downloading:
http://repo1.maven.org/maven2/org/mortbay/jetty/servlet-api-2.5/6.1.11/servlet-api-2.5-6.1.11.pom
3K downloaded
[INFO] snapshot com.foo.jpaweb:perscala:1.0-SNAPSHOT: checking for
updates from scala-tools.org
Downloading:
http://scala-tools.org/repo-releases/com/foo/jpaweb/perscala/1.0-SNAPSHOT/perscala-1.0-SNAPSHOT.pom
Downloading:
http://scala-tools.org/repo-releases/net/liftweb/lift-webkit/0.10-SNAPSHOT/lift-webkit-0.10-SNAPSHOT.jar
Downloading:
http://scala-tools.org/repo-releases/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar
Downloading:
http://repo1.maven.org/maven2/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar
102K downloaded
Downloading:
http://scala-tools.org/repo-releases/com/foo/jpaweb/perscala/1.0-SNAPSHOT/perscala-1.0-SNAPSHOT.jar


[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) net.liftweb:lift-webkit:jar:0.10-SNAPSHOT

Try downloading the file manually from the project website.

Then, install it using the command:

mvn install:install-file -DgroupId=net.liftweb
-DartifactId=lift-webkit -Dversion=0.10-SNAPSHOT -Dpackaging=jar
-Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the
file there:
mvn deploy:deploy-file -DgroupId=net.liftweb
-DartifactId=lift-webkit -Dversion=0.10-SNAPSHOT -Dpackaging=jar
-Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

Path to dependency:
1) com.foo.jpaweb:webapp:war:1.0-SNAPSHOT
2) net.liftweb:lift-webkit:jar:0.10-SNAPSHOT

2) com.foo.jpaweb:perscala:jar:1.0-SNAPSHOT

Try downloading the file manually from the project website.

Then, install it using the command:

mvn install:install-file -DgroupId=com.foo.jpaweb
-DartifactId=perscala -Dversion=1.0-SNAPSHOT -Dpackaging=jar
-Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the
file there:
mvn deploy:deploy-file -DgroupId=com.foo.jpaweb
-DartifactId=perscala -Dversion=1.0-SNAPSHOT -Dpackaging=jar
-Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

Path to dependency:
1) com.foo.jpaweb:webapp:war:1.0-SNAPSHOT
2) com.foo.jpaweb:perscala:jar:1.0-SNAPSHOT

----------
2 required artifacts are missing.

for artifact:
com.foo.jpaweb:webapp:war:1.0-SNAPSHOT

from the specified remote repositories:
central (http://repo1.maven.org/maven2),
scala-tools.org (http://scala-tools.org/repo-releases)


[INFO]
------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO]
------------------------------------------------------------------------

[INFO] Total time: 22 seconds
[INFO] Finished at: Fri Sep 05 14:58:27 PDT 2008
[INFO] Final Memory: 16M/30M
[INFO]
------------------------------------------------------------------------

Am I missing something?

Chas.

Derek Chen-Becker wrote:
> OK, to test this out, I completely erased my local maven repository. I
> then did a "mvn clean" on the top-level jpademo project, then went into
> the perscala module and ran a "mvn test" there. That fails on finding
> the JTA jar:
>
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Failed to resolve artifact.
>
> Missing:
> ----------
> 1) javax.transaction:jta:jar:1.0.1B
>
> Try downloading the file manually from:
> http://java.sun.com/products/jta
>
> Then, install it using the command:
> mvn install:install-file -DgroupId=javax.transaction
> -DartifactId=jta -Dversion=1.0.1B -Dpackaging=jar -Dfile=/path/to/file
>
>
> So I went to the website listed, downloaded the zip file there,
> converted the zip file into a jar (unzip jta-1_0_1B-classes.zip

> <http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jta-1_0_1B-classes.zip?BundledLineItemUUID=YpNIBe.nyXsAAAEcRh8QHDRP&OrderID=KDhIBe.naNoAAAEcNx8QHDRP&ProductID=fIDACUFB4D0AAAEYXtA5AXiq&FileName=/jta-1_0_1B-classes.zip>

> > > a.name <http://a.name> <http://a.name> <http://a.name>

Derek Chen-Becker

unread,
Sep 5, 2008, 6:07:42 PM9/5/08
to lif...@googlegroups.com
On Fri, Sep 5, 2008 at 4:01 PM, Charles F. Munat <ch...@munat.com> wrote:

OK, did that, and mvn test ran successfully.

Phew! I was really confused as to how that could have gone wrong.

 

Am I missing something?


Yes. The first missing dependency is the perscala project. I forgot that step. You need to run "mvn install" from the perscala module to install the persistence jar. Any maven gurus out there with a suggestion on how to get this done automatically would be appreciated. The second dependency is on the SNAPSHOT version of liftweb. I don't know if it's published in the repos, so you might need to check out a copy of the SNAPSHOT version from Git and then install that into your repo by doing a "mvn install" there. This is part of the reason that I was holding back; another is that if the API changes it breaks the code, but neither of these is a huge deal.

Derek

Charles F. Munat

unread,
Sep 5, 2008, 6:11:49 PM9/5/08
to lif...@googlegroups.com
Whoops. I forgot to run mvn install in the perscala subproject. I did
that and it eliminated the second error below. So now what seems to be
missing is net.liftweb:lift-webkit:jar:0.10-SNAPSHOT

mvn -v
Maven version: 2.0.9
Java version: 1.5.0_13
OS name: "mac os x" version: "10.5.4" arch: "i386" Family: "unix"

I confirmed that the jar exists and contains SystemException:

408 Thu Oct 31 14:21:24 PST 2002 javax/transaction/SystemException.class

???

Chas.

Jorge Ortiz

unread,
Sep 5, 2008, 6:23:42 PM9/5/08
to lif...@googlegroups.com
Make sure you're project's pom.xml has scala-tools.org's
repo-snapshots as well repo-releases

--j

Charles F. Munat

unread,
Sep 5, 2008, 6:50:09 PM9/5/08
to lif...@googlegroups.com
Hot damn. I installed Lift using mvn install on my local copy, and went
back to the webapp and ran mvn jetty:run -U and IT RUNS. I now have
"Welcome to the super duper catalog!" at localhost:9090.

THANK YOU VERY MUCH, DEREK.

Now, any ideas on how to switch it from HSQLDB to PostgreSQL?

I presume that I should change:

perscala/pom.xml:

<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.7</version>
</dependency>

to

<dependency>
<groupId>org.postgresql.Driver</groupId>
<artifactId>postgres</artifactId>
<version>8.3</version>
</dependency>

And change webapp/pom.xml:

<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.2.2.0</version>
</dependency>

to

<dependency>
<groupId> org.postgresql.Driver</groupId>
<artifactId>postgres</artifactId>
<version>8.3</version>
</dependency>

Or do I even need this, as the Derby code is commented out and all
access to the DB will be through perscala?

And change perscala/resources/META-INF/persistence.xml:

<property name="hibernate.dialect"
value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.connection.driver_class"
value="org.hsqldb.jdbcDriver"/>

to

<property name="hibernate.dialect"
value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.connection.driver_class"
value="org.postgresql.jdbcDriver"/>

I'm not quite sure what to do about the jpaweb.properties file:

#HSQL Database Engine 1.8.0.5
#Fri Sep 05 15:02:33 PDT 2008
hsqldb.script_format=0
runtime.gc_interval=0
sql.enforce_strict_size=false
hsqldb.cache_size_scale=8
readonly=false
hsqldb.nio_data_file=true
hsqldb.cache_scale=14
version=1.8.0
hsqldb.default_table_type=memory
hsqldb.cache_file_scale=1
hsqldb.log_size=200
modified=yes
hsqldb.cache_version=1.7.0
hsqldb.original_version=1.8.0
hsqldb.compatible_version=1.8.0

Do I need this?

Chas.

Charles F. Munat

unread,
Sep 5, 2008, 6:56:15 PM9/5/08
to lif...@googlegroups.com
Also not sure what to do with this line in persistence.xml to convert to
PostgreSQL:

<property name="hibernate.connection.url"
value="jdbc:hsqldb:file:jpaweb"/>

Charles F. Munat

unread,
Sep 5, 2008, 7:08:59 PM9/5/08
to lif...@googlegroups.com
Thanks, Jorge. It would be much easier for me if you posted the actual
xml from pom.xml for these dependencies. I am still working on getting
dressed by myself in the mornings.

Chas.

Charles F. Munat

unread,
Sep 5, 2008, 7:17:31 PM9/5/08
to lif...@googlegroups.com
Answering my own posts...

Switching to PostgreSQL was quite simple:

1. in perscala/pom.xml, replace this:

<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.7</version>
</dependency>

with this:

<dependency>
<groupId>org.postgresql.Driver</groupId>
<artifactId>postgres</artifactId>
<version>8.3</version>
</dependency>

No need to change anything in webapp/pom.xml.

Change perscala/resources/META-INF/persistence.xml from this:

<persistence>
<persistence-unit name="jpaweb" transaction-type="RESOURCE_LOCAL">
<properties>


<property name="hibernate.dialect"
value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.connection.driver_class"
value="org.hsqldb.jdbcDriver"/>

<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>


<property name="hibernate.connection.url"
value="jdbc:hsqldb:file:jpaweb"/>

<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>


to this:

<persistence>
<persistence-unit name="jpaweb" transaction-type="RESOURCE_LOCAL">
<properties>


<property name="hibernate.dialect"
value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.connection.driver_class"

value="org.postgresql.Driver"/>
<property name="hibernate.connection.username" value="[psql user]"/>
<property name="hibernate.connection.password" value="[psql
password]"/>
<property name="hibernate.connection.url"
value="jdbc:postgresql://localhost/jpaweb"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>

You'll need to replace [psql user] and [psql password] in the above code
with the appropriate username and password respectively for your
PostgreSQL installation.

Create a new database in PostgreSQL called jpaweb (UTF-8). Then cd to
the perscala directory and run mvn install to add the changes. Go back
to the webapp directory and run mvn jetty:run -U. Then check your
PostgreSQL server and you should find that the book and author tables
have appeared in your jpaweb database.

Cool. This is the most progress I've made (and the fastest) since I
started looking at Lift months ago. Thanks again Derek. I owe you at
least a beer.

Chas.

Jorge Ortiz

unread,
Sep 5, 2008, 7:35:36 PM9/5/08
to lif...@googlegroups.com
Your pom.xml will have something like:

<repositories>
<repository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</repository>
</repositories>

Make sure it also has repo-snapshots, like so:

<repositories>
<repository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</repository>
<repository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-snapshots</url>
</repository>
</repositories>

--j

Derek Chen-Becker

unread,
Sep 5, 2008, 7:54:33 PM9/5/08
to lif...@googlegroups.com
Thanks for the tip, Jorge. I'll put those in the pom for now, although since I'm intending to release this with 0.10 GA, I'll remove it (and the SNAPSHOT) dependency then.

Derek

Derek Chen-Becker

unread,
Sep 5, 2008, 7:57:16 PM9/5/08
to lif...@googlegroups.com
Rock on! Glad to hear it's working for you now :). In the persistence.xml the line

<property name="hibernate.hbm2ddl.auto" value="update" />

Is what should make automatically populate the DB with tables, etc. As an added bonus, if you change the def of an object, it should update the tables, although I caution against doing this in a production environment with real data. For production I usually copy the schema from my dev version and remove that line so I don't get nasty surprises. Also, for production you can set the value of


<property name="hibernate.show_sql" value="true" />

to false to turn off the debug SQL printing (unless you really want it).

Derek

Charles F. Munat

unread,
Sep 5, 2008, 8:16:24 PM9/5/08
to lif...@googlegroups.com
Very cool. It worked, too.

Derek Chen-Becker wrote:
> Rock on! Glad to hear it's working for you now :). In the
> persistence.xml the line
>
> <property name="hibernate.hbm2ddl.auto" value="update" />
>
> Is what should make automatically populate the DB with tables, etc. As
> an added bonus, if you change the def of an object, it should update the
> tables, although I caution against doing this in a production
> environment with real data. For production I usually copy the schema
> from my dev version and remove that line so I don't get nasty surprises.
> Also, for production you can set the value of
>
> <property name="hibernate.show_sql" value="true" />
>
> to false to turn off the debug SQL printing (unless you really want it).
>
> Derek
>
> On Fri, Sep 5, 2008 at 5:17 PM, Charles F. Munat <ch...@munat.com
> <mailto:ch...@munat.com>> wrote:
>
>
> Answering my own posts...
>
> Switching to PostgreSQL was quite simple:
>
> 1. in perscala/pom.xml, replace this:
>
> <dependency>
> <groupId>hsqldb</groupId>
> <artifactId>hsqldb</artifactId>

> <version>1.8.0.7 <http://1.8.0.7></version>

> > <version>1.8.0.7 <http://1.8.0.7></version>


> > </dependency>
> >
> > to
> >
> > <dependency>
> > <groupId>org.postgresql.Driver</groupId>
> > <artifactId>postgres</artifactId>
> > <version>8.3</version>
> > </dependency>
> >
> > And change webapp/pom.xml:
> >
> > <dependency>
> > <groupId>org.apache.derby</groupId>
> > <artifactId>derby</artifactId>

> > <version>10.2.2.0 <http://10.2.2.0></version>


> > </dependency>
> >
> > to
> >
> > <dependency>
> > <groupId> org.postgresql.Driver</groupId>
> > <artifactId>postgres</artifactId>
> > <version>8.3</version>
> > </dependency>
> >
> > Or do I even need this, as the Derby code is commented out and all
> > access to the DB will be through perscala?
> >
> > And change perscala/resources/META-INF/persistence.xml:
> >
> > <property name="hibernate.dialect"
> > value="org.hibernate.dialect.HSQLDialect"/>
> > <property name="hibernate.connection.driver_class"
> > value="org.hsqldb.jdbcDriver"/>
> >
> > to
> >
> > <property name="hibernate.dialect"
> > value="org.hibernate.dialect.PostgreSQLDialect"/>
> > <property name="hibernate.connection.driver_class"
> > value="org.postgresql.jdbcDriver"/>
> >
> > I'm not quite sure what to do about the jpaweb.properties file:
> >

> > #HSQL Database Engine 1.8.0.5 <http://1.8.0.5>


> > #Fri Sep 05 15:02:33 PDT 2008
> > hsqldb.script_format=0
> > runtime.gc_interval=0
> > sql.enforce_strict_size=false
> > hsqldb.cache_size_scale=8
> > readonly=false
> > hsqldb.nio_data_file=true
> > hsqldb.cache_scale=14
> > version=1.8.0
> > hsqldb.default_table_type=memory
> > hsqldb.cache_file_scale=1
> > hsqldb.log_size=200
> > modified=yes
> > hsqldb.cache_version=1.7.0
> > hsqldb.original_version=1.8.0
> > hsqldb.compatible_version=1.8.0
> >
> > Do I need this?
> >
> > Chas.
> >
> > Derek Chen-Becker wrote:
> >>
> >> On Fri, Sep 5, 2008 at 4:01 PM, Charles F. Munat <ch...@munat.com
> <mailto:ch...@munat.com>

Oliver Lambert

unread,
Sep 6, 2008, 1:17:32 AM9/6/08
to lif...@googlegroups.com
Very cool demo Derek. May I make a small suggestion to consider renaming the modules to something like

JPADemo (main project)
JPADemo-spa (scala jpa)
JPADemo-web (web proj)

Or something like this with a common naming prefix. This will group the modules together in the IDEs I use - I have lots of projects and modules and like to keep them as organized as possible

Oliver

Derek Chen-Becker

unread,
Sep 6, 2008, 8:42:08 AM9/6/08
to lif...@googlegroups.com
Sure, that sounds like a very reasonable proposal.

Derek

...

[Message clipped]  

Oliver Lambert

unread,
Sep 6, 2008, 3:45:54 AM9/6/08
to Oliver Lambert, lif...@googlegroups.com
Hi Derek and JPAers
I don't want to appear rude by suggesting a modification to this demo - I'm only trying to help.

I would like the Model object to be split into two objects, Model (for your example) and JPA (that wraps an entity manager).
The advantage would be that implicits are used less often, different persistence objects can easily be created and the querying is simpler and doesn't require an asInstanceOf cast
Anyway, the Model object, JPA object and an example AuthorTest are included below

cheers
Oliver


//Model object extends JPA so jpaweb can be injected
// start -------------Model
package com.foo.jpaweb.model
object Model extends JPA.ScalaEntityManager("jpaweb") {}
// end -------------Model

//JPA object wraps an entity manager and Query object allowing some cleanup for Scala
// start -------------JPA
package com.foo.jpaweb.model

import javax.persistence._
import scala.collection.jcl.{BufferWrapper,SetWrapper}
import net.liftweb.http.RequestVar
import net.liftweb.util.{Can,Full}

object JPA {
  
  implicit def wrapSet[A](set : java.util.Set[A]) = new SetWrapper[A]{override def underlying = set}
  implicit def wrapList[A](list : java.util.List[A]) = new BufferWrapper[A]{override def underlying = list}

  abstract class ScalaEntityManager(val persistanceName: String) {

    lazy val factory = Persistence.createEntityManagerFactory(persistanceName)
    
    private def openEM () = {
      val em = factory.createEntityManager()
      em.getTransaction().begin()
      em
    }

    private def closeEM (em : EntityManager) = {
      if (em.getTransaction().getRollbackOnly()) {
        em.getTransaction().rollback()
      } else {
        em.getTransaction().commit()
       }

       em.close()
     }

  object emVar extends RequestVar(openEM()) {
       override def cleanupFunc : Can[() => Unit]= Full(() => closeEM(this.is))
     }

    def em = emVar.is
 
    def getTransaction = em.getTransaction
  
   def createQuery[A](queryString: String) = new ScalaQuery[A](em.createQuery(queryString))
    
   def createNamedQuery[A](queryName: String) = new ScalaQuery[A](em.createNamedQuery(queryName))
    
     def find[A](clazz: Class[A], id: Int) = em.find[A](clazz, id)
     def find[A](clazz: Class[A], id: Long) = em.find[A](clazz, id)
    def find[A](clazz: Class[A], id: String) = em.find[A](clazz, id)
    
   }

   class ScalaQuery[A](val query: Query) {

    def getResultList() = findAll
     def findAll = wrapList[A](query.getResultList.asInstanceOf[java.util.List[A]])
    
    def getSingleResult() = findOne
     def findOne = wrapList[A](query.getSingleResult.asInstanceOf[java.util.List[A]])
   }

}
// end -------------JPA

//If this is done then querying becomes more natural eg - 
// start -------------Test
import javax.persistence.{EntityManager,Persistence}
import scala.collection.jcl.{BufferWrapper,SetWrapper}
import junit.framework._;
import Assert._;
import com.foo.jpaweb.model.JPA._
import com.foo.jpaweb.model.{Author, Book, Model}

class AuthorTest extends TestCase {
  
   def testOK = {
    println("AuthorTest")
    
    val authors = Model.createNamedQuery[Author]("findAllAuthors").getResultList()
   // or maybe better - val authors = Model.createNamedQuery[Author]("findAllAuthors").findAll
    
    authors.foreach(author => {
        println("------------"+author+"------------")
        author.books.foreach(println(_))
      })
  }

}
// end -------------Test


cheers
Oliver

Derek Chen-Becker

unread,
Sep 6, 2008, 10:37:33 AM9/6/08
to lif...@googlegroups.com
I like the direction you're taking, but the ScalaQuery object would have to be a little richer because you need to be able to set query parameters and other things. Of course, you can do this by accessing the query val, but in JPA the query object returns itself for each method so that you can chain the ops. I had actually written up load, find and findAll methods in a previous version of this:

http://riteofcoding.blogspot.com/2008/04/more-progress-on-jpa.html

I'm sure they could be improved a bit but I like the idea of providing a little more "icing" around the em for dealing with types.

Derek

...

[Message clipped]  

Derek Chen-Becker

unread,
Sep 6, 2008, 11:17:27 AM9/6/08
to lif...@googlegroups.com
Let me put together a ScalaEM wrapper class that encapsulates some of the things that you suggested with what I've done before.

Derek

...

[Message clipped]  

Oliver Lambert

unread,
Sep 6, 2008, 11:26:32 AM9/6/08
to lif...@googlegroups.com
That would be cool - if you use something like ScalaQuery, there are only about ten Query methods. Examples of setParameter and SetMaxResults (returning ScalaQuery)
    def setMaxResults(maxResult: Int) = {query.setMaxResults(maxResult);this}
    def setParameter(name: String, value: Object) = {query.setParameter(name, value); this}

I would really like to introduce people to liftweb JPA without having them use asInstanceOf.  If I were new to Scala and saw 
version 2 below, I might think Java is a nicer language than Scala (that would be a shame).

1) val authors = Model.createNamedQuery[Author]("findAllAuthors").getResultList()
2) val authors = Model.em.createNamedQuery("findAllAuthors").getResultList().asInstanceOf[java.util.List[Author]]

Derek Chen-Becker

unread,
Sep 6, 2008, 11:47:55 AM9/6/08
to lif...@googlegroups.com
I agree. I'll put together two wrappers, and I might play with expanding some of the methods out. For example, I like handling parameters as a map that can be handed to the query (a la my find/findAll impls). I don't know if I'll be able to work on this until Tuesday. If you'd like to make modifications to your code based on this discussion feel free, otherwise I'll post something up as soon as I have it done.

Derek

Oliver Lambert

unread,
Sep 7, 2008, 3:49:02 AM9/7/08
to lif...@googlegroups.com
I've modified the code to expand all the methods of EntityManager and Query. I've also added a couple of value added methods such as setParams, as a map.
 I've included a zip of the code - the main changes are JPA.scala, Model.scala and AuthorTest.scala. 
JPAwebapp.zip

Tim Perrett

unread,
Sep 7, 2008, 5:57:16 AM9/7/08
to Lift
Sounds good Oliver - there was no attached zip file however?

Cheers

Tim
> Oliver

Oliver

unread,
Sep 7, 2008, 6:03:02 AM9/7/08
to lif...@googlegroups.com
I think my mac added it to the end of the email - anyway I've used online gmail to add it this time so hopefully it will appear

Oliver
JPAwebapp.zip

Tim Perrett

unread,
Sep 7, 2008, 5:50:33 PM9/7/08
to Lift
Ah cool - this is quite nice actually; good work Oliver!

@Derek, what are your thoughts?

It certainly strikes me that as time wears on and more people are
using the lift/jpa stuff that we should really create an archetype for
it.... would others find that useful?

Cheers

Tim

Charles F. Munat

unread,
Sep 7, 2008, 7:52:40 PM9/7/08
to lif...@googlegroups.com
Oh, hell yeah. Please!

And down the road, when the mapper becomes agnostic, would there be an
archetype that used JPA as the back end for the Lift mapper?

Chas.

Tim Perrett

unread,
Sep 8, 2008, 6:15:14 AM9/8/08
to Lift
Awesome, I have it working with SQL Server as well now, which is
sweet.

Im using JTDS for my driver, and the reading and updating work no
problem however the inserting does not work? I get the following
message:

DEBUG - could not insert: [com.foo.jpaweb.Author] [insert into authors
(name, id) values (?, ?)]
java.sql.SQLException: Parameter #2 has not been set.

With a stack trace to "Model.em.merge(author)", so for whatever reason
lift is not passing the values through to the entity for
persistence... any idea why that might be?

Now, from the jtds FAQ, it says:

--------------
When executing a stored procedure (or any query, for that matter) the
response from the SQL Server is serialized in the same order it is
executed in: for stored procedures this means ResultSets and update
counts first, output parameters and return value last. jTDS only
caches update counts , not ResultSets because they could easily cause
OutOfMemoryErrors or add important performance overheads if cached to
disk (the response would have to be parsed twice, for example).

As a conclusion, when executing stored procedures that only return
update counts output parameters will be available immediately, as jTDS
will process and cache the whole response. But if the stored procedure
returns at least one ResultSet jTDS will only cache the update counts
up to the first ResultSet and you will have to call getMoreResults()
to process all the results. So for procedures returning ResultSets you
will have to loop, consuming all results before reading the output
parameters (i.e. until getMoreResults() returns false AND
getUpdateCount() returns -1).
--------------




Tim Perrett

unread,
Sep 8, 2008, 7:29:24 AM9/8/08
to Lift
Just been doing some more debugging on this - it appears that the
correct values are being passed through and are assigned to an entity
instance, but they blow up when trying to do the em.merge(author)
call.

The stack trace I get is:

### AUTHOR
com.foo.jpaweb.model.Author@cc3e7c
### AUTHOR ID
0
### AUTHOR NAME
sdfsdssdfs
DEBUG - opened session at timestamp: 12208732519
DEBUG - begin
DEBUG - opening JDBC connection
DEBUG - total checked-out connections: 0
DEBUG - using pooled JDBC connection, pool size: 0
DEBUG - current autocommit status: true
DEBUG - disabling autocommit
DEBUG - after transaction begin
DEBUG - id unsaved-value: 0
DEBUG - transient instance of: com.foo.jpaweb.model.Author
DEBUG - merging transient instance
DEBUG - saving [com.foo.jpaweb.model.Author#<null>]
DEBUG - executing insertions
DEBUG - Wrapped collection in role: com.foo.jpaweb.model.Author.books
DEBUG - executing identity-insert immediately
DEBUG - Inserting entity: com.foo.jpaweb.model.Author (native id)
DEBUG - about to open PreparedStatement (open PreparedStatements: 0,
globally: 0)
DEBUG - insert into authors (name, id) values (?, ?)
Hibernate: insert into authors (name, id) values (?, ?)
DEBUG - preparing statement
DEBUG - Dehydrating entity: [com.foo.jpaweb.model.Author#<null>]
DEBUG - binding 'sdfsdssdfs' to parameter: 1
DEBUG - about to close PreparedStatement (open PreparedStatements: 1,
globally: 1)
DEBUG - closing statement
DEBUG - could not insert: [com.foo.jpaweb.model.Author] [insert into
authors (name, id) values (?, ?)]
java.sql.SQLException: Parameter #2 has not been set.
at
net.sourceforge.jtds.jdbc.ConnectionJDBC2.prepareSQL(ConnectionJDBC2.java:
613)

Oliver Lambert

unread,
Sep 8, 2008, 9:16:06 AM9/8/08
to lif...@googlegroups.com
You know I always forget those long winded archetype creation commands
and
thinking about this I guess I would hope for something more. Something
like specify
a set of tables (and stuff) and have "LiftBuilder" go and create
mappings, validation and default html
for me. I haven't looked at it for a long time, but I believe Grails
does something like this

Oliver

On 08/09/2008, at 9:52 AM, Charles F. Munat wrote:

>
> Oh, hell yeah. Please!
>
> And down the road, when the mapper becomes agnostic, would there be an
> archetype that used JPA as the back end for the Lift mapper?
>
> Chas.
>
> Tim Perrett wrote:
>> Ah cool - this is quite nice actually; good work Oliver!

Cheers

Oliver Lambert

unread,
Sep 8, 2008, 7:51:52 AM9/8/08
to lif...@googlegroups.com
Could it be that the author id isn't being created properly by the @GeneratedValue(strategy = GenerationType.AUTO)

Tim Perrett

unread,
Sep 8, 2008, 10:25:21 AM9/8/08
to Lift
Hey Oliver,

I think your right, it works no problem when updating.

Is there a way of stopping JPA inserting a value for a field with an
annotation or such?

Cheers

Tim

Tim Perrett

unread,
Sep 8, 2008, 10:43:26 AM9/8/08
to Lift
Hmmm, I've tried:

@Id
@GeneratedValue(){val strategy = GenerationType.AUTO}
@Column(){val insertable = false}
var id : Long = _

But yet its still being included in the query, any ideas?

Cheers, Tim

Oliver Lambert

unread,
Sep 8, 2008, 2:05:44 PM9/8/08
to lif...@googlegroups.com
I think sql server uses @GeneratedValue(strategy=GenerationType.IDENTITY) 
You could try this instead of GenerationType.AUTO (though this should translate to the above)

Oliver

Mateusz Fiołka

unread,
Sep 8, 2008, 2:15:38 PM9/8/08
to lif...@googlegroups.com

Oliver Lambert

unread,
Sep 8, 2008, 2:35:35 PM9/8/08
to Oliver Lambert, lif...@googlegroups.com
or, you could try

    @GeneratedValue(strategy = GenerationType.AUTO, generator = "system-guid")
    @GenericGenerator(name = "system-guid", strategy = "guid")

with or without the Microsoft driver
<property name="driverClassName">
<value>com.microsoft.sqlserver.jdbc.SQLServerDriver</value>
</property>

and the pom entry
<!dependency>
<groupId>MSSQLDriver</groupId>
<artifactId>sqljdbc</artifactId>
<version>1.1.1501.101</version>
</dependency>

Martin Ellis

unread,
Sep 8, 2008, 2:50:33 PM9/8/08
to lif...@googlegroups.com
Hi Tim,

On Mon, Sep 8, 2008 at 12:29 PM, Tim Perrett wrote:
>
> Just been doing some more debugging on this - it appears that the
> correct values are being passed through and are assigned to an entity
> instance, but they blow up when trying to do the em.merge(author)
> call.
>
> The stack trace I get is:

You didn't post the full stack trace (or at least, it didn't show up
in gmail), but there are only two places I can see merge being called:

(Authors)
def add (xhtml : NodeSeq) : NodeSeq = {
def doAdd () = {
if (author.name.length == 0) {
error("emptyAuthor", "The author's name cannot be blank")
} else {
Model.merge(author)
redirectTo("list.html")
}
}

and (Books) ....

def add (xhtml : NodeSeq) : NodeSeq = {
def doAdd () = {
Model.merge(book)
redirectTo("list.html")
}


The above looks slightly fishy, but I'm afraid I don't have time right
now to try the project to check.

If you want to add something, shouldn't you be calling persist rather
than merge?
I'd expect to see merge being used in a method called doUpdate() or whatever...
... or can you really get away with calling merge when something's not
in the DB yet?

Just a thought.

Regards
Martin

Tim Perrett

unread,
Sep 8, 2008, 7:19:53 PM9/8/08
to Lift
Hey all,

Very strange, I re-wrote the classes in Java and I still see the same
issue!!!

What on earth could be going on here? I tried calling persist rather
than merge, but it appeared to have no impact.

Cheers

Tim

Tim Perrett

unread,
Sep 8, 2008, 7:37:10 PM9/8/08
to Lift
I managed to fix it in the end by reading some really really old post
in the hibernate archive.

Effectively, if you define something, a class property that has no
initial value (in our case, _ ) then it bones the inserting for some
reason. Quite knows what it does that but it does...... and with very
little error as well :-(

For completeness sake, here is the final Author class:

@Entity
@Table(){val name="authors", val schema="dbo"}
class Author {
@Id
@GeneratedValue(){val strategy = GenerationType.IDENTITY}
@Column(){val insertable = false, val unique = true}
var id : Long = 100

var name : String = ""

@OneToMany(){val mappedBy = "author", val targetEntity =
classOf[Book]}
var books : java.util.Set[Book] = new java.util.HashSet[Book]()
}

Oliver

unread,
Sep 8, 2008, 8:19:34 PM9/8/08
to lif...@googlegroups.com
Doesn't look right. The id is the primary key - it could now be inserted with a value of 100, always.
I can do an insert here with
 @Id
 @GeneratedValue(){val strategy = GenerationType.AUTO}

Still works without GeneratedValue being present. My pom dependencies are
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>3.3.2.GA</version>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.jtds</groupId>
            <artifactId>jtds</artifactId>
            <version>1.2</version>
        </dependency>

Properties in persistance.xml
   <properties>
      <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
      <property name="hibernate.connection.driver_class" value="net.sourceforge.jtds.jdbc.Driver"/>
      <property name="hibernate.connection.username" value="xx"/>
      <property name="hibernate.connection.password" value="xx"/>
      <property name="hibernate.connection.url" value="jdbc:jtds:sqlserver://localhost:1433/fred"/>

      <property name="hibernate.max_fetch_depth" value="3"/>
      <property name="hibernate.show_sql" value="true"/>
</properties>

Tim Perrett

unread,
Sep 9, 2008, 5:47:40 AM9/9/08
to Lift
I agree - its strange and not what we would expect.

What version of SQL server are you running? Im using 2005 Enterprise
here...

Its just a really strange thing, the 100 is always ignored... I think
it just needs a 2nd parameter there, even if its going to ignore it.
Thats certainly what it looks like from the SQL thats being run
anyway. I would have thought the GenerationType.IDENTITY would mean
that it knows not to use it in SQL inserts/updates, but obviously not.

Cheers

Tim

Oliver Lambert

unread,
Sep 9, 2008, 7:09:28 AM9/9/08
to lif...@googlegroups.com

On 09/09/2008, at 7:47 PM, Tim Perrett wrote:

>
> I agree - its strange and not what we would expect.
>
> What version of SQL server are you running? Im using 2005 Enterprise
> here...
>

I think thats what they are using at my company


> Its just a really strange thing, the 100 is always ignored... I think
> it just needs a 2nd parameter there, even if its going to ignore it.
> Thats certainly what it looks like from the SQL thats being run
> anyway. I would have thought the GenerationType.IDENTITY would mean
> that it knows not to use it in SQL inserts/updates, but obviously not.
>

I assume that you have run a simple unit test to do an insert with
persist e.g.
def testOK = {

val na = new Author()
na.name = "HELLO THERE!!!!!"
Model.persist(na)

val authors = Model.createNamedQuery[Author]
("findAllAuthors").getResultList()

authors.foreach(author => {
println("name: "+author.name)
author.books.foreach(book => println(" title: "+book.title))
})
}

If you are still having problems, "mvn clean" your project, zip it up
and mail it to me - I'll run it tomorrow morning, when I get to work

Oliver


> Cheers
>
> Tim
> >

Derek Chen-Becker

unread,
Sep 9, 2008, 10:35:15 AM9/9/08
to lif...@googlegroups.com
Looks like I missed a lot in the two days I was gone :). I'm going to look at Oliver's code and merge it. As for Tim's problem with the insertions, the AUTO ID generation should usually just work. I don't have a SQL Server instance to try it out on, but after I merge the code I'll test it again with HSQL, PostgreSQL and MySQL to make sure that it works there. If so, it may be something specific to the SQL Server dialect.

Derek

Derek Chen-Becker

unread,
Sep 9, 2008, 12:55:25 PM9/9/08
to lif...@googlegroups.com
OK, the code is merged in and the latest version is attached. I made a few minor modifications to the JPA code that Oliver sent:

1. I made the openEM and closeEM methods abstract and protected. The idea is that the JPA class shouldn't be tied to the way the user wants to access JPA. Rather, when they implement the JPA class they can provide their own hooks to do direct access, IoC, or JNDI, etc.

2. I added a convenience method for createNamedQuery so that you can pass parameters in when you create the query. A very minor change but it saves a little typing when you use it a lot.

I've also changed the module naming per Oliver's suggestion. I'll test against the other DBs this afternoon, but so far I've had no issues with HSQLDB.

Derek
jpademo.tar.gz

Oliver

unread,
Sep 10, 2008, 1:19:58 AM9/10/08
to lif...@googlegroups.com
Hi Derek,

this is looking good

On Wed, Sep 10, 2008 at 2:55 AM, Derek Chen-Becker <dchen...@gmail.com> wrote:
OK, the code is merged in and the latest version is attached. I made a few minor modifications to the JPA code that Oliver sent:

1. I made the openEM and closeEM methods abstract and protected. The idea is that the JPA class shouldn't be tied to the way the user wants to access JPA. Rather, when they implement the JPA class they can provide their own hooks to do direct access, IoC, or JNDI, etc.

2. I added a convenience method for createNamedQuery so that you can pass parameters in when you create the query. A very minor change but it saves a little typing when you use it a lot.

I like this, it saves typing and reads a lot better
 

I've also changed the module naming per Oliver's suggestion. I'll test against the other DBs this afternoon, but so far I've had no issues with HSQLDB.

I've also tested it against SQL Server 2000 and it runs without any problems (unfortunately, I don't have SQL Server 2005 or later, to test against)
 

Tim Perrett

unread,
Sep 10, 2008, 5:43:21 AM9/10/08
to Lift


> I've also tested it against SQL Server 2000 and it runs without any problems
> (unfortunately, I don't have SQL Server 2005 or later, to test against)
>

Reading online, there seem to be a number of eccentricities with 2005
+ 2008, so it might just be that. Its working for me now, so as long
as it continues to work its all good!

Cheers

Tim

Tim Perrett

unread,
Sep 10, 2008, 5:47:22 AM9/10/08
to Lift
Out of interest, I tried playing around with hibernate-validator on
this demo to see if it works, and (as you can see below), it doesnt.

Any ideas why its doing this?

Looking at the compiled bytecode, its trying to invoke the synthesized
method "name_$eq(String x$1)", and for some reason, failing to call it
properly.

Anyone else's input would be interesting :)

Cheers

Tim



-------------------------------------------------------------------------------
Test set: com.foo.jpaweb.model.TestJPAWeb
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.598
sec <<< FAILURE!
save_stuff(com.foo.jpaweb.model.TestJPAWeb) Time elapsed: 1.554 sec
<<< ERROR!
java.lang.IllegalStateException: Could not get property value
at
org.hibernate.validator.ClassValidator.getMemberValue(ClassValidator.java:
537)
at
org.hibernate.validator.ClassValidator.getInvalidValues(ClassValidator.java:
383)
at
org.hibernate.validator.ClassValidator.getInvalidValues(ClassValidator.java:
351)
at
org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListener.java:
139)
at
org.hibernate.validator.event.ValidateEventListener.onPreInsert(ValidateEventListener.java:
172)
at
org.hibernate.action.EntityIdentityInsertAction.preInsert(EntityIdentityInsertAction.java:
119)
at
org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:
42)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at
org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:
298)
at
org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:
181)
at
org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:
107)
at
org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:
49)
at
org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:
131)
at
org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:
87)
at
org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:
38)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:618)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:592)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:596)
at
org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:
213)
at com.foo.jpaweb.model.TestJPAWeb.save_stuff(TestJPAWeb.scala:34)
Caused by: java.lang.IllegalArgumentException: Invoking name_$eq with
wrong parameters
at
org.hibernate.annotations.common.reflection.java.JavaXMethod.invoke(JavaXMethod.java:
39)
at
org.hibernate.validator.ClassValidator.getMemberValue(ClassValidator.java:
534)
... 45 more
Caused by: java.lang.IllegalArgumentException: wrong number of
arguments
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.hibernate.annotations.common.reflection.java.JavaXMethod.invoke(JavaXMethod.java:
33)

Derek Chen-Becker

unread,
Sep 10, 2008, 9:06:16 AM9/10/08
to lif...@googlegroups.com
Yeah, I tested in PostgreSQL 8.3 and it works fine there, too. Weird.

Derek Chen-Becker

unread,
Sep 10, 2008, 9:22:12 AM9/10/08
to lif...@googlegroups.com
Two lines lower it looks like it's trying to fetch the value (ClassValidator.getMemberValue), but name_$eq is the setter for a value, not the getter. That's probably why it's coming up with the error "wrong number of arguments". You might try adding an explicit "getter" for the property you want to validate and put the annotation there to see if that works. The @BeanProperty Scala annotation might be enough to force the use ofr get/set by the Validator framework. Just a guess at this point.

Derek

Viktor Klang

unread,
Sep 10, 2008, 11:37:41 AM9/10/08
to lif...@googlegroups.com
Or just write a PropertyAccessor implementation for Scala vars?
That should do the trick.
 
Cheers,
Viktor

Tim Perrett

unread,
Sep 10, 2008, 11:50:56 AM9/10/08
to Lift
PropertyAccessor? Im not familiar Viktor, can you explain a little
more?

Thanks

Tim

Viktor Klang

unread,
Sep 10, 2008, 12:01:27 PM9/10/08
to lif...@googlegroups.com
Hi Tim,
 
 
It should be declared with the @Access annotation (if I remember correctly)
Cheers,
Viktor
Reply all
Reply to author
Forward
0 new messages