I'm getting a dependency issue with a jar I'm attempting to use.
I receive the following error
remote: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project sparq: Compilation failure: Compilation failure:
remote: [ERROR] /var/lib/openshift/55846322500446673d000007/app-root/runtime/repo/src/main/java/ServerQuery.java:[3,0] error: package com.github.koraktor.steamcondenser does not exist
remote: [ERROR] /var/lib/openshift/55846322500446673d000007/app-root/runtime/repo/src/main/java/ServerQuery.java:[8,8] error: cannot find symbol
remote: [ERROR] class ServerQuery
remote: [ERROR] /var/lib/openshift/55846322500446673d000007/app-root/runtime/repo/src/main/java/ServerQuery.java:[8,34] error: cannot find symbol
Here is the offending java file.
package helpers;
import com.github.koraktor.steamcondenser.*;
public class ServerQuery {
public static String getPlayers() {
SourceServer server = new SourceServer("66.150.155.152",27015);
server.initialize();
return server.toString();
}
}
I've added the following dependency to my pom.xml
<dependency>
<groupId>com.github.koraktor</groupId>
<artifactId>steam-condenser</artifactId>
<version>1.3.9</version>
</dependency>
I've also added the following action_hook pre_build script
mvn install:install-file -Dfile=./app-root/repo/steam-condenser.jar -DgroupId=com.github.koraktor -DartifactId=steam-condenser -Dversion=1.3.9 -Dpackaging=jar
Here's the GitHub for the project
https://github.com/koraktor/steam-condenser-java
And the website for it
http://koraktor.de/steam-condenser/usage/
Any ideas? Completely lost. Help much appreciated.
Since you are including the jar file in your project already, trying to manage the dependency with Maven seems like overkill. You should be able to put the jar file in your project's lib directory like this article describes. Then you won't need to configure that dependency in Maven at all.
I would use Maven for any dependencies that you want to download at the time your application is being built. Any jar files that you are checking into your project shouldn't need to be configured in Maven.
Just by looking at the question and the excerpts provided, I believe you are struggling with the basics of Maven. If I understand the situation correctly you have a library (which is not written by you):
once added to your project as a Maven dependency. This seems reasonable if you want to use it.
once the source code of the library incorrectly added to your own Java project.
remote: [ERROR] /var/lib/openshift/55846322500446673d000007/app-root/runtime/repo/src/main/java/ServerQuery.java:[3,0] error: package com.github.koraktor.steamcondenser does not exist
Based on the errormessage above it seems you have copied one of the sourcefiles from the library into your project. This is now causing problems. The main one is that without your source-folder (src/main/java) correctly representing the package structure declared in the source file (com.github...) it cannot be compiled. Hence the errormessage:
package com.github.koraktor.steamcondenser does not exist.
First of all you need to remove this copy-pasted file entirely an just use the dependency-management feature of Maven to get the library on classpath. After that just follow the examples given by the author of the library using the link you have already found (http://koraktor.de/steam-condenser/usage/).
Related
I have a maven project that works perfectly fine locally but after I've pushed it to a remote repository on GitHub and cloned it somewhere else (even to a new location on the same computer), one of the imports does not work because
Cannot resolve symbol 'DefaultMouseManager'
and of course maven install is failing with a lot of compilation errors like this one:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/.../CustomMouseManager2.java:[6,36] cannot find symbol
symbol: class DefaultMouseManager
location: package org.graphstream.ui.view.util
Is there anything I should check that may cause this problem?
Is the problem the class DefaultMouseManager or is it something more general?
(tl,dr at the end)
We have a small method that generates self-signed SSL certificate and it obviously depends on sun.security.x509. Currently we are still building it using JDK8 because of that, even though the rest of the codebase (it's only small, single library) is build using JDK11 and run with JVM11.
Unfortunately there aren't replacement in the main JDK, as per (and CertificateFactory has little to nothing with generating certificates, contrary to what it's javadoc states…):
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8165481
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8058778
One option would be to use BouncyCastle, but that's additional 4MB that we really don't need, especially for such small task so I was pondering ways to access it while
From what I saw, the package and required classes are still package and relevant classes are still there (see sun.security.x509 on github but when building it (using maven) I get error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project: Compilation failure: Compilation failure:
[ERROR] OldSelfSignedCertificateGenerator.java:[20,25] package sun.security.x509 does not exist
[ERROR] OldSelfSignedCertificateGenerator.java:[71,45] cannot find symbol
[ERROR] symbol: class X509CertInfo
[ERROR] location: class OldSelfSignedCertificateGenerator
I was searching a bit and adding:
<arg>--add-exports</arg><arg>java.base/sun.security.x509=ALL-UNNAMED</arg>
to maven-compiler-plugin and it somewhat worked - I only get WARNING not regarding sun.security.x509 package:
[WARNING] OldSelfSignedCertificateGenerator.java:[20,25] sun.security.x509.AlgorithmId is internal proprietary API and may be removed in a future release
BUT! Now it seems I entered (unwillingly!) module system and it complains about access to other, basic Java classes (and one more our dependency):
[ERROR] CertificateUtil.java:[35,17] package java.util.logging is not visible
(package java.util.logging is declared in module java.logging, but module java.base does not read it)
I tried adding java.logging module in the same manner to exports but without much success. It also seems that I would have to convert both this library and it's dependency to module system, which is not really desired.
The question is somewhat related to How to generate a self-signed certificate using only JDK supported classes?
tl,dr;
is there a way to compile library using sun.security.x509 package under JDK 11 without module system? Some simple switch?
It turns out that presumably it has to do with the fact that builds produced by newer JDK (9+) Versions won't be executable under JDK8:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>9</source>
<target>9</target>
<release combine.self="override"></release>
<compilerArgs>
<arg>--add-exports</arg><arg>java.base/sun.security.x509=ALL-UNNAMED</arg>
</compilerArgs>
</configuration>
</plugin>
To include sun.security.[somePackage] classes in gradle you may add:
tasks.withType(AbstractCompile) {
options.compilerArgs += ["--add-exports", "java.base/sun.security.util=ALL-UNNAMED"]
options.compilerArgs += ["--add-exports", "java.base/sun.security.pkcs=ALL-UNNAMED"]
}
I learning Spring development and trying to configure the Spring framework step by step following a project on Github (the website is: https://github.com/spring-projects/spring-framework/wiki/Building-a-distribution-with-dependencies). After typing in the command $ ./gradlew depsZip to Run the depsZip gradle task . the following information was shown with a failure:
:spring-aspects:compileJava
Download http://repo.springsource.org/libs-release/org/aspectj/aspectjrt/1.7.1/a
spectjrt-1.7.1.jar
[ant:iajc] C:\Users\Zihan\Documents\GitHub\spring-framework\spring-aspects\src\m
ain\java\org\springframework\beans\factory\aspectj\AbstractBeanConfigurerAspect.
aj:1 [error] The type java.lang.CharSequence cannot be resolved. It is indirectl
y referenced from required .class files
[ant:iajc] (no source information available)
[ant:iajc] C:\Users\Zihan\Documents\GitHub\spring-framework\spring-aspects\src\m
ain\java\org\springframework\mock\staticmock\AbstractMethodMockingControl.aj:19
[error] The import java.util.Arrays cannot be resolved
[ant:iajc] import java.util.Arrays;
[ant:iajc] ^^^^^^^^^^^^^^^
[ant:iajc] C:\Users\Zihan\Documents\GitHub\spring-framework\spring-aspects\src\m
ain\java\org\springframework\mock\staticmock\AbstractMethodMockingControl.aj:87
[error] Arrays cannot be resolved
[ant:iajc] if (!Arrays.equals(this.args, args)) {
[ant:iajc] ^
[ant:iajc]
[ant:iajc] 3 errors
:spring-aspects:compileJava FAILED
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\Zihan\Documents\GitHub\spring-framework\spring-aspects\aspects.
gradle' line: 30
* What went wrong:
Execution failed for task ':spring-aspects:compileJava'.
> compile errors: 3
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 42.798 secs
C:\Users\Zihan\Documents\GitHub\spring-framework [(abdcefb...)]>
could any help me with the configuration problem. really appreciate if giving some guidance.
Thanks in advance!
Firstly, why you can't use a dependency managment tool like maven or gradle? At your link I read
Although it is strongly recommended that Spring Framework users take advantage of the transitive dependency management features of build systems like Gradle, Maven, and Ivy, some teams cannot use these tools. This is usually due to corporate restrictions or working with legacy builds
Using tool defined above simply the build and the mantainence to a spring project. Then to start with a spring project you can following this Building Spring Project
I have a little problem in Eclipse with a package . The error output is Package (name of package ) does not exist .
I have a package called de.baimos.blueid.lockserver.demo.exec . But Eclipse is looking for a package called de.baimos.blueid.lockserver.api.exec . This package is can be found in my Project nowhere .
My current situation is this: I have two projects that work as a project. Now you can in Eclipse under Properties - Add a project to a different > Project -> Java Build Path . But if I want to run Maven install I get the error above. At first I thought it would be in the pom.xml file . But I noticed that it is not possible to merge two pom.xml files. My project was to make the inheritance , however, by themselves , whom I put them together leads . Did anyone of you ever such a problem , or can someone help me ?
Thanks in advance for your help .
That is the error:
[ERROR] /home/test/workspace/HeartbeatService/src/main/java/de/baimos/blueid/lockserver/demo/exec/DemoCommandExecutionEventListener.java:[3,44] error: package de.baimos.blueid.lockserver.api.event does not exist
[ERROR] /home/test/workspace/HeartbeatService/src/main/java/de/baimos/blueid/lockserver/demo/exec/DemoCommandExecutionEventListener.java:[4,44] error: package de.baimos.blueid.lockserver.api.event does not exist
[ERROR] /home/test/workspace/HeartbeatService/src/main/java/de/baimos/blueid/lockserver/demo/exec/DemoCommandExecutionEventListener.java:[5,44] error: package de.baimos.blueid.lockserver.api.event does not exist
[ERROR] /home/test/workspace/HeartbeatService/src/main/java/de/baimos/blueid/lockserver/demo/exec/DemoCommandExecutionEventListener.java:[6,44] error: package de.baimos.blueid.lockserver.api.event does not exist
[ERROR] /home/test/workspace/HeartbeatService/src/main/java/de/baimos/blueid/lockserver/demo/exec/DemoCommandExecutionEventListener.java:[8,59] error: cannot find symbol
Maven can't see what you specify in Eclipse's Java Build Path; it's a command line tool that runs outside / without Eclipse.
Instead, you have to do mvn install in the first project.
Then you can add a dependency to this project in the second project's POM.
Maven will then make sure that Eclipse add the first project to the classpath as well without manually changing the build path in the UI.
I am trying to "Mavenize" our existing Commerce solution. However, I am getting a weird error when I try to run mvn compile I get the following error.
[ERROR] /home/user/tmp/IBM/WCDE_ENT70/workspace/WebSphereCommerceServerExtensionsData/ejbModule/org/ecommerce/wcs/changerequest/ChangeRequestAccessBean.java:[347,32] cannot find symbol
[ERROR] symbol : method createAccessBeans(java.util.Collection)
[ERROR] location: class org.ecommerce.wcs.changerequest.ChangeRequestAccessBean
When I check the class it is related to the com.ibm.ivj.ejb.runtime.AbstractEntityAccessBean class which IBM has neglected to include JavaDoc for anywhere. I look into eclipse and it shows me the method in question was correct using code complete, however, it still fails with maven.
I am wondering if it isn't a customisation to the IBM jre (I am not using that for this POC) and if there is no way around it (short of extending the class and reimplementing).
Anyone?
Problem had to do with multiple imports of different versions of the same dependency. Now this has been resolved.