We are using SonarQube 5.1.2 using Ant runner 2.2 and Java pluging 3.12 for the analysis. I can succesfully analyse my project. I just keep getting this error:
Java bytecode has not been made available to the analyzer. The org.sonar.java.bytecode.visitor.DependenciesVisitor#d678716, org.sonar.java.checks.unused.UnusedPrivateMethodCheck#58e28efd, CycleBetweenPackages rule are disabled.
So I need to configure my sonar.java.binaries and sonar.java.test.binaries properties (following http://docs.sonarqube.org/display/PLUG/Java+Plugin+and+Bytecode).
Which I think I have done correctly:
<property name="project.dir" value="${basedir}/xalg.prj/h3_service_fo" />
<property name="sonar.java.binaries" location="${project.build.dir}/classes/main" />
<property name="sonar.java.test.binaries" value="${project.build.dir}/classes/test" />
Which resolve to the following valid directories for the above properties:
basedir=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj
project.dir=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj/xalg.prj/h3_service_fo
sonar.java.binaries=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj\\xalg.prj\\h3_service_fo\\build\\classes\\main
sonar.java.test.binaries=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj/xalg.prj/h3_service_fo/build/classes/test
But I keep getting:
Java bytecode has not been made available to the analyzer. The org.sonar.java.bytecode.visitor.DependenciesVisitor#d678716, org.sonar.java.checks.unused.UnusedPrivateMethodCheck#58e28efd, CycleBetweenPackages rule are disabled.
And for the life of me, I can not figure out what values I need to give the sonar.java.binaries and sonar.java.test.binaries properties. I even tried using sonar.binaries, which gave me the following output:
Binary dirs: xalg.prj/h3_service_fo/build/classes
Which I did not get using either sonar.java.binaries or sonar.java.test.binaries. I also got:
JavaClasspath initialization...
sonar.binaries and sonar.libraries are deprecated since version 2.5 of sonar-java-plugin, please use sonar.java.binaries and sonar.java.libraries instead
Which is to be expected for a deprecated property. But using the sonar.java.binaries property I did not get the "Binary dirs" line in my log.
Using sonar.java.binaries:
Language is forced to java
Load rules
Load rules (done) | time=761ms
Code colorizer, supported languages: cs,plsql
Initializers :
Base dir: D:\appl\BuildAgent\work\H3\src.prj\java.prj
Working dir: D:\appl\BuildAgent\work\H3\src.prj\java.prj\.sonar
Source paths: xalg.prj/h3_service_fo/src/main/java
Test paths: xalg.prj/h3_service_fo/src/test/java
Source encoding: windows-1252, default locale: en_US
Index files
Versus using sonar.binaries:
Language is forced to java
Load rules
Load rules (done) | time=736ms
Code colorizer, supported languages: cs,plsql
Initializers :
Base dir: D:\appl\BuildAgent\work\H3\src.prj\java.prj
Working dir: D:\appl\BuildAgent\work\H3\src.prj\java.prj\.sonar
Source paths: xalg.prj/h3_service_fo/src/main/java
Test paths: xalg.prj/h3_service_fo/src/test/java
Binary dirs: xalg.prj/h3_service_fo/build/classes
Source encoding: windows-1252, default locale: en_US
Index files
I also looked into the source code of SonarQube, SonarQube Java Plugin and the SonarQube Scanner for instances of either "Java bytecode has not been made available to the analyzer." or sonar.java.binaries. I found plenty on sonar.java.binaries, but nothing on "Java bytecode has not been made available to the analyzer." So I have no clue what conditions exactly trigger that error.
I also tried the following permutations on sonar.java.binaries:
<property name="sonar.java.binaries" location="${project.build.dir}/classes" />
<property name="sonar.java.binaries" location="${project.build.dir}/classes/main/nl" />
But that did nothing either.
What is weird is that Squid seems to resolve the classpath just fine:
----- Classpath analyzed by Squid:
D:\appl\BuildAgent\work\H3\src.prj\java.prj\xalg.prj\h3_service_fo\build\classes\main
So, what am I missing? What am I doing wrong? Thanks in advance.
Update 2016-09-08:
Removed the entire log, the post become to long.
A subset with the (I think) relevant paths:
project.build.dir=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj/xalg.prj/h3_service_fo/build
project.dir=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj/xalg.prj/h3_service_fo
project.src.dir=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj/xalg.prj/h3_service_fo/src
sonar.dir=D\:/appl/sonarqube-5.1.2
sonar.working.directory=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj\\.sonar
sonar.projectBaseDir=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj
sonar.jacoco.reportPath=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj/xalg.prj/h3_service_fo/build/jacoco/test.exec
sonar.junit.reportsPath=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj/xalg.prj/h3_service_fo/build/test-results
sonar.sources=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj/xalg.prj/h3_service_fo/src/main/java
sonar.java.binaries=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj\\xalg.prj\\h3_service_fo\\build\\classes\\main
sonar.java.libraries=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj/_deploy/*.jar,D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj/_repos/lib/*.jar,D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj/_repos/provided/*.jar
sonar.tests=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj/xalg.prj/h3_service_fo/src/test/java
sonar.java.test.binaries=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj/xalg.prj/h3_service_fo/build/classes/test
sonar.java.test.libraries=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj/_deploy/*.jar,D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj/_repos/lib/*.jar,D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj/_repos/provided/*.jar
The paths have exactly the same format as in my post. Could it be that the Sonar Ant runner can't figure out a path with both backslashes and slashes?
Update 2016-09-16:
Removed the entire log, the post become to long.
A subset with the (I think) relevant paths:
project.build.dir=xalg.prj\\\\h3_service_fo\\\\build
project.dir=xalg.prj\\\\h3_service_fo
project.src.dir=xalg.prj\\\\h3_service_fo\\\\src
sonar.dir=D\:\\\\appl\\\\sonarqube-5.1.2
sonar.working.directory=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj\\.sonar
sonar.projectBaseDir=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj
sonar.jacoco.reportPath=xalg.prj\\\\h3_service_fo\\\\build\\\\jacoco/test.exec
sonar.junit.reportsPath=xalg.prj\\\\h3_service_fo\\\\build\\\\test-results
sonar.sources=xalg.prj\\\\h3_service_fo\\\\src\\\\main\\\\java
sonar.java.binaries=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj\\xalg.prj\\h3_service_fo\\build\\classes\\main
sonar.java.libraries=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj\\\\_deploy\\\\*.jar,D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj\\\\_repos\\\\lib\\\\*.jar,D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj\\\\_repos\\\\provided\\\\*.jar
sonar.tests=xalg.prj\\\\h3_service_fo\\\\src\\\\test\\\\java
sonar.java.test.binaries=xalg.prj\\\\h3_service_fo\\\\build\\\\classes\\\\test
sonar.java.test.libraries=D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj\\\\_deploy\\\\*.jar,D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj\\\\_repos\\\\lib\\\\*.jar,D\:\\appl\\BuildAgent\\work\\H3\\src.prj\\java.prj\\\\_repos\\\\provided\\\\*.jar
Some paths have become relative, but I think that is because TeamCity changed the Ant file to the file in SVN.
The sonar.java.binaries is absolute and it definitely points to the correct directory.
But I still get this error:
09:17:52.299 INFO - Java Main Files AST scan done: 1579 ms
09:17:52.301 INFO - 2/2 source files have been analyzed
09:17:52.305 WARN - Java bytecode has not been made available to the analyzer. The org.sonar.java.bytecode.visitor.DependenciesVisitor#757a48f9, org.sonar.java.checks.unused.UnusedPrivateMethodCheck#1adf492b, CycleBetweenPackages rule are disabled.
The classpath is still interpreted just fine:
[sonar:sonar] 09:17:51.971 DEBUG - ----- Classpath analyzed by Squid:
[sonar:sonar] 09:17:51.972 DEBUG - D:\appl\BuildAgent\work\H3\src.prj\java.prj\xalg.prj\h3_service_fo\build\classes\main
[sonar:sonar] 09:17:51.973 DEBUG - D:\appl\BuildAgent\work\H3\src.prj\java.prj\_deploy\batch.daemon.jar
[sonar:sonar] 09:17:51.974 DEBUG - D:\appl\BuildAgent\work\H3\src.prj\java.prj\_deploy\buildinfo.jar
[sonar:sonar] 09:17:51.975 DEBUG - D:\appl\BuildAgent\work\H3\src.prj\java.prj\_deploy\h2_shared.jar
[sonar:sonar] 09:17:51.975 DEBUG - D:\appl\BuildAgent\work\H3\src.prj\java.prj\_deploy\h3_generator.jar
[sonar:sonar] 09:17:51.976 DEBUG - D:\appl\BuildAgent\work\H3\src.prj\java.prj\_deploy\h3_loadtest.jar
[sonar:sonar] 09:17:51.977 DEBUG - D:\appl\BuildAgent\work\H3\src.prj\java.prj\_deploy\h3_model_common.jar
[sonar:sonar] 09:17:51.977 DEBUG - D:\appl\BuildAgent\work\H3\src.prj\java.prj\_deploy\h3_model_xalg.jar
[sonar:sonar] 09:17:51.978 DEBUG - D:\appl\BuildAgent\work\H3\src.prj\java.prj\_deploy\h3_model_xalg_dao.jar
[sonar:sonar] 09:17:51.979 DEBUG - D:\appl\BuildAgent\work\H3\src.prj\java.prj\_deploy\h3_model_xalg_mappers.jar
[sonar:sonar] 09:17:51.979 DEBUG - D:\appl\BuildAgent\work\H3\src.prj\java.prj\_deploy\h3_model_xalg_procedures.jar
[sonar:sonar] 09:17:51.980 DEBUG - D:\appl\BuildAgent\work\H3\src.prj\java.prj\_deploy\h3_model_xcare.jar
[sonar:sonar] 09:17:51.981 DEBUG - D:\appl\BuildAgent\work\H3\src.prj\java.prj\_deploy\h3_model_xcare_dao.jar
[sonar:sonar] 09:17:51.982 DEBUG - D:\appl\BuildAgent\work\H3\src.prj\java.prj\_deploy\h3_model_xcare_mappers.jar
[sonar:sonar] 09:17:51.982 DEBUG - D:\appl\BuildAgent\work\H3\src.prj\java.prj\_deploy\h3_model_xcare_procedures.jar
Could the Sonar Ant runner have a problem with the escaped back slashes?
This is what I use, and it works.
sonar-scanner -Dsonar.projectKey=projectName
-Dsonar.gitlab.commit_sha=$CI_BUILD_REF
-Dsonar.gitlab.ref_name=$CI_BUILD_REF_NAME -Dsonar.sources=directory\src\
-Dsonar.java.binaries=.build\libs\
You need to point sonar.java.binaries to a directory that contains jars. I would't try to get fancy with wildcards and file extensions, that's not the same thing. You need a directory as an argument, not a regular expression for files.
I don't know everything about sonar scanner, but my configuration works.
Take my example into context, I use it in a gitlab runner pipeline. Your double backslashes should be fine, but you can always substitute them for forwards slashes in your config files.
Here are some options for a Gradle multi-project. I'm running in CI (Jenkins) but the principles apply.
Options:
Hand-maintain a hardcoded sonar.java.binaries entry, eg:
sonar.java.binaries=subproject1/build/classes,subproject2/build/classes, (etc)
Set it to the top-level directory of the project:
sonar.java.binaries=.
Use a script to generate your own props file at runtime, for example:
cat > sonar-project.properties <<EOF
sonar.projectKey=XXXX
sonar.projectVersion=YYYY
sonar.sources=$(find . -path '*/src/main' | xargs | tr ' ' ',')
sonar.java.binaries=$(find . -path '*/build/classes/java' | xargs | tr ' ' ',')
EOF
Note that the above also applies to sonar.sources, and it is likely going to need to be in sync with sonar.java.binaries. Having binaries be a superset of source seems to be OK. Obviously, if your sources value is too broad (ie includes tests, etc), you'll get more noise. The advantage of using a script is that you can customize these heuristics to your taste.
you have to provide the parameter sonar.java.libraries.
if you use maven you can add these inside the pom.xml as a property
<project>
...
<properties>
...
<sonar.java.libraries>target</sonar.java.libraries>
</properties>
</project>
or as run parameter -Dsonar.java.libraries=target
Based on the documentation at https://docs.sonarqube.org/latest/analysis/languages/java/
The purpose of sonar.java.binaries path is:
Comma-separated paths to directories containing the compiled bytecode files corresponding to your source files.
For Gradle, the default path is at build/classes, so I would set:
sonar.java.binaries=build/classes
IDK but adding this sonar.java.binaries= **/*.bin to sonar-project.properties helped me
Related
Problem
I have a package with a java_library configured with javaopts = ["-Werror"]. Building was successful with 3.6.0.
After upgrading to 4.0.0 I get
warning: [path] bad path element "some/path/some.jar" : no such file or directory
More inspection revealed that these jars are declared in the META-INF/MANIFEST.MF Class-Path in some of our dependencies that are being fetched through maven_install. And, obviously, they are not found in the referred to directory in the warning message.
I tried adding "-Xlint:-path" to javacopts in our BUILD file, but warnings still exist.
Worth mentioning that removing the -Werror does not fail the build (although the warnings of course still exist).
To Reproduce
To reproduce on a simpler project, I replicated the case with the example repo from the java tutorial on bazel docs.
git clone https://github.com/bazelbuild/examples
Then applying this git patch
diff --git a/java-maven/BUILD b/java-maven/BUILD
index 60cdd7b..370b6f4 100644
--- a/java-maven/BUILD
+++ b/java-maven/BUILD
## -5,7 +5,8 ## package(default_visibility = ["//visibility:public"])
java_library(
name = "java-maven-lib",
srcs = glob(["src/main/java/com/example/myproject/*.java"]),
- deps = ["#maven//:com_google_guava_guava"],
+ deps = ["#maven//:com_google_guava_guava", "#maven//:org_apache_beam_beam_model_job_management"],
+ javacopts = ["-Werror", "-Xlint:-path"]
)
java_binary(
diff --git a/java-maven/WORKSPACE b/java-maven/WORKSPACE
index 1cbdf12..aa0df88 100644
--- a/java-maven/WORKSPACE
+++ b/java-maven/WORKSPACE
## -17,6 +17,7 ## maven_install(
artifacts = [
"junit:junit:4.12",
"com.google.guava:guava:28.0-jre",
+ "org.apache.beam:beam-model-job-management:2.19.0",
],
fetch_sources = True,
repositories = [
bazel build //...
I also tried bazel build --javacopt="-Werror -Xlint:-path" //..., but also no luck
Can anyone advise what am I doing wrong and how to achieve suppressing this specific warning (path warnings) while still having -Werror?
Digging deeper into Bazel codebase, I found the undocumented (to extent of my knowledge) flag Xerror: (vs Xerror), which takes a list of warnings to fail the build for. In my case I could do Xerror:-path instead the standard Xerror and Xlint:-path.
I found this bug report later, and also commented there.
NOVICE HERE - I am trying to Execute a WSDL file in a remote ubuntu terminal. I have installed Java, Axis, and ant. I also specified the classpath and CLASSPATH (wasn't sure if case was a thing). But when I run it using this command:
$AXIS2_HOME/bin/wsdl2java.sh -uri ShippingService.wsdl -p pws.client.ShippingService.wsdl -d adb -s
I get this error:
Using AXIS2_HOME: /opt/axis2
Using JAVA_HOME: /usr/lib/jvm/jdk-13.0.1
Error: -classpath requires class path specification
AXIS2_HOME=/opt/axis2 is defined in the /etc/environment; as is JAVA_HOME.
The instructions specify to use axis2-1.4.1 I am using axis2-1.7.9 which is the latest version. The older one has this file in its classpath specification annogen-0.1.0.jar the newer axis2 doesn't. Is this a possible issue?
Here is the Readme.txt (only available for Windows XP):
Requires:
Basic understanding of Web Services with Java
Valid Development/Production Key and Password
Java SE Development Kit (JDK 6 Update 16)
AXIS2 from Apache
Ant from Apache
This example covers the creation of a proper SOAP Client to communicate with the Shipping Web Services. The solution file was built on a Windows XP system using the Java Development Kit and AXIS2. The generated sample stub files are located in folder ShippingServiceStub based on this system that generated them. You can gather the pre-compiled stubs by making sure the Stub class files are in your classpath, or you can generate the stubs on your own following all the steps below.
To Complete:
1. Download Shipping Service 2.0 WSDL File from Eship Web Services site (Login Required)
a) https://eship.purolator.com/SITE/en/resourcecentre/samplecode.aspx
Note: In this sample the file has been unzipped to C:\EWSSample\ShippingService-Create directory. There should now be ShippingService.wsdl in the directory C:\EWSSample\ShippingService-Create\Development. This is the file we will concentrate on in the next step.
2. Execute WSDL2JAVA to build the stub files (Run this in the C:\EWSSample\ShippingService-Create\Development directory)
a) Example for all WSDLs from Eship Web Services site
%AXIS2_HOME%\bin\wsdl2java -uri WSName.wsdl -p pws.client.WSName -d adb -s
where:
WSName is the name of the web service, for example: ShippingService
AXIS2_HOME is environment variable pointing to your Axis2 installation, for example C:\axis2\axis2-1.4.1
-d adb means that provided samples use Axis Data Binding. It generates one stub class per web service which extends org.apache.axis2.client.Stub.
b) Our current example
C:\AXIS2\axis2-1.4.1\bin\wsdl2java -uri ShippingService.wsdl -p pws.client.ShippingService -d adb -s
Note: If you receive an error 'The JAVA_HOME environment variable is not defined' refer to Installation and Environment Notes file.
Note: If you receive an error 'The AXIS2_HOME environment variable is not defined' refer to Installation and Environment Notes file.
Response received:
Using AXIS2_HOME: C:\AXIS2\axis2-1.4.1
Using JAVA_HOME: C:\Program Files\Java\jdk1.6.0_16
Retrieving document at 'ShippingService.wsdl'.
What happened? build.xml was created in local directory. 'src\pws\client\ShippingService' directory created with ShippingServiceCallbackHandler.java, ShippingServiceContract_Consolidate_ValidationFaultFault_FaultMessage.java, ShippingServiceContract_CreateShipment_ValidationFaultFault_FaultMessage, ShippingServiceContract_ValidateShipment_ValidationFaultFault_FaultMessage, ShippingServiceContract_VoidShipment_ValidationFaultFault_FaultMessage and ShippingServiceStub java files created.
3. Download Shipping Service 2.0 Create java sample code and extract ShipmentClientCreate.java to C:\EWSSample\ShippingService-Create\Development\src\pws\client\ShippingService directory.
4. Edit the file and modify the following code
a) Define the Production (or development) Key and Password
b) Define your Purolator Account Number ( Note the Test Account Number is 9999999999 )
c) Define your Postal Code. Make sure the sending postal code is the one you registered with when receiving the Development Key and Password.
5. Run ant to compile.
a) Type 'C:\ANT\apache-ant-1.7.1\bin\ant' from the C:\EWSSample\ShippingService-Create\Development directory.
Response received:
Buildfile: build.xml
init:
[mkdir] Created dir: C:\EWSSample\ShippingService-Create\Development\build
[mkdir] Created dir: C:\EWSSample\ShippingService-Create\Development\build\classes
[mkdir] Created dir: C:\EWSSample\ShippingService-Create\Development\build\lib
pre.compile.test:
[echo] Stax Availability= true
[echo] Axis2 Availability= true
compile.src:
[javac] Compiling 5 source files to C:\EWSSample\ShippingService-Create\Development\build\classes
[javac] Note: C:\EWSSample\ShippingService-Create\Development\src\pws\client\ShippingService\ShippingServiceStub.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
jar.client:
[jar] Building jar: C:\EWSSample\ShippingService-Create\Development\build\lib\ShippingService-test-client.jar
BUILD SUCCESSFUL
Total time: 13 seconds
b) Type 'C:\ANT\apache-ant-1.7.1\bin\ant' from the C:\EWSSample\ShippingService-Create\Development directory.
Response received:
Buildfile: build.xml
init:
[mkdir] Created dir: C:\EWSSample\ShippingService-Create\Development\build
[mkdir] Created dir: C:\EWSSample\ShippingService-Create\Development\build\classes
[mkdir] Created dir: C:\EWSSample\ShippingService-Create\Development\build\lib
pre.compile.test:
[echo] Stax Availability= true
[echo] Axis2 Availability= true
compile.src:
[javac] Compiling 4 source files to C:\EWSSample\ShippingService-Create\Development\build\classes
[javac] C:\EWSSample\ShippingService-Create\Development\src\pws\client\ShippingService\ShippingServiceStub.java:34: error: incompatible types: java.lang.String cannot be converted to pws.client.ShippingService.ShippingServiceStub.String
[javac] return Long.toString(System.currentTimeMillis()) + "_" + counter;
[javac] ^
[javac] Note: C:\EWSSample\ShippingService-Create\Development\src\pws\client\ShippingService\ShippingServiceStub.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 1 error
BUILD FAILED
C:\EWSSample\ShippingService-Create\Development\build.xml:43: Compile failed; see the compiler error output for details.
Total time: 4 seconds
In case you see this error, update C:\EWSSample\ShippingService-Create\Development\src\pws\client\ShippingService\ShippingServiceStub.java by changing method signature of getUniqueSuffix to
private static synchronized java.lang.String getUniqueSuffix(){
6. Navigate to the C:\EWSSample\ShippingService-Create\Development\src\ directory and compile the client code by running the following
a) javac pws\client\ShippingService\ShipmentClientCreate.java
Possible Error 1: 'javac' is not recognized as an internal or external command, operable program or batch file.
Resolution 1: You need to add the Java path to the PATH Environment Variable. %JAVA_HOME%\bin. Refer to Installation and Environment Notes file for additional information.
Possible Error 2: package org.apache.axis2 does not exist throws org.apache.axis2.AxisFault
Resolution 2: Classpath variable needs to be set. Refer to Installation and Environment Notes file for additional information.
Response Received:
C:\EWSSample\ShippingService-Create\Development\src>javac pws\client\ShippingService\ShipmentClientCreate.java
Note: .\pws\client\ShippingService\ShippingServiceStub.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
7. Running the code after valid compile above.
a) C:\EWSSample\ShippingService-Create\Development\src>java pws.client.ShippingService.ShipmentClientCreate
Possible Error 1:
WARNING:
log4j:WARN No appenders could be found for logger (org.apache.axis2.description.AxisService).
log4j:WARN Please initialize the log4j system properly.
Resolution 1: http://logging.apache.org/log4j/1.2/manual.html. Refer to Installation and Environment Notes file for additional information.
Possible Error 2:
[main] INFO org.apache.axis2.transport.http.HTTPSender - Unable to sendViaPost to url[https://devwebservices.purolator.com/EWS/V2/Shipping/ShippingService.asmx]
org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
Resolution 2: Make sure you are using your Development key and Password when connecting to the devwebservices instance.
Possible Error 3:
[main] INFO org.apache.commons.httpclient.HttpMethodDirector - No credentials available for BASIC 'Purolator'#devwebservices.purolator.com:
Resolution 3:
Make sure code has import procedures:
import org.apache.axis2.client.Options;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties;
Try the alternate way to send in credentials to web service. Make sure you remark the other credentials that you tried.
Options options = stub._getServiceClient().getOptions();
HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
auth.setUsername("your key here");
auth.setPassword("your password here");
options.setProperty(HTTPConstants.AUTHENTICATE,auth);
Response Received:
Here are the setup instructions (only available for Windows XP):
Applications to Install:
Java SE Development Kit (JDK 6 Update 16)
AXIS2 from Apache
Ant from Apache
This example covers the creation of a proper SOAP Client to communicate with the Shipping Web Services. The solution file was built on a Windows XP system using the Java Development Kit and AXIS2.
Installation Instructions for the Environment:
1. Download and install the Java Development Kit
a) In this document Java SE Development Kit 6 Update 16 was downloaded an installed
b) Location: http://java.sun.com/javase/downloads/index.jsp
c) run jdk-6u16-windows-i586.exe (Extracts Installation files)
d) Installed to C:\Program Files\Java\jdk1.6.0_16
2. Download and unpack AXIS 2 Standard Binary Distribution version 1.4.1
a) Location: http://ws.apache.org/axis2/download/1_4_1/download.cgi
b) Unzip to directory (C:\AXIS2\axis2-1.4.1)
Make sure you add JAVA_HOME environment variable pointing to your Java engine root folder (C:\Program Files\Java\jdk1.6.0_16).
This can be completed by right clicking My Computer. Select Properties. Select Advanced, select Environment variables. Select 'New' of JAVA_HOME is not listed under System Variables.
In our example C:\Program Files\Java\jdk1.6.0_16
Make sure you add AXIS2_HOME environment variable pointing to your Axis engine root folder (C:\AXIS2\axis2-1.4.1).
This can be completed by right clicking My Computer. Select Properties. Select Advanced, select Environment variables. Select 'New' of AXIS_HOME is not listed under System Variables.
In our example C:\AXIS2\axis2-1.4.1
Use the online tutorial from Apache for non Java programmers.
Note: Java sample code uses web service client stubs created with Wsdl2Java utility from Apache Axis2 Web services engine.
3. Download and unpack Apache Ant (1.7.1)
a) Location: http://ant.apache.org/bindownload.cgi
b) Unzip to directory (C:\Ant\apache-ant-1.7.1)
Note: Apache Ant is a Java-based build tool.
4. Set the Classpath for the jar files that are included in the AXIS directory.
a) run the following from command line
set classpath=C:\AXIS2\axis2-1.4.1\lib\activation-1.1.jar;
C:\AXIS2\axis2-1.4.1\lib\annogen-0.1.0.jar;
C:\AXIS2\axis2-1.4.1\lib\axiom-api-1.2.7.jar;
C:\AXIS2\axis2-1.4.1\lib\axiom-dom-1.2.7.jar;
C:\AXIS2\axis2-1.4.1\lib\axiom-impl-1.2.7.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-adb-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-adb-codegen-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-ant-plugin-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-clustering-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-codegen-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-corba-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-fastinfoset-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-java2wsdl-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-jaxbri-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-jaxws-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-jaxws-api-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-jibx-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-json-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-jws-api-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-kernel-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-metadata-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-mtompolicy-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-saaj-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-saaj-api-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-spring-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-xmlbeans-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\backport-util-concurrent-3.1.jar;
C:\AXIS2\axis2-1.4.1\lib\commons-codec-1.3.jar;
C:\AXIS2\axis2-1.4.1\lib\commons-fileupload-1.2.jar;
C:\AXIS2\axis2-1.4.1\lib\commons-httpclient-3.1.jar;
C:\AXIS2\axis2-1.4.1\lib\commons-io-1.4.jar;
C:\AXIS2\axis2-1.4.1\lib\commons-logging-1.1.1.jar;
C:\AXIS2\axis2-1.4.1\lib\geronimo-annotation_1.0_spec-1.1.jar;
C:\AXIS2\axis2-1.4.1\lib\geronimo-stax-api_1.0_spec-1.0.1.jar;
C:\AXIS2\axis2-1.4.1\lib\httpcore-4.0-beta1.jar;
C:\AXIS2\axis2-1.4.1\lib\httpcore-nio-4.0-beta1.jar;
C:\AXIS2\axis2-1.4.1\lib\jalopy-1.5rc3.jar;
C:\AXIS2\axis2-1.4.1\lib\jaxb-api-2.1.jar;
C:\AXIS2\axis2-1.4.1\lib\jaxb-impl-2.1.6.jar;
C:\AXIS2\axis2-1.4.1\lib\jaxb-xjc-2.1.6.jar;
C:\AXIS2\axis2-1.4.1\lib\jaxen-1.1.1.jar;
C:\AXIS2\axis2-1.4.1\lib\jettison-1.0-RC2.jar;
C:\AXIS2\axis2-1.4.1\lib\jibx-bind-1.1.5.jar;
C:\AXIS2\axis2-1.4.1\lib\jibx-run-1.1.5.jar;
C:\AXIS2\axis2-1.4.1\lib\log4j-1.2.15.jar;
C:\AXIS2\axis2-1.4.1\lib\mail-1.4.jar;
C:\AXIS2\axis2-1.4.1\lib\mex-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\neethi-2.0.4.jar;
C:\AXIS2\axis2-1.4.1\lib\soapmonitor-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\woden-api-1.0M8.jar;
C:\AXIS2\axis2-1.4.1\lib\woden-impl-dom-1.0M8.jar;
C:\AXIS2\axis2-1.4.1\lib\wsdl4j-1.6.2.jar;
C:\AXIS2\axis2-1.4.1\lib\wstx-asl-3.2.4.jar;
C:\AXIS2\axis2-1.4.1\lib\xalan-2.7.0.jar;
C:\AXIS2\axis2-1.4.1\lib\xercesImpl-2.8.1.jar;
C:\AXIS2\axis2-1.4.1\lib\xml-apis-1.3.04.jar;
C:\AXIS2\axis2-1.4.1\lib\xml-resolver-1.2.jar;
C:\AXIS2\axis2-1.4.1\lib\xmlbeans-2.3.0.jar;
C:\AXIS2\axis2-1.4.1\lib\XmlSchema-1.4.2.jar;
5. Set up the file log4j.properties which displays additional information when running code in command line.
a) Location of Information: http://logging.apache.org/log4j/1.2/manual.html
b) Create File named: 'log4j.properties' in C:\EWSSample\ShippingService-Create\Development\src directory with the following information.
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
Please assist. Cheers!
I have java project and I want to integrate it with SonarCloud I Follow the official steps:
Inspecting code with the SonarQube Scanner #
Before inspecting your code, you need to:
Create a user authentication token for your account on SonarCloud.
Encrypt this token travis encrypt abcdef0123456789 or define SONAR_TOKEN in your Repository Settings
Find which SonarCloud.io organization you want to push your project on and get its key
Create a sonar-project.properties file for your project (see the documentation). Then add the following lines to your .travis.yml file
to trigger the analysis:
add in my travis.yml file
addons:
sonarcloud:
organization: "xelian-github"
token:
secure: ${SONAR_TOKEN}
branches:
- master
script:
# other script steps might be done before running the actual analysis
- sonar-scanner
Where SONAR_TOKEN is a variable on Travis CI pointing to the key from SonarCloud.(It is not encrypted).
From SonarCloud I add permissions
But when I start the travis build I have the following error:
Setting environment variables from repository settings
$ export SONAR_TOKEN=[secure]
....
ERROR: Error during SonarQube Scanner execution
ERROR: You're only authorized to execute a local (preview) SonarQube analysis without pushing the results to the SonarQube server. Please contact your SonarQube administrator.
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
It seems to me that I the travis do not have permissions to upload results to SonarCloud. Is the problem in the token or in some Sonar configurations.
The official entry point to configure a project on SonarCloud is the "Get Started" page:
You will see that for Maven projects, you don't need to create a sonar-project.properties file at all
You will even find a link to a sample Maven project that is analyzed on SonarCloud
Finally I find a solution. In the root path whete the yml file is you have to add:
sonar-project.properties
# Required metadata
sonar.projectKey=java-sonar-runner-simple:master
sonar.projectName=Rss-service
sonar.projectVersion=1.0
# Comma-separated paths to directories with sources (required)
sonar.sources=/microservice-application/rss-reader-service/src/main/java
sonar.java.binaries=/microservice-application/rss-reader-service/target/classes
# Language
sonar.language=java
# Encoding of the source files
sonar.sourceEncoding=UTF-8
And in the travis.yml I add:
script:
# other script steps might be done before running the actual analysis
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar
Edit:
sonar-project.properties not necessary. Only maven goals make sense.
I've got a Tomcat webapp where I'm using AspectJ for logging and metrics, everything seems fine, but it keep creating several files like ajcore.20150310.113255.780.txt in the root folder. There is no exception in this files, so they are completely useless.
I've found this: https://eclipse.org/aspectj/doc/released/pdguide/ajcore.html
That states that using org.aspectj.weaver.Dump.exception="false" should disable this behavior, yet the files are still appearing. Is there any other way to completely disable the creation of this files? The other option mentioned: org.aspectj.dump.directory would also solve the problem, but it doesn't seem to work either.
This is the content of the file in case it helps for anything:
---- AspectJ Properties ---
AspectJ Compiler 1.7.1 built on Thursday Sep 6, 2012 at 16:39:22 GMT
---- Dump Properties ---
Dump file: ajcore.20150310.113255.780.txt
Dump reason: org.aspectj.weaver.BCException
Dump on exception: true
Dump at exit condition: abort
---- Exception Information ---
---- System Properties ---
... My system properties here
---- Command Line --- Empty
---- Full Classpath --- Empty
---- Compiler Messages --- Empty
Either of the following options may help:
Executing this code before any AspectJ weaving occurs (if possible): org.aspectj.weaver.Dump.setDumpOnExit(org.aspectj.bridge.IMessage.ABORT)
Adding this system property definition to your java command-line: -Dorg.aspectj.weaver.Dump.condition=abort
I think it is good that the AJ core dump happens because something seems to go wrong during LTW compilation:
Dump file: ajcore.20150310.113255.780.txt
Dump reason: org.aspectj.weaver.BCException
So there is an exception and you should investigate and fix it. Maybe some of your classes are woven with the logging code correctly and some are not. Run the weaver in verbose mode and check your console output, maybe you see something strange there. An AJ core file means that the weaver/compiler was shut down completely (abnormal termination).
As for the actual problem, I think that this
---- Command Line --- Empty
looks strange, as if no command line parameters were passed to the weaver. Also that no exception is actually logged is really unusual.
Which Java version are you on? I assume Java 7 because 1.6 is really old and Java 8 needs AspectJ 1.8. Anyway, can you try to use the latest AspectJ version 1.8.5 or at least the latest 1.7.4 from the old release and see if the problem still occurs?
Add this argument to your JVM run: -Dorg.aspectj.weaver.Dump.exception=false
And also see official docs
I have this warning:
warning: Supported source version 'RELEASE_6' from annotation processor
org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor' less than -source
'1.7'
Note: Creating non-static metadata factory ...
Note: Found Option : eclipselink.canonicalmodel.use_static_factory, with value: false
Note: Optional file was not found: META-INF/orm.xml continuing with generation.
Note: Optional file was not found: META-INF/eclipselink-orm.xml continuing with
generation.
Note: Found Option : eclipselink.canonicalmodel.use_static_factory, with value: false
Note: Optional file was not found: META-INF/orm.xml continuing with generation.
Note: Optional file was not found: META-INF/eclipselink-orm.xml continuing with
generation.
warning: The following options were not recognized by any processor:
'[eclipselink.canonicalmodel.use_static_factory]'
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 warning
Copying 5 files to E:\NetBeansProjects\votaciones\build\classes
compile:
Created dir: E:\NetBeansProjects\votaciones\dist
Copying 1 file to E:\NetBeansProjects\votaciones\build
Copy libraries to E:\NetBeansProjects\votaciones\dist\lib.
Building jar: E:\NetBeansProjects\votaciones\dist\votaciones.jar
To run this application from the command line without Ant, try:
java -jar "E:\NetBeansProjects\votaciones\dist\votaciones.jar"
jar:
BUILD SUCCESSFUL (total time: 8 seconds)
what happen?
It says build was successful. The first warning is saying you use Java 7(1.7) where the source supports Java 6 (1.6). The second waring is a consequence of the first one. If your application works, i dont think there is any problem. If it doesnt work, try using java 1.6 or get the updated versions that support java 1.7.