I want to suppress a single Findbug warning ("passes a nonconstant String to an execute method on an SQL statement") by entering this line before the beginning of the method:
#edu.umd.cs.findbugs.annotations.SuppressWarnings(value = {"SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE", "SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" }, justification = "just a test")
But Eclipse keeps saying that edu cannot be resolved to a type and The attribute justification is undefined for the annotation type SuppressWarnings.
In the findbugs documentation i read that I have to add the annotations.jar and jsr305.jar in Java Build Path (in Project Propertes). But in the findbugs folder I cant find any .jar file. Only findbugs.xml, findbugs-excludes.xml and so on.
What can I do to get this running? I Use Findbugs maven plugin 2.5.2.
Thank you very much!
Download it and add to your classpath:
http://www.java2s.com/Code/Jar/a/Downloadannotations201jar.htm
Or use the official maven repository:
<dependency>
<groupId>findbugs</groupId>
<artifactId>findbugs</artifactId>
<version>1.0.0</version>
</dependency>
Link: http://mvnrepository.com/artifact/findbugs/findbugs/1.0.0
Or use this maven snippet:
<dependency>
<groupId>com.kenai.nbpwr</groupId>
<artifactId>edu-umd-cs-findbugs-annotations</artifactId>
<version>unknown</version>
</dependency>
Related
I am writing a junit test for my Jenkins groovy scripts. My Jenkins script that I am testing contains a method call like this:
error "Foo"
When I try to run the test from my IDE (Intellij IDEA) I get an error like this:
No signature of method: static xxx.error() is applicable for argument types: (org.codehaus.groovy.runtime.GStringImpl) values [Foo]
So I suppose, I need to add some library into my classpath to make this error function known to Runtime. I tried this maven dependency
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-aggregator</artifactId>
<version>2.5</version>
</dependency>
but it does't help.
So I am struggling to find what library contains these basic Jenkins workflow functions described in here: https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps
Any ideas?
The solution is to use Jenkins Pipeline Unit library that makes all those functions/methods like echo or error available and known to the pipeline context:
...
helper.registerAllowedMethod("echo", [String.class], null)
...
In this case every test should wrap-up the piece of code we are trying to test into a small jenkins script that will be executed by the JenkinsPipelineUnit engine.
The source is located here. So based on the pom I would say it's in the following dependency.
<!-- https://mvnrepository.com/artifact/org.jenkins-ci.plugins.workflow/workflow-basic-steps -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<version>2.24</version>
<scope>test</scope>
</dependency>
I have a simple maven project to do some SIF calls with MDM hub, and adding castor dependencies for this.
Maven dependency added:
org.codehaus.castor
castor-xml
1.4.1
This downloaded the castor-xml-1.4.1.jar file.
Right at the line calling sipClient.process(req) below exception is thrown
Exception in thread "main" java.lang.NoSuchMethodError: org.exolab.castor.xml.Marshaller.getResolver()Lorg/exolab/castor/xml/ClassDescriptorResolver;
at com.siperian.sif.message.CastorUtil.setMappingLoader(CastorUtil.java:470)
at com.siperian.sif.message.CastorUtil.beanToXmlString(CastorUtil.java:358)
at com.siperian.sif.message.CastorUtil.beanToXmlString(CastorUtil.java:323)
at com.siperian.sif.message.CastorUtil.beanToXmlString(CastorUtil.java:309)
at com.siperian.sif.message.CastorUtil.beanToXmlString(CastorUtil.java:295)
at com.siperian.sif.client.HttpSiperianClient._process(HttpSiperianClient.java:117)
at com.siperian.sif.client.SiperianClient.process(SiperianClient.java:179)
I can see the getResolver method and classDescriptorResolver in the jar file in Java Decompiler, Images
classResolverDescriptor
getResolver method
Same exception even for 1.3.2 dependency.
Should I download any extra dependencies.
Thanks
This specific error for 2 reasons:
1- You are missing the jar file that has this method (This might not be the issue you have, as you stated you can see it when looking at the decompiled jar)
2- You have 2 or more jars in your dependencies, and it is actually looking at the jar which does not have the method you need.
How you should approach this is as follows:
Go to your ide, and open your pom.xml file
Open the Dependency Heirarchy view and search for org.codehaus.castor or castor-xml and see how many different versions you have.
If you have more than 1, and some are included as part of another jar, you can use in your pom.xml to remove the versions which you dont want.
If you like command line you can probably do the above, using mvn dependency:tree
Hope this helps you in some way.
-- Edited --
Your code is using 1.3.2 dependency. How? You can download the castor-xml.1.3.2.jar and extract it and look into the Marshaller. You will see the method getResolver() does not take any parameters, and therefore you get NoMethodFound.
´´´
/**
* Returns the ClassDescriptorResolver for use during marshalling
*
* #return the ClassDescriptorResolver
* #see #setResolver
*/
public XMLClassDescriptorResolver getResolver() {
}
´´´
Therefore you need to find out in your dependency hierarchy, will one includes this 1.3.2 jar and exclude this jar from it.
An example of how to do exclude is in pom.xml:
<dependency>
<groupId>sample.group.which.has.castor.in.it</groupId>
<artifactId>artifactor.which.has.castor.in.it</artifactId>
<version>1.0</version>
<scope>compile</scope>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>org.codehaus.castor</groupId>
<artifactId>castor-xml</artifactId>
<version>1.3.2</version>
</exclusion>
</exclusions>
</dependency>
<dependency> <!-- add proper dependency also, as it is needed -->
<groupId>org.codehaus.castor</groupId>
<artifactId>castor-xml</artifactId>
<version>1.4.1</version>
</dependency>
I have been doing my project and all the sudden eclipse started to give this error saying
The type com.google.protobuf.GeneratedMessageV3$Builder cannot be resolved.
It is indirectly referenced from required .class files where we declare the package. I have tried adding com.google.protobuf-2.4.0.jar to build path but it did not work. Please help and here's the screenshot.
com.mysql.cj.x.protobuf.MysqlxSql.StmtExecute is not on the classpath so remove this import
If you are expecting Protobuf generated files to be available, then ensure that you have added the Protobuf library to your project.
Gradle example:
implementation group: 'com.google.protobuf', name: 'protobuf-java', version: googleProtobufVersion
Maven example:
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>${googleProtobufVersion}</version>
</dependency>
Not sure if this helps at such a later date. But i also faced something similar.
I found that I imported this by mistake
import com.mysql.cj.x.protobuf.MysqlxDatatypes.Array;
After removing this line, it works fine.
In your case you need to remove the import
com.mysql.cj.x.protobuf.MysqlxSql.StmtExecute
Replace it with the relevant import.
This is due to the missing dependency of gRPC protobuf. Add this dependency to your pom.xml and this should solve your problem.
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.16.1</version>
</dependency>
Lastly, do maven -> project update
I'm working in a GWTP + GAE project based on the CarStore example delviered by ArcBees. Maven dependencies are taken from that project too. My current version of GWTP is 1.5-SNAPSHOT.
The project compiles perfectly well. But when I run it, I'm stucked in this error:
[ERROR] Error injecting com.gwtplatform.dispatch.rest.delegates.client.ResourceDelegate<com.rmideas.sportbinder.shared.api.SessionResource>:
Unable to create or inherit binding: No #Inject or default constructor found for com.gwtplatform.dispatch.rest.delegates.client.ResourceDelegate<com.rmideas.sportbinder.shared.api.SessionResource>
The error refers to the ResourceDelegate declared in LoginPresenter. But i can´t find anything wrong in my code.
I analyzed the stacktrace and found this cause:
[INFO] Caused by: java.lang.NoSuchMethodError: com.gwtplatform.dispatch.rest.rebind.events.RegisterGinBindingEvent.postSingleton(Lcom/google/common/eventbus/EventBus;Lcom/gwtplatform/dispatch/rest/rebind/utils/ClassDefinition;Lcom/gwtplatform/dispatch/rest/rebind/utils/ClassDefinition;)
[INFO] at com.gwtplatform.dispatch.rest.delegates.rebind.DelegateGenerator.maybeRegisterGinBinding(DelegateGenerator.java:162)
This refers to a call between two Class objects. DelegateGenerator is the caller and is obtained from this dependency:
<dependency>
<groupId>com.gwtplatform.extensions</groupId>
<artifactId>dispatch-rest-delegates</artifactId>
<version>${gwtp.version}</version>
<scope>provided</scope>
</dependency>
And RegisterGinBindingEvent is the receiver. It belongs to here:
<dependency>
<groupId>com.gwtplatform</groupId>
<artifactId>gwtp-dispatch-rest</artifactId>
<version>${gwtp.version}</version>
<scope>provided</scope>
</dependency>
Now, this happens in line 162 of DelegateGenerator:
RegisterGinBindingEvent.postSingleton(eventBus, definition, getClassDefinition());
This shouldn't be a problem, but the key the eventBus sends as the first parameter is of a different type in both classes.
DelegateGenerator has this import statement:
import com.google.common.eventbus.EventBus;
And RegisterGinBindingEvent has this EventBus class:
import com.gwtplatform.dispatch.rest.rebind.utils.EventBus;
I guess that this is causing the problem. Both dependencies are using the same version (1.5-SNAPSHOT). If I downgrade the version to 1.4, this won´t happen. But it still has issues running ResourceDelegate with this code.
Does anyone know what am I be doing wrong? Or if this is a bug?
Thanks for using the snapshots.
For some reason the CI didn't deploy a snapshot for the last commits. This should now be fixed. Can you try another build? Add -U to your maven command line to make sure you grab the latest snapshot.
I am trying to compile my JasperReports template using an Ant script and Java. I am getting this error:
jasper java.lang.NoClassDefFoundError:
org/codehaus/groovy/control/CompilationFailedException
There is nothing complex in the template, but I still can't compile.
You will have to set the language value in your template to Java. There are two ways you can do this:
If you are using iReport, select the root object in your Report Inspector (the one with the same name as your report). Then in the Properties window, select Java from the Languages drop-down.
If you are editing the raw mark-up in the JRXML file, remove language="groovy" from the file altogether.
Then try to recompile - you should be sorted. :)
If you are using Maven, you must add the groovy dependency in your pom.xml.
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.10</version>
</dependency>
In another case, you must add the library groovy in your lib folder (WEB-INF/lib)
Another solution is to copy groovy-all-{version}.jar from the groovy binary distribution into the application's.
If you are using TIBCOJaspersoftStudio:
Download latest groovy 2.4.* jar from https://groovy.apache.org/download.html
Unpack and get this file ./groovy-2.4.10/embeddable/groovy-all-2.4.10.jar
Put the jar in ./TIBCOJaspersoftStudio-6.3.1.final/plugins
Delete the old jar: ./TIBCOJaspersoftStudio-6.3.1.final/plugins/groovy-all_2.4.5.jar
Change the languge to java in JRXML (ex:- language="java") or add groovy*.jar to your project’s classpath.
Your are missing the a important library groovy in path.
case 1 : if you are using Maven add this dependency with compatible version in pom.xml
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>3.0.4</version>
</dependency>
Case 2 : Second way is add the compatible version of groovy jar in class path
Url to download groovy jar : http://groovy-lang.org/download.html