I'm just trying to add the Lombok plugin to IntelliJ IDEA 12.1.4. on a Mac machine, see:
The documentation on this page (https://code.google.com/p/lombok-intellij-plugin/) said:
...just download, unzip to IntelliJ plugin directory and try out!
First I had to use EasyFind to find out this folder, because it was invisible...
than I put the plugin at the directory:
~/Library/Application Support/IntelliJIdeaXX
as specified on this page (http://devnet.jetbrains.com/docs/DOC-181), and redeployed the app. But the code keeps showing compile errors on every line that uses Lombok's features, even the simple #Getter and #Setter annotations.
so I've restarted the IDE, the highlighted compile time errors were gone, but when I run it on Glassfish it caught the compile time error, on the same line of code: trying to get a property using getter method that is generated by Lombok.
Exception:
Caused by: java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: <any>
at com.codepianist.model.Model.<clinit>(Model.java:40)
... 50 more
Error:
// Error code
#Getter
private static Map<String, Language> LANGUAGES_MAP = new HashMap();
static {
for(Language l : LANGUAGES)
LANGUAGES_MAP.put(l.getId(), l); // line 40
}
Language Class:
// Language class
public class Language implements Serializable{
public Language(){}
public Language(String id, String flag) {
this.id = id;
this.flag = flag;
this.locale = new Locale(id);
}
#Getter private String id;
#Getter private String flag;
#Getter private Locale locale;
}
For information: Tried to call mvn clean install -e from my Terminal and not a single error. And the same app, runs fine with Netbeans.
May I have to configure the plugin on any IDE section?
I'm migrating from Netbeans, and just installed IntelliJ IDE, so I'm pretty new to it.
Thanks in advance.
Try installing the plugin using the following guide: http://www.jetbrains.com/idea/features/open_api_plugin_manager.html
Related
Running the following command mvn -U clean install is there a way to check -U from within my custom Mojo?
I checked available items in AbstractMojo.getPluginContext() but didn't find anything for command line.
Technically it is possible get the information via the MavenSession:
#Parameter(defaultValue = "${session}", readonly = true)
private MavenSession session;
public void execute() {
...
if (session.getRequest().isNoSnapshotUpdates()) {
...
}
}
But I would ask why do you need such information within a plugin?
I am struggling for quite a while to make Lombok getter available in two parts of my Spring Boot API. Despite many articles about this error, I haven’t found a suitable solution on the internet for my problem. IntelliJ does recognize all lombok annotations at development time. However, the compilation breaks with the following error:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] xxxxxxxxxxxxxxxxxxxxxxxxxxx/service/AuditorAwareService.java:[19,49] cannot find symbol
symbol: method getId()
location: variable userModel of type xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.UserShortModel
I am using getters, setters and other annotations as well and it works as expected. When I manually implement a getId() getter method in class UserShortModel then no complication error occurs and it works as expected.
The error above is the first example where the Lombok getter can’t be found. AuditorAwareService is annotated as a bean in my AppConfiguration class.
#Configuration
#EnableJpaAuditing(auditorAwareRef = "auditorAware")
public class AppConfiguration {
#Bean
public AuditorAware<Long> auditorAware() {
return new AuditorAwareService();
}
}
The second and last example where the same error occurs is when I use a predefined getter in a method in an entity (javax.persistence) class. FirstName and LastName are valid getters in the class IndividualModel. The getter getLabel(), getFirstName(),LastName() throw “cannot find symbol” errors when compiling the code.
#Entity
#Getter
#Setter
#NoArgsConstructor
#AllArgsConstructor
#SuperBuilder
#Table(name = "employees")
public static class EmployeeModel extends IndividualModel {
#ManyToOne
#JoinColumn(name="title_id")
private StaticDataModel.StaticDataShortModel title;
#NotNull
#JsonProperty(required = true)
public String getFullName() {
if (this.title != null) {
return this.title.getLabel() + " " + this.getFirstName() + " " + this.getLastName();
}
return this.getFirstName() + " " + this.getLastName();
}
}
I guess the reason is that lombok is too late with creating the getters and setters in the compilation process. I recognized when I build the module before compiling with IntelliJ, all lombok getters are found, even in the app configuration and the entities. However, please note, since I want to use Jenkins the build function of IntelliJ is not a working solution for my project. I also tried to change the annotation process with annotationProcessorPaths in the pom.xml like mentioned here https://newbedev.com/how-to-configure-lombok-with-maven-compiler-plugin. Unfortunately, the same compilation errors occur.
Does anybody can help me to make lombok annotations available in app configurations and entity methods?
Thank you very much!
im having an annoying issue where I cant seem to find a solution for.
Im currently implementing a way to read only the top 500 Entries ordered by Date. If I dont enter the Order By, Spring boot delivers the top 500 which is fine, but as soon as I include the Order By Option I get this Error:
Caused by: java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.sma.db.repositories.LogRepository.findTop500ByOrderBylogsLogTimeDesc()! No property orderBylogsLogTimeDesc found for type LogEntity!
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:96) ~[spring-data-jpa-2.3.5.RELEASE.jar:2.3.5.RELEASE]
As it seems, Spring boot includes the Order by and and looks for a property named orderbylogsLogTimeDesc . What I also dont understand is, why order is written in lower cases.
Does anyone know a solution for this? It is really annoying and I cant seem to find a solution :(
Repository:
#Repository
public interface LogRepository extends JpaRepository<LogEntity, Long>{
// List<FeedEntity> deleteByfeedTimestamp(Date feed_timestamp);
List<LogEntity>findTop500ByOrderBylogsLogTimeDesc();
}
Entity:
#Column(name = "logs_logtime")
private Date logsLogTime;
public Date getLogsLogTime() {
return logsLogTime;
}
public void setLogsLogTime(Date logsLogTime) {
this.logsLogTime = logsLogTime;
}
Service:
#Service
public class LogService {
#Autowired
private LogRepository repo;
public List<LogEntity> getLogs() {
return repo.findTop500ByOrderBylogsLogTimeDesc();
}
Ive found the solution in the end: I had to write LogsLogTime instead of logsLogTime... . It works now :) Thanks!
Maybe you have to specify the field twice, have you tried:
List<LogEntity>findTop500ByLogsLogTimeOrderByLogsLogTimeDesc();
You guys gave me an idea. I actually found the Issue! When i typed LogsLogTime it worked as in:
findTop500ByOrderByLogsLogTimeDesc
I'm in the process of migrating from Play Framework 2.1.5 to 2.2.6. I was having tons of errors like this:
[error] C:\dev\CS\trunk\app\models\Asset.java:57: error: cannot find symbol
[error] #NotNull
[error] ^
[error] symbol: class NotNull
[error] location: class Asset
and this:
play.PlayExceptions$CompilationException: Compilation error[error: package com.avaje.ebean.validation does not exist]
at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14$$anonfun$apply$16.apply(PlayReloader.scala:304) ~[na:na]
at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14$$anonfun$apply$16.apply(PlayReloader.scala:304) ~[na:na]
at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14.apply(PlayReloader.scala:304) ~[na:na]
at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14.apply(PlayReloader.scala:298) ~[na:na]
I have found online in this thread that I needed to add a line in my dependencies to make it work.
"org.avaje.ebeanorm" % "avaje-ebeanorm-api" % "3.1.1",
I have multiple question about this:
1. Why is another import needed for Ebean? I have imported the javaEbean, shouldn't it be enough to be up and running? It was ok 2.1.5 and nothing point to that in the migration documentation.
2. When I look at this package, it seems to be used by nobody. Should I be using something else? Is this some kind of deprecated package?
3. The main reason I ask all of these questions is because, even if it work to resolve these dependencies on my dev machine (windows), when deploying on the server (unix), it doesn't download the same "sub-dependencies" and it doesn't work at runtime. All of the log point to this library causing trouble...
Thanks!
I have found my answer but it was a long journey, let's begin:
First, Ebean is a complete other project than Play Framework and between Play Framework 2.1 and Play Framework 2.2, the version from Ebean changed from 3.1.2 to 3.2.2. I could not found any release note or documentation but I have found a post from the author in a google group discussion that stated clearly that he deleted the validation from the Ebean library because people should use JSR 303 bean validation instead. Since Ebean is a one man show, the decision seems final.
The problem with that is that the library that provide this said bean validation (javax for example) are not called when doing an update() or a save() which is a regression in our code.
After numerous reading and testing, we have finally created a BaseModel based on Model that override the save() and update() method by calling a validator manully, like this:
#MappedSuperclass
public class BaseModel extends Model {
#Override
public void save() {
Set<ConstraintViolation<BaseModel>> constraints = validate();
if (constraints.size() > 0 ) {
onFoundConstraints(constraints);
} else {
super.save();
}
}
#Override
public void update() {
Set<ConstraintViolation<BaseModel>> constraints = validate();
if (constraints.size() > 0 ) {
onFoundConstraints(constraints);
} else {
super.update();
}
}
private Set<ConstraintViolation<BaseModel>> validate() {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
return validator.validate(this);
}
private void onFoundConstraints(Set<ConstraintViolation<BaseModel>> constraints) {
String allErrors = "";
for (ConstraintViolation<BaseModel> constraint : constraints) {
allErrors += constraint.getRootBeanClass().getSimpleName()+
"." + constraint.getPropertyPath() + " " + constraint.getMessage();
}
throw new RuntimeException(allErrors);
}
}
All our object now extends this class and it work well so far. I don't know if the previous validation was doing anything more than that but for our needs, it is ok.
I hope it help others since the Play Framework migration documentation doesn't even talk about this...
Hi all,
at Can DropWizard serve assets from outside the jar file? I have read, that it is possible to serve static files outside of jar file with dropwizard-configurable-assets-bundle (later only DCAB).
But there are no examples available on the web. The only one, at their github page is not very helpful for me.
Firstly, there is said, that I should implement AssetsBundleConfiguration, but there is no mention where should I use it then.
Next, in service I should put this row:
bootstrap.addBundle(new ConfiguredAssetsBundle("/assets/", "/dashboard/"));
But unfortunately, it is showing me an error, that it is not applicable for that argument.
And in third part there is some yaml, but I don't know, whether it's produced by bundle, or whether I should put it somewhere.
And I noticed, that paths are relative to src/main/resources. Is there also option how to access files outside of that?
So the steps are pretty much like described in the README.md
You start with dependency
dependencies {
compile 'com.bazaarvoice.dropwizard:dropwizard-configurable-assets-bundle:0.2.0-rc1'
}
AssetBundleConfiguration interface needs to be implemented by you standard configuration file. So in my case:
public class BookRespositoryConfiguration extends Configuration
implements AssetsBundleConfiguration {
#Valid
#NotNull
#JsonProperty
private final AssetsConfiguration assets = new AssetsConfiguration();
#Override
public AssetsConfiguration getAssetsConfiguration() {
return assets;
}
}
This configuration is referred in you Application class
public class BooksRepositoryApplication
extends Application<BookRespositoryConfiguration> {
#Override
public void initialize(Bootstrap bootstrap) {
bootstrap.addBundle(new ConfiguredAssetsBundle("/assets/", "/books/"));
}
#Override
public void run(BookRespositoryConfiguration configuration,
Environment environment) throws Exception {
//...
}
}
And finally configuration. The configuration path is relative to the document-root, so in my case the assets are located outside the application folder.
assets:
overrides:
/books: ../book-repository
Now after running the app you can easily navigate to http://localhost:8080/books/some-static-files.html
Look at upto-date dropwizard-configurable-assets-bundle maintained at official dropwizard-bundles.
https://github.com/dropwizard-bundles/dropwizard-configurable-assets-bundle.