Has anyone successfully built QuickFIX/J with IntelliJ IDE, importing Maven project structure? - quickfixj

I ask this question because it sort of builds but not really.
The core module could not be built; it is missing the Field classes.
I do not know how to make the builder generate these classes. I added some dependencies to point to JAR files that were included in folder \org.quickfixj-2.0.0-bin\org.quickfixj-2.0.0 which came prebuilt. I then no longer get a build problem for module core.
Next, I get errors on anything having to do with a test. I try to build the example Banzai. It complains:
Error:(35, 22) java: package quickfix.field does not exist
for lines like
import quickfix.field.AvgPx;
Environment:
IntelliJ 2017.2.5
QuickFixJ QFJ_RELEASE_2_0_0 2017-11-22

Related

Grails Project missing Java library at runtime

I was trying to add some Java Libraries (AWS SDK for Java, Apache Commons Math, etc.) to my Grails project since some of my Java source code (placed in src/java) had dependencies. By following this answer, I was able to resolve compile errors by adding the jar files to the /lib folder and add it to the build path, as answered here: Add Java Libraries to a Netbeans Grails Project
However, when I call my Java source code from my controller during runtime, it is unable to find the Java libraries that I added, showing a NoClassDefFoundError. Should I be adding something to the BuildConfig.groovy file? I'm not sure what the name convention for the jar files to be added to the dependencies.
The question you refer to is 5 years old. You should use newer resources :)
The preferred approach now is to use dependencies in BuildConfig.groovy, and let Grails (via Ivy or Maven) download the jars for you once and reuse them for various projects.
It's not always obvious what the syntax is, and I find that http://mvnrepository.com/ is a great resource. For example if you search for "commons math" and click through to http://mvnrepository.com/artifact/org.apache.commons/commons-math you'll see a few versions. Click on version 2.2 and you'll see the Maven dependency XML but you can click on the Gradle tab and it's going to be similar to what you need for Grails. So I'd add
dependencies {
compile 'org.apache.commons:commons-math:2.2'
}
and if necessary change compile to runtime, build, etc. depending on what you need the jar in the build process.
In the rare case that you do have a jar that isn't available in a Maven repo (e.g. a shared library at your company) then you can put the jar file in the lib directory. As you've seen, Grails doesn't auto-detect it (this is as of version 2.0). But you can run grails compile --refresh-dependencies to get your jar added to the classpath.
My issue turns out to be the fact that AWS Java SDK had dependencies (Apache HTTP Client) that were not installed yet and that I was unaware of.
This is what I had to configure this for my BuildConfig.groovy file
dependencies {
runtime 'org.apache.httpcomponents:httpclient:4.2.5'
runtime 'com.amazonaws:aws-java-sdk:1.4.7'
}
All the dependencies for AWS Java SDK 1.4.7 can be found here: http://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk/1.4.7. All the dependencies outside of HTTP client were already installed for me, but may not be for your Grails setup.

is sonar multi-module broken?

trying to make a multi module project I dowloaded the samples in github: I use this folder
https://github.com/SonarSource/sonar-examples/tree/master/projects/multi-module/sonar-runner/java-sonar-runner-modules-own-configuration-file as a project base dir
In a command line in this folder, I type /opt/sonar-runner/bin/sonnar-runner
First thing I find is that sonar-project.properties has a property named sonar.sources=src, but executing throws
Exception in thread "main" org.sonar.runner.RunnerException: You must define mandatory properties: sources
Then I correct this property with sources=src and runner execution finish, adds the project to my sonar server, but no code, modules or file is detected. It is like if all project is empty.
It is exactly the same with other examples and with my own project. No matter if is java, python...
Any help is welcome
You are using an old version of Sonar Runner and/or Sonar. Please update to the latest versions (Sonar Runner 2.2 and Sonar 3.5.1).

Grails can't find classes in jars

I have an app in Grails that uses a .java to manage paypal MassPay feature. Like many .java, it needs some jars that enclose the classes that jar uses. Ok, i import that jars and the errors in the .java dissapears. But now, when I try to run the app, i receive 25 messages like this:
myapproute/grails-app/controllers/com/mycompany/widget/MassPay.java:3: package com.paypal.sdk.profiles does not exist
import com.paypal.sdk.profiles.APIProfile;
That file in the MassPay.java does not throw any error, since i imported the jar where that class is enclosed. But it doesn't allow me to run the project.
Any help? thanks.
Im using Eclipse, not NetBeans (i have read that there is a bug in Netbeans)
Adding JARs to the Eclipse project build path is not sufficient to make them visible to Grails. You need to either put them in the application's lib directory and run grails compile --refresh-dependencies or (better) if the JARs are available in a Maven-compatible repository simply declare your dependencies in BuildConfig.groovy and let Grails download the JARs itself.
Run this - it will work
grails clean

Blackberry 5.0 - Add reference to a Java Library Project

It seems to me that what I'm trying to achieve is incredibly simple, yet is becoming incredibly painful.
I have ProjectA which is a BlackBerry Application project. I have ProjectB which is a Java library project. I want to refer to ProjectB from ProjectA. I can add a reference but when I run ProjectA, it doesn't work. I have source code for both the projects and both are compiled using Java compiler 1.4
I have tried multiple things but everything fails for some reason:
1. pre-verify.exe on ProjectB
It fails with an error "JAR file creation failed with error -1" I can see that the cod and jar files have been created but when add the jar file to ProjectA and run it, it doesn't work. Not sure if I need to add the .cod file.
2. Create new BlackBerry Library Project and reference it in ProjectA
I create a new project ProjectC and then add the jar of ProjectB to it. Then I add a reference to ProjectC in ProjectA. But I cant import classes from ProjectB
Pls suggest a way out.
I'm using Eclipse Plug-in and relying on Eclipse's build capabilities
Figured out answer myself. Publishing here in case someone stumbles upon this. Here are the steps:
Create your library and export as JAR (or download the 3rd party JAR)
Run preverify.exe on the JAR
preverify.exe -verbose -classpath "C:/Program Files/Research In Motion/BlackBerry JDE 5.0.0/lib/net_rim_api.jar" jarname.jar
If you are lucky, you won't run into any issues and you will be done. But I wasn't lucky enough. I got the below error
Error: No such file or directory. JAR file creation failed with error -1
There are two possible causes of this:
jar.exe is not added to your PATH. If so, add it (found in your JAVA
installation directory) to PATH
cvfm or -cfm option on jar.exe fails to execute. I'm not aware of the reason but the way to fix this is to use -cf option, point to the .class files but don't use the manifest file. here is an
example:
"C:\Program Files\Java\jdk1.6.0_26\bin\jar.exe" -cf "output\json-1.0.jar" tmp12996/
tmp12996 contains the preverified .class files.
You may run into different issues other than the one I've listed above.
Once jar is created from above step, make sure that it's structure is as you anticipate. One way to check is to rename the .jar to .zip, unzip it and then check it. If it is not as you need, you can change the structure and then repack it (I wouldn't do any major changes though)
Then add this newly built jar to your BlackBerry application as a reference i.e. add to Java Build Path in your eclipse and Check it in Order and Export window.
That's it! You are good to go! Run you app!
You may face error indicating that the module contains verification errors when you try to run in the simulator. One possible cause of this issue is that your library (the original JAR) contains APIs that are not compatible with J2ME or BB JRE. You may not get a compiler error when you build your library independently as it is compiled against Java 1.4 (or whatever your version is). Best to figure the issue out is to move all your code into your BB App project and then build it. That will tell you all the issues upfront. You make the changes as required and then move the code back to the library. If you don't have source code for the library you are using (like a 3rd party library), you may be out of luck! Also remember that there could be other issues than what I've hit upon and solved.
I'm documenting this at length as it has taken an awful amount of time for me to figure all this out; and to say the least, was most frustrating!
I found another solution. If you get error -1 while preverifying your JAR file, just run your library application once. Because if you don't run the application, the deliverables folder will be empty. Make sure this folder is not empty.

Problem with dependencies using Ant from the shell

I'm having problems building my project, using an Ant script, from the command prompt using Ant itself. It can't find a certain import for a particular Java file in my project (which has nearly 5,000 source files as it is). The import is included in a .jar package whose location I have set in the Ant file itself. (As a pathelement, along with other needed JARs that either are fine, or haven't tried to been used when the crash occurs). The crash happens with javac, with the simple message of "import etc.ect.* cannot be found at line etc" Oddly enough, I can build the project just fine from the Ant file using an IDE like Eclipse. Any ideas what could be wrong? Thanks!
Wow, the solution was completely unrelated. It was a dumb fault in the java code where the class was trying to import .* from a directory that only had folders in it. For some reason, Eclipse didn't seem to mind, but javac did!
Eclipse's root classloader contains a lot of classes, when you run ant from console there's much less.
Just tell javac task to use the required .jar, and you'll be fine.
You should post the stack trace, does it say "import required by ..."? ( I forget the exact text). Likely there's a jar that's available in your eclipse environment that is not included in your ant script. Look in the stack trace for the missing class to identify the jar that's not being included in your build.

Resources