play querydsl plugin Limiting Qclass generation by package - jpa

I am using play framework version 2.2.0 and using play-querydsl plugin.
I am using Spring Data JPA version 1.7.2 integrated with play framework.
I am not using querydsl for all the model classes and only for few scenarios which are not supported by Spring Data JPA such as mixing more than one AND, OR checks in the WHERE clause.
Hence I would like to limit the generation of the QClasses by the play-querydsl plugin to few packages only and not all the packages which contain ENTITY classes.
I referred to https://github.com/CedricGatay/play-querydsl and added the QueryDSLPlugin.queryDSLPackage entry to my build.sbt as below :
playJavaSettings ++ QueryDSLPlugin.queryDSLSettings
QueryDSLPlugin.queryDSLPackage := "com.codetroopers.app.models"
But after this, when I try to build the play app using activator, the Q classes are not getting generated. When I removed the QueryDSLPlugin.queryDSLPackage entry from my build.sbt file, the Q classes are generated normally for all ENTITY classes inside models package.
Is there a way to limit the Q class generation by the plugin to only few packages or to only package ?
Vijay

Check out version 0.1.2 of the plugin -it's just been released. According to docs:
//From Play 2.3 and onward (thanks to autoImport feature)
queryDSLPackage := "com/codetroopers/app/models"
//OR Up to play 2.2
QueryDSLPlugin.queryDSLPackage := "com/codetroopers/app/models"
I'm using Play 2.3 and can confirm that it now works as expected (everything under com/codetroopers/app/models is scanned recursively).

Related

How to fix dependency injection when upgrading play framework from 2.5.x to 2.6.x Scala

I am trying to upgrade from play 2.5.x to 2.6.3. (Because 2.5.x doesn't support multipart post in WS. import play.api.libs.ws.DefaultBodyWritables._ throws Exceptions. The code example in the official document doesn't work. The compiler needs the Body Writables which is not provided until 2.6.x)
So I changed the plugin.sbt version to 2.6.3 and upgraded sbt to 0.13.15. And edit the build.sbt file to add guice and json. The project compiles fine. But when I started with sbt run, and visit http://localhost:9000, it throws a bunch of Exception related to a jar file I have in the local lib/ directory. The same code worked just fine with 2.5.x.
Here's the exception:
1) Error injecting constructor, java.lang.NoClassDefFoundError: com/google/common/util/concurrent/FutureFallback
at db.ConcreteGGDB.(ConcreteGGDB.scala:24)
at Module.configure(Module.scala:29) (via modules: com.google.inject.util.Modules$OverrideModule -> Module)
while locating db.ConcreteGGDB
Any idea if this is related to the local jar is not compatible with 2.6.x? or I need to change some code to do dependency injection other than specify in the Module.scala file? Thanks.
Why am I getting a NoClassDefFoundError in Java?
Error injecting constructor, java.lang.NoClassDefFoundError: com/twitter/finagle/http/Method$Get$
NoClassDefFound means that there's a class that your code needs, but
it can't find it. This typically happens when your project
transitively depends on more than one version of a library. For
example, imagine that you're building project A, which depends on lib
X, and project B, which also depends on lib X. However, project B was
built against an older version of lib X, which used to have a class,
but which it no longer exports.
A => B => X (version 1)
A => X (version 2)
Then when it runs, A makes a call into B, which tries to make a call
into X, but because the project now uses the newer version instead of
the older version, it can't find the class it needs.
I would encourage you to use sbt-dependency-graph to see which
versions of [library name] you're depending on transitively, and ensure that
every library you use uses the same version of [library name].
Looks like an issue with the local jar.

UnsupportedClassVersionError on play with JDK 1.7

I am getting the same error as this post. i'm trying to resolve the problem as mentioned in the proposed solution but i didn't understand how ?
If you are using version 2.4.x (or newer), you must use Java 8. From the Highlights of version 2.4:
Play 2.4 now requires JDK 8. Due to this, Play can, out of the box, provide support for Java 8 data types. For example, Play’s JSON APIs now support Java 8 temporal types including Instance, LocalDateTime and LocalDate.
To confirm that you are using Play 2.4, see file project/plugins.sbt.
Edit:
If you can't (or don't want to) use Java 8, you have to use Play 2.3 instead. To do so, you must edit project/plugins.sbt to change the used version of Play:
// Notice we are now using version 2.3.10
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.10")
If this is a brand new project, you can recreate it using 2.3 template instead:
activator new play-scala-2.3 name-of-your-project
Or, for Java:
activator new play-java-2.3 name-of-your-project

Migrate from Play 2.0.4 to 2.1: Tika doesn't find my class anymore

I migrated a web application from Play Framework 2.0.4 to 2.1.
The application uses Apache Tika (V. 1.3) with a custom parser as described here on the Tika-Homepage.
A file myPlayProject/conf/META-INF/services/org.apache.tika.parser.Parsercontains the name of the custom parser class like this:
# Add here all custom parsers for Apache Tika.
com.test.CustomTikaParser
The custom parser will get detected with Play 2.0.4, but not anymore with Play 2.1. I have tried it with two fresh 2.0.4vs2.1-projects and got the same problem with V. 2.1.
Has something changed with the classpath between these Play versions?
(I can read the file META-INF/services/org.apache.tika.parser.Parser with Play 2.0.4 and Play 2.1 under the classpath.)
maybe try a simple command :
play clean-all update reload compile,
it will be clean your .target do an update and reload of your application then a compile...

Play Framework and JPA

testing Play framework and JPA.
I eclipsify my very simple test application. Import the project in eclipse and confirm that the play jar file is in my eclipse java build path: C:\play-2.0.2\repository\local\play\play_2.9.1\2.0.2\jars\play_2.9.1.jar
in my simple Item entity class, I import play.db.jpa.Model which my entity should extend
Here, eclipse is not be able to resolve the class!
Notice, the following jar file DOES NOT include the Model class - which I understand is essential in order to integrate with PLAY with JPA.
play_2.9.1.jar -> play\db\jpa\Model
the jpa only includes the following:
TransactionalAction$1.class
JPA.class
TransactionalAction.class
Transactional.class
JPAPlugin.class
JPA$1.class
what am I missing? do i include a wrong jar in my path?
where is Model.class??
Be sure to import play.db.ebean.*;, Play 2.0 uses Ebean for the Model extension.
Documentation can be found http://www.playframework.org/documentation/2.0.1/JavaEbean

GWT upgrade from 2.1 to 2.4

while compiling from GWT 2.1 to 2.4, the following error is shown:
Found interface com.google.gwt.core.ext.typeinfo.JClassType, but class was expected
so kindly provide me with the solution to this issue.
There's a binary backwards-incompatibility in GWT 2.2 (where com.google.gwt.core.ext.typeinfo.JClassType et al. were changed from classes to interfaces). You have to update your third-party dependencies with ones that have been compiled against the GWT 2.2 SDK or a newer version; for your own library or if the third-party lib has been somewhat abandoned, you'll have to recompile it (javac).
GIN for example provides 2 builds of its 1.5 release: one compatible with GWT 2.1.1 and older, and one compatible with 2.2 onwards (there are two distinct JARs in the gwt-1.5.zip download).