I am working on a Project for my university in a group of 7 people. We have a Problem, that we have different outputs depending on what we use to compile one of our Components.
If we use the .class files, which are also created by maven everything works fine. But if we use the jar which maven creates we get an annoying bug. Some elements of an specific ArrayList get cut.
The Code runs with no errors aswell, but the outputs are different. I put an example of the both outputs below the text.
How is this even possible? Btw everyone of the group get the same (wrong) output if the code runs with jar. We tried to search for errors in the code but everything seems fine. We also double checked the pom.xml and tried to a jar with dependencies and without dependencies.
If you need more information about our code let me know, but I guess the Problem has to do with maven or the pom especially, because with the classes everything works fine as mentioned above.
Pom.xml
<!-- project was generated with
mvn -B archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=dbp17 -DartifactId=dbpedia-provenience -->
<!-- for documentation refer to https://maven.apache.org/pom.html#The_Basics -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- name of the author group -->
<groupId>dbp17</groupId>
<!-- name of the project,
together with the groupId it should uniquely identify this project -->
<artifactId>dbpedia-provenance</artifactId>
<!-- the result of `mvn package` is a jar file with the compiled sources
this uses the maven-jar-plugin https://maven.apache.org/components/plugins/maven-jar-plugin/
This plugin provides the capability to build jars. -->
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<!-- defines properties / variables; https://maven.apache.org/pom.html#Properties
Maven properties are value placeholder, like properties in Ant.
Their values are accessible anywhere within a POM by using the notation ${X}, where X is the property. -->
<properties>
<!-- sets variables for which version of the dependencies to use -->
<jena.version>3.2.0</jena.version>
<slf4j.version>1.7.24</slf4j.version>
<junit.version>4.11</junit.version>
<!-- sets encoding to UTF-8 for standardized, platform-independent build
as describe here: https://maven.apache.org/general.html#encoding-warning -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- Apache Jena: (from wikipedia:)
Apache Jena is an open source Semantic Web framework for Java.
It provides an API to extract data from and write to RDF graphs.
The graphs are represented as an abstract "model".
code taken from https://jena.apache.org/download/maven.html -->
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>apache-jena-libs</artifactId>
<type>pom</type>
<version>${jena.version}</version>
</dependency>
<!-- for Apache Jena: (from https://www.slf4j.org/:)
The Simple Logging Facade for Java (SLF4J) serves
as a simple facade or abstraction for various logging frameworks
(e.g. java.util.logging, logback, log4j) allowing the end user
to plug in the desired logging framework at deployment time.
code taken from https://www.slf4j.org/faq.html#maven2 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>${slf4j.version}</version>
<!-- with this enabled, an error message is thrown
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
<scope>test</scope> -->
</dependency>
<!-- autogenerated, for Unit Tests with JUnit-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<!-- <scope>test</scope> -->
</dependency>
</dependencies>
<build>
<plugins>
<!-- per default maven doesn't build an executable jar
there are several ways to get maven to build standalone executable jar file
as explained for example here: http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven/#answer-23986765 -->
<!-- bundle all dependencies together with the project into one big jar
using the maven-assembly-plugin
code taken from http://maven.apache.org/plugins/maven-assembly-plugin/usage.html
sections 'Execution: Building an Assembly' and 'Creating an Executable JAR' -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>DumpParser</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
output using .class files
command: java -cp target/classes/ DumpParser TestInput.txt
counter ID\Revisions-IDs author
81 99248866 Overberg 2012-02-04T16:08:11Z
82 99248577 Overberg 2012-02-04T16:00:41Z
83 99248479 Overberg 2012-02-04T15:58:24Z
84 99248404 Overberg 2012-02-04T15:56:38Z
85 99248239 Overberg 2012-02-04T15:52:36Z
86 99214062 Overberg 2012-02-03T18:08:33Z
87 99207128 Overberg 2012-02-03T15:04:58Z
88 99205924 Overberg 2012-02-03T14:32:54Z
89 99205852 Overberg 2012-02-03T14:31:07Z
90 99198643 Overberg 2012-02-03T11:48:22Z
output using jar
command: java -jar target/dbpedia-provenance-1.0-SNAPSHOT-jar-with-dependencies.jar TestInput.txt
or
command: java -cp target/dbpedia-provenance-1.0-SNAPSHOT-jar-with-dependencies.jar DumpParser TestInput.txt
counter ID\Revisions-IDs author timestamp
81 99248866 Overberg 2012-02-04T16:08:11Z
82 99248577 Overberg 2012-02-04T16:00:41Z
83 99248479 Overberg 2012-02-04T15:58:24Z
84 99248404 Overberg 2012-02-04T15:56:38Z
85 99248239 Overberg 2012-02-04T15:52:36Z
86 99214062 Overberg 201
87 99207128 Overberg 2012-02-03T15:04:58Z
88 99205924 Overberg 2012-02-03T14:32:54Z
89 99205852 Overberg 2012-02-03T14:31:07Z
90 99198643 Overberg 2012-02-03T11:48:22Z
These are only very small pieces of our output, I would guess it happens to like 1 % of the timestamps and only the timestamps.