Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnsolvedSymbolException{context='null', name='JpaRepository', cause='null'} #86

Open
Lyannic opened this issue Mar 6, 2019 · 12 comments

Comments

@Lyannic
Copy link

Lyannic commented Mar 6, 2019

Hello,
when I try to execute the cvReport task for a project that contains JpaRepositories, I get the following exception:

Exception initializing Code Visualizer
UnsolvedSymbolException{context='null', name='JpaRepository', cause='null'}
at com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserInterfaceDeclaration.toReferenceType(JavaParserInterfaceDeclaration.java:342)
at com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserInterfaceDeclaration.getAncestors(JavaParserInterfaceDeclaration.java:250)
at com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration.getAncestors(ResolvedReferenceTypeDeclaration.java:69)
at com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserInterfaceDeclaration.getAllFields(JavaParserInterfaceDeclaration.java:185)
at com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration.getDeclaredFields(ResolvedReferenceTypeDeclaration.java:191)
at io.sitoolkit.cv.core.domain.classdef.javaparser.ClassDefReaderJavaParserImpl.readFieldDefs(ClassDefReaderJavaParserImpl.java:306)
at io.sitoolkit.cv.core.domain.classdef.javaparser.ClassDefReaderJavaParserImpl.lambda$readJava$4(ClassDefReaderJavaParserImpl.java:131)
at java.util.Optional.ifPresent(Optional.java:183)
at io.sitoolkit.cv.core.domain.classdef.javaparser.ClassDefReaderJavaParserImpl.readJava(ClassDefReaderJavaParserImpl.java:128)
at io.sitoolkit.cv.core.domain.classdef.javaparser.ClassDefReaderJavaParserImpl.lambda$readDir$2(ClassDefReaderJavaParserImpl.java:84)
at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1603)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
at io.sitoolkit.cv.core.domain.classdef.javaparser.ClassDefReaderJavaParserImpl.readDir(ClassDefReaderJavaParserImpl.java:75)
at io.sitoolkit.cv.core.app.designdoc.DesignDocService.analyze(DesignDocService.java:74)
at io.sitoolkit.cv.core.app.config.ServiceFactory.initialize(ServiceFactory.java:54)
at io.sitoolkit.cv.core.app.config.ServiceFactory.createAndInitialize(ServiceFactory.java:49)
at io.sitoolkit.cv.plugin.gradle.ReportTask.export(ReportTask.java:12)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:566)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:801)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:768)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)
at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:277)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:262)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:834)

When I delete the JpaRepositories from the project, everything works fine. Do you have any idea, why it can't handle them?

Thank you in advance for any help.

@kfujinuma
Copy link
Contributor

Thank you for your report.
We will reproduce the problem and check it.
Is JpaRepositories of your project that of spring-data-jpa?

@Lyannic
Copy link
Author

Lyannic commented Mar 7, 2019

Yes, my Repository-Interfaces are extending the one of spring-data-jpa.

@kfujinuma
Copy link
Contributor

Unfortunately, I could not reproduce the same exception in a project using JpaRepository. However, in your project, I think that SIT-CV could not grasp the dependence on spring-data-jpa.
So would you show us the build.gradle if possible so that we can reproduce the failure of that dependency?

@Lyannic
Copy link
Author

Lyannic commented Mar 11, 2019

Originally my build.gradle looked like this:

buildscript {
	repositories {
		mavenCentral()
	}
}

plugins {
	id 'io.spring.dependency-management' version '1.0.7.RELEASE'
	id 'io.sitoolkit.cv.sit-cv-gradle-plugin' version '1.0.0-beta.2'
}

project.ext {
	springBootVersion = '2.1.2.RELEASE'
}

group = 'net.my.group'

allprojects {
	version = '0.0.1-SNAPSHOT'
}

subprojects {
	repositories {
		mavenCentral()
	}
	apply plugin: 'java'
	apply plugin: 'io.spring.dependency-management'
	group = 'net.my.group.project'
	sourceCompatibility = '11'
	dependencies {
		implementation 'org.springframework.boot:spring-boot-starter-web'
	}
	dependencyManagement {
		imports { mavenBom("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") }
	}
}

configure(subprojects - project(':docs')) {
	dependencies {
		implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
		implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.9.8'
		runtimeOnly 'org.springframework.boot:spring-boot-devtools'
		runtimeOnly 'org.postgresql:postgresql'
		testImplementation 'org.springframework.boot:spring-boot-starter-test'
		testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
	}
}

But I also tried to make all dependencies available to all projects using this modified version:

buildscript {
	repositories {
		mavenCentral()
	}
}

plugins {
	id 'io.spring.dependency-management' version '1.0.7.RELEASE'
	id 'io.sitoolkit.cv.sit-cv-gradle-plugin' version '1.0.0-beta.2'
}

project.ext {
	springBootVersion = '2.1.2.RELEASE'
}

group = 'my.group'

allprojects {
	repositories {
		mavenCentral()
	}
	apply plugin: 'java'
	apply plugin: 'io.spring.dependency-management'
	version = '0.0.1-SNAPSHOT'
	sourceCompatibility = '11'
	dependencies {
		implementation 'org.springframework.boot:spring-boot-starter-web'
		implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
		implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.9.8'
		runtimeOnly 'org.springframework.boot:spring-boot-devtools'
		runtimeOnly 'org.postgresql:postgresql'
		testImplementation 'org.springframework.boot:spring-boot-starter-test'
		testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
	}
	dependencyManagement {
		imports { mavenBom("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") }
	}
}

subprojects {
	group = 'my.group.project'
}

@Lyannic
Copy link
Author

Lyannic commented Mar 11, 2019

I just noticed that the bootJar task of my two spring-boot-apps in this multi module project fail when I use your plugin in my project.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':docs:bootJar'.
> java.lang.IllegalArgumentException (no error message)

When I just remove the plugin (id 'io.sitoolkit.cv.sit-cv-gradle-plugin' version '1.0.0-beta.2'), it works again. So this might be some kind of dependency problem, because your project relies on Spring Boot aswell.

@kfujinuma
Copy link
Contributor

UnsolvedSymbolException has been reproduced in my environment. The cause seems to be a bug of SIT-CV. I have fixed it, so please try the following fixed version to see if the problem is solved.
https://github.com/sitoolkit/sit-cv/tree/feature/fix_unsolvedsymbol

git clone -b feature/fix_unsolvedsymbol https://github.com/sitoolkit/sit-cv.git
cd sit-cv
mvnw install
cd sit-cv-gradle-plugin
gradlew install

build.gradle

buildscript {
  repositories {
    mavenlocal()
  }
  dependencies {
    classpath "gradle.plugin.io.sitoolkit.cv:sit-cv-gradle-plugin:1.0.0-beta.4-SNAPSHOT"
  }
}
apply plugin: "io.sitoolkit.cv.sit-cv-gradle-plugin"

@kfujinuma
Copy link
Contributor

kfujinuma commented Mar 15, 2019

Also, can you try to see if bootJar also fails when using the above plug-in version? (1.0.0-beta.4-SNAPSHOT uses a newer version of Spring)

@Lyannic
Copy link
Author

Lyannic commented Mar 20, 2019

You also need to have the com.sun:tools:1.5.0 jar in $JAVA_HOME/../lib and the gradle install tasks puts the plugin to ".m2/repository/io/sitoolkit/cv/sit-cv-gradle-plugin/1.0.0-beta.4-SNAPSHOT", but gradle looks for it in ".m2/repository/gradle/plugin/io/sitoolkit/cv/sit-cv-gradle-plugin/1.0.0-beta.4-SNAPSHOT".

After sorting this out, the cvReport task and the bootJar tasks run without any problem.

Thank you.

@Lyannic Lyannic closed this as completed Mar 20, 2019
@Lyannic
Copy link
Author

Lyannic commented Aug 1, 2019 via email

@ykuwahara
Copy link
Member

@Lyannic We released v1.0.0-beta.4 just today!

@Lyannic
Copy link
Author

Lyannic commented Aug 4, 2019 via email

@Lyannic
Copy link
Author

Lyannic commented Jun 21, 2022

I didn't manage to try out the official release till now. But I get the same error with 1.1.1 and also with the official 1.0.0-beta.4.

@Lyannic Lyannic reopened this Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants