QueryDsl error. Q classes not generated - java

I try to generate query type classes (e.g. QUser) but got errors...
You can find my source code here: https://github.com/TheNakedMan/remindme.server/
I'am working with IntelliJ IDEA, and it seems like I have working plugin.
Help me, please.
Log message:
/remindme.server/src/main/java/com/qoobico/remindme/server/repository/UserRepository.java
Error:(21, 126) java: cannot find symbol symbol: class QUser
Error:(25, 62) java: cannot find symbol symbol: class QUser
location: interface
com.qoobico.remindme.server.repository.UserRepository
UPDATE:
After LifeCycle->clean and run apt:process in IntelliJ, I have this error:
[ERROR] Failed to execute goal on project com.qoobico.remindme.server:
Could not resolve dependencies for project
com.qoobico.remindme.server:com.qoobico.remindme.server:war:1.0-SNAPSHOT:
Could not find artifact
com.qoobico.remindme.server:com.qoobico.remindme.server:jar:1.0-SNAPSHOT

In your sources you did not import the generated classes, for instance:
import com.qoobico.remindme.server.entity.QUser;
If you want to generate the classes without compile and/or install the package use the maven goal apt:process.
You can use IntelliJ to start such a maven goal, use the Maven Projects window. The window will show you all available goals.
On the commandline you could use the mvn cli, which can be downloaded here.
Hint: the command from the help plugin mvn help:describe -Dplugin=com.mysema.maven:apt-maven-plugin will show you a list of all available apt-maven-plugin goals.
You configured the outputDirectory to: target/generated-sources/java
To let your IDE find that classes, put them into your class path. Some IDEs like IntelliJ will do this automatically for maven projects, because that folder is the default.

Related

mvn dependency not recognised after dependency version change

I have a custom dependency for my project, api-client. This dependency is used to connect among multiple modules within my project.
The problem is, if I make any changes in my api-client dependency and I produce a .jar file using the below command:
mvn install -Dmaven.test.skip=true
I will place that .jar file in my .m2 repository manually. Afterwards, if I try to run other modules which depends on api-client, those modules
would throw lots of compilation errors. (Previously, all ran successfully.)
Some of the sample errors are as follows:
[ERROR] /C:/Local/core/src/main/java/com/core/service/impl/DBSClaimServiceImpl.java:[33,39] C:\Local\core\src\main\java\com\core\service\impl\DBSClaimServiceImpl.java:33: package org.apache.commons.lang3 does not exist
[ERROR] /C:/Local/core/src/main/java/com/core/service/impl/DBSClaimServiceImpl.java:[33,1] C:\Local\core\src\main\java\com\core\service\impl\DBSClaimServiceImpl.java:33: static import only from classes and interfaces
[ERROR] /C:/Local/core/src/main/java/com/core/model/Dealer.java:[9,39] C:\Local\core\src\main\java\com\core\model\Dealer.java:9: package org.apache.commons.lang3 does not exist
[ERROR] /C:/Local/core/src/main/java/com/core/model/Dealer.java:[9,1] C:\Local\core\src\main\java\com\core\model\Dealer.java:9: static import only from classes and interfaces
[ERROR] /C:/Local/core/src/main/java/com/core/resource/settlement/flatFile/RecordType1ClaimInformation.java:[10,39] C:\Local\core\src\main\java\com\core\resource\settlement\flatFile\RecordType1ClaimInformation.java:10: package org.apache.commons.lang3 does not exist
All the packages are available in my local repository, but still, it is not recognising them. I am unsure what exactly the problem is here.
Below please find entries that I have in one of the module:
<api.version>1.0.245</api.version>
<api.client.version>1.0.292</api.client.version>
The problem started once I changed the above version (api.client.version). After that, an old version also throws the same error.
To resolve transitive dependencies, other modules do not just need the api-client.jar, but also a generated pom.xml which declares what other jars are needed to use api-client.jar.
There are multiple ways to fix this, but the description of your environment is not detailed enough to tell how best to fix this.

com.apple.AppleJavaExtensions AboutHandler class not found

I'm trying to compile my java project with maven, but every time i got this error:
ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project tts: Compilation failure: Compilation failure:
[ERROR] /Users/stefano/Programming/git/DyslexoTTS/src/main/java/io/dyslexo/graphics/Tray.java:[3,22] cannot find symbol
[ERROR] symbol: class AboutHandler
[ERROR] location: package com.apple.eawt
On intelliJ I have no issues, why maven does not work?
Here the piece of code:
Application application = Application.getApplication();
application.setAboutHandler(e -> {
//my code
});
I also tried to compile on different platforms like linux and windows, but i got the same error.
How can I fix that?
I also tried to compile on different platforms like linux and windows,
but i got the same error. How can I fix that?
You'll have to add a stub library since those classes aren't available on non-Mac platforms. AppleJavaExtensions is one example. Put it in your compilation classpath, but be sure not to include it in the final product, assuming those classes will be available runtime.

How do I get IntelliJ to recognise resource bundle when compiling?

Ok, first up I am almost completely unfamiliar with Java and Java tooling.
I am attempting to contribute a bugfix to a Jenkins plugin. Code-wise the fix is simple, my problem is in trying to compile the project and run the tests locally.
I have installed IntelliJ IDEA 15CE and started a new project, pointing it to my local clone of the plugin repo.
It has gone away and 'downloaded the internet' in terms of Maven dependencies. Mostly everything looks ok. What I want to do is to run the tests...
If I right-click at the root of the project and select 'Run All Tests' I get the error:
Error:(115, 29) java: cannot find symbol
symbol: variable Messages
location: class hudson.plugins.copyartifact.BuildSelector
The source of this error is a line:
console.println(Messages.CopyArtifact_MissingSrcArtifacts(srcDir));
https://github.com/jenkinsci/copyartifact-plugin/blob/master/src/main/java/hudson/plugins/copyartifact/BuildSelector.java#L115
As far as I can tell the Messages symbol should resolve to this properties file:
https://github.com/jenkinsci/copyartifact-plugin/blob/master/src/main/resources/hudson/plugins/copyartifact/Messages.properties
...which IDEA recognises as a 'Resource Bundle' in the project tree view.
But it doesn't seem to recognise it when compiling the project.
I have no idea where to start fixing this. The tests run fine if I push a commit to a pull request on GitHub and let the cloudbees.com Jenkins server run them, but I'd like to be able to test stuff locally first.
Run the maven compile command from Intelli-J Maven tool. After compiling error will vanish.
When you compile it will generate a Messages.java file in generated sources automatically.

Building IntelliJ project in TeamCity

I'm new to IntelliJ and Java but I have a fair bit of TeamCity experience, mostly building .Net projects.
I have created a very simple Android Library project in IntelliJ with basically a single class that uses RxJava (Reactive Extensions for Java). I have added the Rx library in IntelliJ using Project Structure -> Libraries -> From Maven. The actual library I have added is com.netflix.rxjava:rxjava-android:0.19.6 which pulls in com.netflix.rxjava:rxjava-core:0.19.6.
This works brilliantly and my project compiles within IntelliJ without even having to install Maven. Nice job, JetBrains.
However, when I try to build the project in TeamCity using the IntelliJ-IDEA runner, the project doesn't compile. Bad JetBrains!
I get errors on all the references to rx.*, which as I said all worked perfectly on my workstation. The errors from TeamCity look like this:
C:\BuildAgent\work\eefd62e2c3082b56\src\com\example\TigraAndroidUtilities\ObservableModel.java:3: package rx does not exist
import rx.Observable;
^
C:\BuildAgent\work\eefd62e2c3082b56\src\com\example\TigraAndroidUtilities\ObservableModel.java:4: package rx.subjects does not exist
import rx.subjects.BehaviorSubject;
^
C:\BuildAgent\work\eefd62e2c3082b56\src\com\example\TigraAndroidUtilities\ObservableModel.java:18: cannot find symbol
symbol: class BehaviorSubject
location: class com.example.TigraAndroidUtilities.ObservableModel
private BehaviorSubject modelStream;
^
C:\BuildAgent\work\eefd62e2c3082b56\src\com\example\TigraAndroidUtilities\ObservableModel.java:63: cannot find symbol
symbol: class Observable
location: class com.example.TigraAndroidUtilities.ObservableModel
public Observable toObservable()
^
C:\BuildAgent\work\eefd62e2c3082b56\src\com\example\TigraAndroidUtilities\ObservableModel.java:28: cannot find symbol
symbol: variable BehaviorSubject
location: class com.example.TigraAndroidUtilities.ObservableModel
modelStream = BehaviorSubject.create(modelData);
^
C:\BuildAgent\work\eefd62e2c3082b56\src\com\example\TigraAndroidUtilities\ObservableModel.java:65: cannot find symbol
symbol: variable Observable
location: class com.example.TigraAndroidUtilities.ObservableModel
if (completed) { return Observable.empty(); }
^
Here's what I've tried:
Considered using the Maven build runner instead; but the project doesn't have a POM file so it's not a Maven build.
I've tried installing Maven on the build agent, that doesn't seem to make any difference and I didn't need to install it for IntelliJ to work locally so I can't see why it would be needed.
There is a path macro called MAVEN_REPOSITORY in the IntelliJ build runner settings and I've tried setting that to various different values, no luck.
I've looked at JetBrains' documentation for the IntelliJ runner and as far as I can tell, I've configured my build step correctly. Clearly I'm missing something though.
This is all a bit frustrating, I've been tinkering with it hours but nothing seems to work and basically I have no clue what I'm doing wrong. I must have missed something somewhere. How can I get this build working properly in TeamCity?
As of TeamCity 9.1, its IDEA runner can't build Maven modules any longer, nor can it auto-download external artifacts from Maven Central.
Basically, what you need is:
Download external artifacts, one by one, using TeamCity Maven runner and maven-dependency-plugin, as described in this answer., e. g.:
mvn org.apache.maven.plugins:maven-dependency-plugin:3.0.0:get com.netflix.rxjava:rxjava-android:0.19.6
You'll need as many Maven build steps as the number of dependencies in your IDEA project, and these steps must precede the IDEA runner build step.
At the build configuration level, set the system.path.macro.MAVEN.REPOSITORY system property to %env.HOME%/.m2/repository.
That's it.
Happy building!

springframework source in Idea Intellij

I'm having hard time to setup springframework code in Intellij.
I git-cloned springframework project from github, and ran ant task to get all the libraries into ivy-cache directory.
I found "spring-framework.ipr" file for intellij project, and opened it.
Unfortunately, some of the libraries are not correctly mapped to the jar files or missing. So I cannot compile the codebase in IDE.
I also tried importing as eclipse project into intellij. Jar file reference seems ok.
But there are compilation errors in OXM module. Some test classes have reference to auto generated classes such as "~.samples.flight.FlightDocument", "~.jaxb.test.FlightType", and they don't exist(ant test goal generates them in target dir).
It seems same problem happens in STS.
I referenced this blog post:
http://blog.springsource.org/2009/03/03/building-spring-3/
Any good idea to setup spring code in intellij?
I use intellij v11.
git branch: 3.1.x
git commit: e8fc90ce3e4554f14eaa86ce05591249d3fe62fa
Compilation error example:
.../org.springframework.oxm/src/test/java/org/springframework/oxm/xmlbeans/XmlBeansMarshaller Tests.java
Error:(29,42) package org.springframework.samples.flight does not exist
Error:(30,42) package org.springframework.samples.flight does not exist
Error:(44,9) cannot find symbol class FlightsDocument
Error:(44,58) package FlightsDocument does not exist
....
Thanks,
problem solved.
"spring-framework.ipr" is the one for intellij.
lesson learned:
simply wrong version of junit was referenced in spring-framework.ipr file.
when ant build failed middle of the test, subsequent module won't be built. so, required libraries won't be downloaded into ivy-cache/repository.
"ant jar" goal will not download test related libraries since the goal doesn't run tests
After all the tests passed and manually fixed junit reference, intellij finally has no errors.

Categories