Gradle complains that it cannot convert long to int even when the method lasts as a parameter

When I started "gradle build", I had the following error with one of our projects, a couple of classes get the following compilation error:

cannot be applied to given types; this._logFilter.setFirstResult(firstResult); ^ required: int found: long reason: actual argument long cannot be converted to int by method invocation conversion 

Although the setFirstResult method accepts a long parameter. Here is the code:

 public void setFirstResult(long firstResult) { this._firstResult = firstResult; } 

I tried --refresh-dependencies and cleared the cache, etc. None of them worked for me. Also, this project was a maven project, I converted it instead of gradle.

Edit:

I am adding additional context here for the request from the comments:

Here is the source code for this._logFilter

 public class GlobalMessageLogFilter { private long _firstResult = 0L; private long _maxResults = 100L; private Application _application; private SeverityLevelEnum _severityLevel; private EnvironmentEnum _environment; private String _userName; private Category _category; public EnvironmentEnum getEnvironment() { return this._environment; } public void setEnvironment(EnvironmentEnum environment) { this._environment = environment; } public long getFirstResult() { return this._firstResult; } public void setFirstResult(long firstResult) { this._firstResult = firstResult; } public long getMaxResults() { return this._maxResults; } public void setMaxResults(long maxResults) { this._maxResults = maxResults; } public Application getApplication() { return this._application; } public void setApplication(Application application) { this._application = application; } public SeverityLevelEnum getSeverityLevel() { return this._severityLevel; } public void setSeverityLevel(SeverityLevelEnum severityLevel) { this._severityLevel = severityLevel; } public String getUserName() { return this._userName; } public void setUserName(String userName) { this._userName = userName; } public Category getCategory() { return this._category; } public void setCategory(Category category) { this._category = category; } } 

Here is a complete stack trace

 λ gradle build :compileJava C:\Java Source\wicket\administration\GlobalMessageLogProvider.java:36: error: method setFirstResult in class GlobalMessageLogFilter cannot be applied to given types; this._logFilter.setFirstResult(firstResult); ^ required: int found: long reason: actual argument long cannot be converted to int by method invocation conversion C:\Java Source\wicket\administration\GlobalMessageLogProvider.java:37: error: method setMaxResults in class GlobalMessageLogFilter cannot be applied to given types; this._logFilter.setMaxResults(maxResults); ^ required: int found: long reason: actual argument long cannot be converted to int by method invocation conversion C:\Java Source\wicket\administration\users\UserSecurityProvider.java:35: error: method setFirst in class UserSearchFilter cannot be applied to given types; this._filter.setFirst(first); ^ required: int found: long reason: actual argument long cannot be converted to int by method invocation conversion C:\Java Source\wicket\administration\users\UserSecurityProvider.java:36: error: method setCount in class UserSearchFilter cannot be applied to given types; this._filter.setCount(count); ^ required: int found: long reason: actual argument long cannot be converted to int by method invocation conversion 

Edit: Added GlobalMessageLogProvider source code

 public class GlobalMessageLogProvider extends SortableDataProvider<GlobalMessageLog, String> { @SpringBean private GlobalMessageLogRepository _globalMessageLogRepository; private GlobalMessageLogFilter _logFilter; private boolean _searchAllowed = false; public GlobalMessageLogProvider(GlobalMessageLogFilter globalMessageLogFilter) { Injector.get().inject(this); this._logFilter = globalMessageLogFilter; } @Override public Iterator<? extends GlobalMessageLog> iterator(long firstResult, long maxResults) { this._logFilter.setFirstResult(firstResult); this._logFilter.setMaxResults(maxResults); Iterator<GlobalMessageLog> results = Arrays.<GlobalMessageLog> asList().iterator(); if (this._searchAllowed) { if (super.getSort() == null) { results = this._globalMessageLogRepository.search(this._logFilter, "id", false).iterator(); } else { results = this._globalMessageLogRepository.search(this._logFilter, super.getSort().getProperty(), super.getSort().isAscending()).iterator(); } } return results; } } 
+6
source share
1 answer

I figured out this problem and I was able to solve it. A majority comment indicated that setFirstResult(int firstResult) is the wrong version of the class that it used. they are true.

Basically, GlobalMessageLogProvider been changed, but the latest version of jar has never been pushed to the Nexus server (our own private third-party dependency server). therefore, whenever I pull out a jug, it always refers to the old one.

After you push the last jar to the Nexus server manually, I was able to successfully execute the project with gradle without errors.

So, take your mind off this question: We need to create a build process that will automatically create / push the latest version of jar to the Nexus server. I am thinking of creating a build / push process through our TeamCity build server with some command / script. (Please feel free to give any improvement tips / advice, if any).

Thank you all for your kind help, I am sincerely grateful.

0
source

All Articles