I try to work with JMeter 3.2 source but it's not compiling, It was missing mainly Bouncy Castle jars I added jars but still getting an error:
SMIMEAssertion.java include constructor SMIMESignedParser(BcDigestCalculatorProvider, MimeMultipart) which doesn't exists in JMeter's lib, Code failing:
s = new SMIMESignedParser(new BcDigestCalculatorProvider(), multipart);
s = new SMIMESignedParser(new BcDigestCalculatorProvider(), msg);
I added different jars of Bouncy Castle as latest bcprov-jdk15on-158.jar to older versions bcmail-jdk14-1.46.jar or others as bcpkix-jdk15on-1.55 or bcmail-jdk15-140.jar but still failed to compile
Does anyone knows the correct jars to add?
JMeter uses "ant" to build.
Based on https://github.com/apache/jmeter it looks like they use Travis to build and test (probably on Github).
Based on
before_script:
- test "x$RUN_CHECKSTYLE" != 'x' || ant -Djava.awt.headless=true download_jars install
(https://github.com/apache/jmeter/blob/trunk/.travis.yml)
it appears that you should run
ant download_jars
to get the jars you need. Locate them and add them to your build path.
(And this stuff is exactly why projects are typically migrating to Maven)
Edited in by other user after I wrote it:
Full explanation for building is here:
http://jmeter.apache.org/building.html
A PR of migration to maven is available and should be merged after 3.3 release.
Related
I'm (almost) a beginner in plugin creation (I created one a long time ago) and I would like to create a plugin that works BOTH with IntelliJ and with Android Studio (this to start with, because later I would like it to work also for Webstorm, PyCharm...).
The principle of my plugin is to use the parsing provided by IntelliJ (for Java for the moment, later for Kotlin, PHP...) thanks to the PSI (I MUST use PSI!). I've spent days reading and testing information at https://plugins.jetbrains.com/docs/intellij , https://plugins.jetbrains.com/docs/intellij/android-studio.html (and so on) and online tutorials, but I still can't configure my project (even before coding it).
Can you help me?
Here are some information:
I created the plugin ('empty' plugin for now) from the github template presented the online documentation. No problem for that.
I use a JDK 11. I guess this is what I have to do now (unlike before when I had to use the IntelliJ JDK).
I want to code my plugin in Java (not in Kotlin). The template generated Kotlin code (MyBundle.kt, listeners, services...) but I don’t need these Kotlin files. What to write to replace this code in Java ?
I don't know Kotlin (or very very little) and I usually develop in Java with Android Studio and Gradlen and I want to keep the build.gradle.kst (better than build.gradle).
I must also use a personal .jar file (not a lib like JSON for instance) for my plugin to work. Do I only have to add this jar in the libraries of the 'project settings' or do I have to do something else?
Here is my current configuration (most interesting parts):
plugin.xml (with error)
<depends>com.intellij.modules.lang</depends>
<depends>com.intellij.modules.java-capable</depends> // correct ?
<depends>com.intellij.modules.androidstudio</depends> // error : cannot resolve plugin in dependencies
<depends>org.jetbrains.android</depends> // error : cannot resolve plugin in dependencies
build.gradle.kts (with questions)
plugins {
// Java support
id("java")
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij") version "1.4.0"
// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "1.3.1"
// Gradle Qodana Plugin
id("org.jetbrains.qodana") version "0.1.13"
}
...
configurations {
create("externalLibs")
}
dependencies {
// to integrate my personal jar file , correct ?
"externalLibs"(files("lib/myfile.jar"))
// to integrate an external API , correct ?
implementation("com.foo.api-java-sdk:1.0.2")
}
gradle.properties (with questions)
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
pluginSinceBuild = 211
pluginUntilBuild = 213.*
# IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
platformType = IC
#platformVersion = 2021.1.3
platformVersion = 211.7628.21 // to be compatible between IJ and Android Studio, OK ?
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins = com.intellij.java, org.jetbrains.android // is it correct ????
# Java language level used to compile sources and to generate the files for - Java 11 is required since 2020.3
javaVersion = 11
# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 7.4
If someone could give me the right configuration for all these files, it would be fine because I am totally lost and hopeless :-(
Thank you.
While executing tests in Maven Surefire I see ClassNotFoundExceptions from time to time.
This really gives me a headache, since:
the missing classes vary. Only around 5 classes are affected, but which one it is varys from build to build. However, I see no unique similarities between these classes, which they wouldn't share with 20 other classes of the same kind.
These missing classes come from 2 different dependencies. These are managed by Maven, of course.
When a CNFE is raised I had a look at the class path (during runtime!) and it looks fine!
How I analysed the class path
I took the code of the "class path scanner" from Arno Haase:
public List<URL> getRootUrls () {
List<URL> result = new ArrayList<> ();
ClassLoader cl = Thread.currentThread().getContextClassLoader();
while (cl != null) {
if (cl instanceof URLClassLoader) {
URL[] urls = ((URLClassLoader) cl).getURLs();
result.addAll (Arrays.asList (urls));
}
cl = cl.getParent();
}
return result;
}
The list of URLs is quite short:
a few JRE libs
a "surefire booter jar"
The latter jar bundles all my Maven dependencies in its Manifest file, as described in the Surefire docs.
So I dug further and analysed the "Class-Path" attribute of the manifest. There I found the dependent jar listed, where the missing class should have come from.
When browsing through the jar's entries, I also found the missing class there. The fully qualified path also matches.
So in principle everything seems to be correct and in place.
Where should I continue to investigate now?
There are several things to check for problems like these.
Does this happen from command line or via CI build only? If using Jenkins or Hudson, is this a Maven project or a FreeStyle project with a Maven build step? If this is a Maven project, switch it to a FreeStyle project with a Maven build step, and that just may solve the issue. Stephen Connolly of the Maven team considers the Jenkins Maven build type evil.
Ensure there is only one version of each dependency and that related dependencies (Spring, ASM, Hibernate, etc.) have the same/compatible versions. Pay particular attention to artifacts where the group ID or artifact ID has changed, for example spring.jar vs. spring-core.jar. The old Tattletale plugin might be useful to get started.
Replace any dependencies ending in -all with their component parts. -all jars may contain every class needed to run the library - repackaged into the jar file where Maven's dependency resolution process can't get at them - instead of referencing them as dependencies. mockito-all, hamcrest-all, powermock-all, cglib are examples.
If using coverage tools (Jacoco, Clover) does the build work if you turn off the coverage? If yes, the tool may be introducing classpath jars that conflict with your app's. (Different version of CGLIB for example.) Run in debug mode and compare dependencies with/without coverage to identify the differences.
If using JUnit, make sure Maven surefire is using the right JUnit provider for your version of JUnit. Run the build in debug mode with -X (redirect output to a file if using command line). Grep the output for surefire-junit. You should find something like this:
[DEBUG] org.apache.maven.surefire:surefire-junit4:jar:2.16:test (selected for test)
Now, make sure the version of the provider matches the version of JUnit used. Check out the Maven docs for information on which provider to use and how to configure.
I have an archetype that we use to create new projects. At the point of project creation (i.e. when someone executes mvn archetype:generate) I want to pin some of the dependencies to RELEASE version available at that time (I strongly oppose putting <version>RELEASE</version> in POM file).
Is there a way I can make archetype to resolve RELEASE version and pin that for some of the libraries.
Only way I solve this problem right now is by releasing new version of archetype every time some of the core libraries are released and then hard coding versions of those in the archetype-resources/pom.xml
I did see couple of similar questions but none of the solutions for those work for me.
As I already mentioned, that I want to pin the latest release version available at the time of creating project from archetype. Using `RELEASE means that I can not recreate binaries from same source code as I will end up fetching a different version of dependency.
Let me explain with concrete example.
I have an archetype with maven co-ordinate com.my-company:my-awesome-framework:1.0.
I have a library with maven co-ordinates com.my-company:core-lib:1.0.
Developer-1 runs command mvn archeype:generate my-awesome-framework. He fills in required details and creates project called service-foo. service -foo has dependency core-lib and since.
We add more features to core-lib and release version 2.0
Developer-1 build service-foo it still builds with core-lib version 1.0. (since he hasn't changed the version the project's POM file. Had I used <version>RELEASE<version> for 'core-lib, this timeservice-foowould have built with version2.0of thecore-lib`)
Devloper-2 runs mvn archetype:generate my-awesome-framework. He fills out required fields and creates a service called service-bar. Now this time since core-lib version 2.0. Note that I did not modify my-awesome-archetype to update version for core-lib inside archetype-resources\pom.xml
I hope this clarifies my use case
I solved this using archetype-post-generate.groovy, script. Maven archetype plugin executes that (if available) after the project has been created. There one can use Maven versions plugin to update to the latest releases.
Here is an example how you can update both versions in properties and in parent project (in Spring Boot in this case):
dir = new File(new File(request.outputDirectory), request.artifactId)
def run(String cmd) {
def process = cmd.execute(null, dir)
process.waitForProcessOutput((Appendable)System.out, System.err)
if (process.exitValue() != 0) {
throw new Exception("Command '$cmd' exited with code: ${process.exitValue()}")
}
}
run("echo 'Updating to latest Vaadin version...'")
run("mvn versions:update-properties")
run("echo 'Updating to latest Spring Boot version...'")
run("mvn versions:update-parent")
The downside is that Eclipse don't seem to execute that script, but in other major IDEs and command line this work just fine.
The groovy script form my Vaadin + Spring Boot archetype in GitHub.
I'm trying to make examples from grpc-java work.
It's indeed easy if I'm using gradle, however, I'm going to integrate grpc into the project that uses another build system.
I would like to know how to compile and run examples using only protoc, javac and java.
I'm able to generate java sources from .proto sources, but no luck compiling the generated java sources.
I tried 1000 combinations (different classpathes), but nothing works.
> javac RouteGuideGrpc.java
< RouteGuideGrpc.java:3: error: package io.grpc.stub does not exist
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
(99 other compile errors were omitted)
Could anyone show a sequence of commands that will work?
Thank you.
Upd: I'm doing this on Linux.
Upd: I'm using SBT, but it really does not matter. What I really want to understand is how to use javac to compile generated grpc code.
I'm sure I have grpc-core, grpc-netty, grpc-protobuf and grpc-stub in classpath (actually, not sure in anything at this point...).
I actually faced a couple of problems myself trying to migrate from Gradle to SBT.
First you should take advantage of sbt-protobuf plugin which compiles .proto files for you. Make sure to:
Set the path and version of your protoc:
version in PB.protobufConfig := "3.0.0"
protoc in PB.protobufConfig := PATH_PROTOC
If needed set the location of your .proto files (default is src/main/protobuf):
sourceDirectory in PB.protobufConfig := baseDirectory.value / "src" / "main" / "proto"
Finally, set extra options of protoc used by grpc-java. First options sets the path for your protoc-gen-grpc-java plugin bin; and second sets the output path of grpc-java to the same as sbt-protobuf:
protocOptions in PB.protobufConfig ++= Seq(
"--plugin=protoc-gen-grpc-java=" + PATH_GRPC_JAVA_PLUGIN,
"--grpc-java_out=" + baseDirectory.value + "/target/src_managed/main/compiled_protobuf")
I ended up putting a repository with all of this sorted out. Here it is, hope it helps!
The package io.grpc.stub is part of the grpc-stub artifact. To build the code generated component, you need at least protobuf-java, grpc-stub, grpc-protobuf, and grpc-core in your classpath. Depending on how you are compiling, you may also need any protobuf generated classes (the grpc-generated stubs depends on the protobuf-generated protos).
There is documentation for running the code generator manually in the compiler directory, but it doesn't include running javac.
If you continue having problems, double-check that the protoc compiler and protobuf-java have the same version, and protoc-gen-grpc-java and the grpc JARs have the same version.
Ok, I was able to resolve compile-time issues.
I ended up inserting println statements into the build.gradle files that come with grpc to see the actual class-path that is used when compiling those examples.
It turned out that grpc libs had versions 0.9.0, while in my sbt build I was referring to 0.7.2.
Just today libs of version 0.8.0 were put to the maven repository and when I change the version from 0.7.2 to 0.8.0 everything works as expected.
I'm strugling with using jackson-dataformat-xml on android
I have some very basic code that works fine on oracle jre
JacksonXmlModule module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
XmlMapper xmlMapper = new XmlMapper(module);
First I tried official documentation adapted for gradle (by me, not sure if done correctly):
compile 'com.fasterxml.jackson.core:jackson-core:2.5.4'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.5.4'
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.4'
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.5.4'
compile 'org.codehaus.woodstox:woodstox-core-asl:4.4.1'
compile 'javax.xml.stream:stax-api:1.0-2'
Result: gradle fails build time about bundling corelibraries into an application
...
:app:preDexDebug
trouble processing "javax/xml/stream/EventFilter.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
...
2nd attempt trying to follow Sean's answer
(Basicly he repackages corelibs with prefix names and rebuilds jackson-dataformat-xml to use the prefixed names)
compile 'com.fasterxml.jackson.core:jackson-core:2.1.2'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.1.2'
compile 'com.fasterxml.jackson.core:jackson-databind:2.1.2'
// Repackaged XML-specific libraries
compile 'edu.usf.cutr.android.xml:jackson-dataformat-xml-android:2.1.2'
compile 'edu.usf.cutr.android.xml:stax2-api-android:3.1.1'
compile 'edu.usf.cutr.android.xml:stax-api-android:1.0-2'
compile 'edu.usf.cutr.android.xml:aalto-xml-android:0.9.8'
And build time failed on duplicates
Duplicate files copied in APK META-INF/services/com.fasterxml.jackson.core.ObjectCodec
so added:
packagingOptions {
...
exclude 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
exclude 'META-INF/services/com.fasterxml.jackson.core.ObjectCodec'
}
When adding the exclusions it builds and deploys, but fails runtime on below stackdump (AFAIK it cant find the SAX provider, even tho it is added to the classpath to my understanding)
edu.usf.cutr.javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.MXParserFactory not found
at edu.usf.cutr.javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
at edu.usf.cutr.javax.xml.stream.FactoryFinder.find(FactoryFinder.java:176)
at edu.usf.cutr.javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
at edu.usf.cutr.javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136)
at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:97)
at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:85)
at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:82)
at com.fasterxml.jackson.dataformat.xml.XmlMapper.<init>(XmlMapper.java:46)
What is the proper way to move forward on either #1 or #2?
Number 2 is the correct approach (Android doesn't like it when you include classes in the official Java package namespace - but then again, I wrote the original answer so I'm biased ;) ).
I believe the FactoryConfigurationError: Provider com.bea.xml.stream.MXParserFactory not found error is due to a bug in the Android build tools. In previous versions of ADT for Eclipse and Gradle plugin < 0.7.0 the /META-INF/* files are stripped from the JARs during the build process. It seems like >= v0.7.0 shouldn't have the problem according to Google, but from others' reports it sounds like it still may be problematic, and could potentially remove the META-INF/services/javax.xml.stream.XMLInputFactory file, which is required for the platform to register Aalto.
Try the workaround mentioned in AOSP issue 59658 comment 22:
right click on /src/main (where you have /java and /res folders),
select New > Folder > Java Resources Folder,
click Finish (do not change Folder Location),
right click on new /resources folder,
select New > Directory
enter "META-INF" (without quotes),
right click on /resources/META-INF folder,
select New > Directory
enter "services" (without quotes)
copy any file you need into /resources/META-INF/services
For you, in step 10 above you'd need to copy this file into /resources/META-INF/services. In case the file link is broken in the future, the name of the file is javax.xml.stream.XMLInputFactory and it consists of a single line:
com.fasterxml.aalto.stax.InputFactoryImpl
EDIT
If you get a "Error:duplicate files during packaging of APK... Path in archive: META-INF/services/javax.xml.stream.XMLInputFactory", you can try telling Gradle to keep the first occurrence with:
android {
packagingOptions {
pickFirst 'META-INF/services/javax.xml.stream.XMLInputFactory'
}
}
EDIT 2
This bug may be affecting "pickFirst". Please make sure you're running the latest version of Android Studio, and update your local tools and Android Gradle plugin to make sure you're running the most recent version of the tools. This may be fixed in Android Studio 1.3 RC1.
I have attempted to add XmlPull support to jackson xml. Find the forked project here:
https://github.com/finvu/jackson-dataformat-xml
Currently, only supported for version 2.9.6. (clone the branch jackson-dataformat-xml-2.9.6-XmlPull)
Sorry, I am not able to provide detailed documentation due to time constraints. If you have knowledge of git and maven to pull a specific branch and build the jar, then it should be relatively easy.
To those who will be in need of this in the future:
first integrate Jitpack in Your Android app, following their instructions:
https://jitpack.io/
Then paste teh GitHub url of jackson-dataformat-xml on Jitpack sites' corresponding text box. GitHub url is:
https://github.com/FasterXML/jackson-dataformat-xml.
That's it! Enjoy the result. :)