When running the XJC task on SNotification.xsd, two XSDs(SNotification.xsd, CDataModel.xsd) are generating the same class. The error it is showing off is:
A class/interface with the same name "com.att.mre.ecrupr.atlas.jms.MarketInfo" is already in use. Use a class customization to resolve this conflict.
[xjc] line 214 of file:/C:/Documents%20and%20Settings/rkar4749/workspace/ECRUPR_1306/AtlasEventsListener/xsd/Atlas/Container/Public/SubscriberNotification.xsd
[xjc] [ERROR] (Relevant to above error) another "MarketInfo" is generated from here.
[xjc] line 22368 of file:/C:/Documents%20and%20Settings/rkar4749/workspace/ECRUPR_1306/AtlasEventsListener/xsd/Common/Types/Public/CingularDataModel.xsd
[xjc] [ERROR] Two declarations cause a collision in the ObjectFactory class.
[xjc] line 22368 of file:/C:/Documents%20and%20Settings/rkar4749/workspace/ECRUPR_1306/AtlasEventsListener/xsd/Common/Types/Public/CingularDataModel.xsd
[xjc] [ERROR] (Related to above error) This is the other declaration.
[xjc] line 214 of file:/C:/Documents%20and%20Settings/rkar4749/workspace/ECRUPR_1306/AtlasEventsListener/xsd/Atlas/Container/Public/SubscriberNotification.xsd
[xjc] failure in the XJC task. Use the Ant -verbose switch for more details
i had the same problem and run below command from terminal and it was solved
xjc -XautoNameResolution your.xsd
You can use an external binding file to rename one of the generated classes.
Example
JAXB: How to change XJC-generated classes names when attr type is specified in XSD?
Related
I reinstalled between jdk-8 and jdk-12, the building process shows different errors but both failed. And both are showing in the log that the bcel package is missing as the first error.
I've set JAVA_HOME in both jdk with the corresponding value;
sh build.sh -Ddist.dir=~/tmp/ant dist
this is the code I get from the org document for building.
Loading source files for package org.apache.tools.tar...
Loading source files for package org.apache.tools.zip...
Constructing Javadoc information...
/home/uppdev/tmp/ant/src/main/org/apache/tools/ant/filters/util/JavaClassHelper.java:23: error: package org.apache.bcel.classfile does not exist
import org.apache.bcel.classfile.ClassParser;
^
/home/uppdev/tmp/ant/src/main/org/apache/tools/ant/filters/util/JavaClassHelper.java:24: error: package org.apache.bcel.classfile does not exist
import org.apache.bcel.classfile.ConstantValue;
:
:
:
Building index for all the packages and classes...
Building index for all classes...
Generating /home/uppdev/tmp/ant/build/javadocs/help-doc.html...
Note: Custom tags that could override future standard tags: #todo. To avoid potential overrides, use at least one period character (.) in custom tag names.
26 errors
100 warnings
BUILD FAILED
/home/uppdev/tmp/ant/build.xml:1012: The following error occurred while executing this line:
/home/uppdev/tmp/ant/build.xml:1520: Javadoc returned 1
Total time: 20 seconds
If this is for ant 1.10.2 then I can provide info:
JDK8 returns an error for missing references in javadocs (see https://bugs.openjdk.java.net/browse/JDK-8224266) which can be maded non-fatal by passing -Xdoclint:none to javadoc.
ant 1.10.2 removed this flag together with the configure param withDoclint which made builds fail if the optional dependencies were not found.
A workaround is to add additionalparam="-Xdoclint:none" to the <javadoc ...> tag in the <target name="javadocs" in build.xml before building.
Fixed part of 1.10.2:
<target name="javadocs" depends="check-javadoc"
description="--> creates the API documentation" unless="javadoc.notrequired">
<mkdir dir="${build.javadocs}"/>
<javadoc additionalparam="-Xdoclint:none"
useexternalfile="yes"
destdir="${build.javadocs}"
failonerror="true"
author="true"
version="true"
locale="en"
windowtitle="${Name} API"
doctitle="${Name}"
maxmemory="1000M"
verbose="${javadoc.verbose}">
I would like you to help me with a problem that I have when executing: 'build now', because when I execute it the console output shows a series of failures
One of the failures was and still is, the properties of the file, I have already configured them and it is still giving faults, I have also saved them in the project directory, but nothing keeps failing.
these are the properties which i have in my project
sonar.projectKey=sistema_integracion
sonar.projectName=sistema_integracion
sonar.projectVersion=1.0
sonar.projectDescription=proyecto_asir
sonar.source=C:\Program Files (x86)\Jenkins\workspace\proyecto_integracion\spring_boot\src\main\java\hello
sonar.language=java
sonar.java.binaries=.
sonar.sourceEncoding=UTF-8
sonar.scm.disabled=True
-And these are the flaws , I would appreciate all the help possible.
Thank you so much.
ERROR: Error during SonarQube Scanner execution
ERROR: You must define the following mandatory properties for 'sistema_integracion': sonar.sources
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeeded?
ERROR: SonarQube scanner exited with non-zero code: 1
Finished: FAILURE
Here is your problem:
ERROR: You must define the following mandatory properties for 'sistema_integracion': sonar.sources
You defined an absolute path:
sonar.source=C:\Program Files (x86)\Jenkins\workspace\proyecto_integracion\spring_boot\src\main\java\hello
The path must be relative. If this is your file structure:
sonar-project.properties
src
\-main
\-java
Then you should set:
sonar.sources=src/main/java
I would like to:
use the Frege programming language to write a simple "Hello World" piece of code,
then using the Frege compiler generating the equivalent Java source code,
then building an executable Jar file to run from the command line,
all the previous steps should be "controlled" by Gradle.
I am able to generate the source code (items 1. and 2. from the previous list), but I am not able to specify a "package" structure of the Java source code in output, i.e. I can not see the package Java statement as the first line of code in the generate Java source code. I can specify to the Frege compiler where to put the generated code though (via the -d argument).
I think this is the reason why when building an executable Jar, then launching it, I am seeing similar errors (according to different attempts on Gradle tasks) e.g.: no main manifest attribute.
The Frege source code is saved in a file named HelloFrege.fr, the generated Java source code is in a file named HelloFrege.java (I verified the file contains the expected main method).
Here there's a version of the Gradle "Jar task":
//create a single Jar with all dependencies
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Hello Frege Jar Example',
'Implementation-Version': version,
'Main-Class': 'HelloFrege'
}
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
Here there's another version of the Gradle "Jar" task:
jar {
manifest {
attributes 'Main-Class': 'HelloFrege'
}
}
How can I solve this problem? I would like to avoid to manually add the package reference to the automatically generated Java source code file.
If your module name in Frege is unqualified such as HelloWorld, you will not see the package statement generated in Java. The module name will become the class name and the package will be empty or default package.
If your module name is qualified such as foo.bar.HelloWorld, then foo.bar will be the package name and HelloWorld will be the class name in the generated Java source.
The rule is that the last part of the module name becomes the class name and the qualifiers form the package name in the generated Java source.
I am not sure what gradle can do for you in this regard, but without gradle, the following should at least be possible:
... build your jar, as before ...
jar -uvfe project-all.jar HelloFrege
java -jar project-all.jar # run it
This, of course, is just another way to create a manifest. If this works, then it would be time to investigate why gradle refuses to do it.
Postscriptum: After thinking another minute about what the problem might be, it occurs to me that you may think that the source file name/path has anything to do with the java package name. This is not so in Frege, though it is good practice to have the file path match the package name, and the file base name match the class name (just like in Java). In addition, to remove some confusion, use the module keyword in frege. As explained by Marimuthu, the Java package and class name is derived from the frege module name.
Example:
$ cat Foo.fr
module my.org.Baz where
...
$ java -jar fregec.jar -d bin Foo.fr
This generates the Baz class in package my.org, and creates the class file in bin/my/org/Baz.class
I am posting here my findings so far. The combination of Gradle commands that works for me is the following one (calling it from the command line typing gradle clean generateJavaSrcFromFregeSrc fatJar):
task generateJavaSrcFromFregeSrc {
ant.java(jar:"lib/frege3.21.586-g026e8d7.jar",fork:true) {
arg(value: "-j") // do not run the java compiler
arg(value: "-d")
arg(value: "src/main/java") // the place where to put the generated source code (paired to the -d argument)
arg(value: "src/main/frege/HelloFrege.fr")
}
}
jar {
manifest {
attributes 'Main-Class': 'org.wathever.HelloFrege'
}
}
task fatJar(type: Jar) {
from files(sourceSets.main.output.classesDir)
from files(sourceSets.main.output.resourcesDir)
//from {configurations.compile.collect {zipTree(it)}} // this does not include the autogenerated source code
baseName = project.name + '-fatJar'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
The manifest details need to be specified in the jar block of code, if I specify them in the task fatJar then when running the jar I get no main manifest attribute, in [...].
If I use just the block of code jar with the property from("$projectDir") { include 'lib/**'} to include the Frege jar, then I get errors like java.lang.ClassNotFoundException (I think because the Jar is included as it is and not as a set of .class files).
The folder src/main/java/org/wathever needs to be there before running Gradle (additional info: the Maven convention prefix src/main/java with as a suffix the "Java package" as specified inside the HelloFrege.fr source code: module org.wathever.HelloFrege where)
Some useful details I found:
How to build a fat Jar
Another how to build a fat Jar
An "Hello Frege" example without the Gradle management
The Gradle documentation on how to use the Jar task
I am new to Code Coverage and EMMA tool.
I am trying to:
1. Write a simple java program "testClass1.java". Compile it, and a got a "testClass1.class" file.
2. I package this as a jar. "myJar.jar"
3. Instrument this jar using this emma command and got a coverage.em file
C:\Users\emahaboo\Desktop>java -cp emma-2.0.5312.jar emma instr -m overwrite -cp myJar.jar
EMMA: processing instrumentation path ...
EMMA: instrumentation path processed in 156 ms
EMMA: [1 class(es) instrumented, 0 resource(s) copied]
EMMA: metadata merged into [C:\Users\emahaboo\Desktop\coverage.em] {in 7 ms}he emma command.
Now I want to execute this "myJar.jar" file.
I am not sure, what should I do exactly here, because I get the below error:
C:\Users\emahaboo\Desktop>java -cp myJar.jar:emma-2.0.5312.jar myJar
Error: Could not find or load main class myJar
C:\Users\emahaboo\Desktop>java -cp myJar.jar:emma-2.0.5312.jar testClass1
Error: Could not find or load main class testClass1
Can someone help me to proceed. I want to successfully run this program and get the emma code coverage report.
On Windows, items on the classpath need to be separated with semicolons. I would put the whole parameter in quotes:
-cp "myJar.jar;emma-2.0.5312.jar"
If you want to execute a jar file, there must be a main class as the entrance. For the error "Error: Could not find or load main class...", it just means that it can't find the main class. I think the root cause for this is due to your second step: "I package this as a jar. "myJar.jar"". when you packaged it, you need to set the testClass1 as the main class for this jar file. Hope this helps.
i got this error while build application jar with ant
Problem: failed to create task or type bind
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / declarations have taken place.
and this a snippet is my build.xml file:
Your <bind verbose="true" load="true" binding="mdb-src/com/arj/sms/xmlHandler/mapping/binding.xml">
requires task definition of JiBX binding compiler. Just like any other custom Ant task. To make it more clear bind is not a "ant tag" like you call it and isn't "part" of ant syntax. You need to define it:
<taskdef name="bind" .. + classname/classpaths/filesets etc..
You have it?
If you have it, then make sure that task definition has proper path to the lib directory of your JiBX installation. Also note that some versions of Ant may not work properly if the JiBX installation path contains a space character.
Good luck.