I am facing a problem with maven dependency.
I have a maven project called DdsInterface. Inside the pom.xml there is this dependency
...
<dependency>
<groupId>it.snam.ned</groupId>
<artifactId>ned-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
...
That is used in a class to import the NedRestTemplate object. Everything in the project is working.
Then I build a jar with command maven clean install and generate a ned-dds-interface.jar.
I then install the library in my local repository .m2 with command
mvn install:install-file -Dfile="target/ned-dds-interface.jar" -DgroupId=ned-dds-interface -DartifactId=ned-dds-interface -Dversion=1.2 -Dpackaging=jar
Now I want to use this library ned-dds-interface in another project call Portal. So in the pom.xml I created the dependency
<dependency>
<groupId>ned-dds-interface</groupId>
<artifactId>ned-dds-interface</artifactId>
<version>1.2</version>
<scope>compile</scope>
</dependency>
Finally I create the war for the project to run in a Web logic server using
mvn clean install
and then deploy the package Portal that successfully run on Weblogic. But executing a function I get the following error
Root cause of ServletException.
java.lang.NoClassDefFoundError: it/snam/ned/libs/core/NedRestTemplate
at it.snam.ned.libs.dds.v2.AbstractDdsDaoImpl.<init>(AbstractDdsDaoImpl.java:25)
at it.snam.ned.libs.dds.v2.DdsFolderDaoImpl.<init>(DdsFolderDaoImpl.java:36)
at eng.la.controller.DdsController.getFolderInfo(DdsController.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Truncated. see log file for complete stacktrace
Can someone please help me with this problem?
Related
When doing a mvn clean install -U I am getting:
[ERROR] Failed to execute goal on project xxx-security: Could not resolve dependencies for project xxx:xxx-security:jar:50-SNAPSHOT: Failed to collect dependencies at
xxx:xxx-persistence:jar:50-SNAPSHOT -> org.mybatis:mybatis:jar:${mybatis.version}: Failed to read artifact descriptor for org.mybatis:mybatis:jar:${mybatis.version}: Could not
transfer artifact org.mybatis:mybatis:pom:${mybatis.version} from/to nexus (http://example.net/repository/Standard/): Failed to transfer file: http://example.net/repository/Stan
dard/org/mybatis/mybatis/$%7Bmybatis.version%7D/mybatis-$%7Bmybatis.version%7D.pom. Return code is: 400 , ReasonPhrase:Invalid repository path. -> [Help 1]
What I don't get is why maven is using mybatis.version in the url to get the dependency rather than a version number. I have searched the code and cannot find mybatis.version in there. I did find:
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.0.4</version>
</dependency>
So why is maven using mybatis.version rather than 3.0.4?
It looks like your xxx:xxx-persistence:jar:50-SNAPSHOT jar has internal dependency with org.mybatis:mybatis:jar:${mybatis.version}. Provided that you define mybatis.version in your properties.
You can do following:
Execute mvn dependency:tree to check which specific jar has this dependency.
Also define <mybatis.version>3.0.4</mybatis.version> under <properties> section of pom.xml. You can optionally remove <version>3.0.4</version> from your <dependency> section where you defined mybatis dependency.
Version: maven 3.6.3
I try to put this dependency into pom.xml,but it not auto download
<dependency>
<groupId>com.datastax.spark</groupId>
<artifactId>spark-cassandra-connector_2.11</artifactId>
<version>2.4.3</version>
</dependency>
so i use command line:
mvn dependency:get -DremoteRepositories=http://repo1.maven.org/maven2 -DgroupId=com.datastax.spark -DartifactId=spark-cassandra-connector_2.11 -Dversion=2.4.3 -Dtransitive=false
but it give me couldn't download artifact error log :
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:get (default-cli) on project standalone-pom: Couldn't download artifact: Could not transfer artifact com.datastax.spark:spark-cassandra-connector_2.11:jar:2.4.3
Do I need to upgrade remoteRepositories?
Why are some commonly used packages automatically downloaded quickly ? such as guava,commons-lang.
Some new versions are always problematic to rely on for download,Is it no cache in
repository?
How can I download the dependency? Thanks
My project settings are SpringBoot4+Mybatis+Oracle10g.This project clearly requires a ojdbc driver. So I installed Ojdbc6 into local maven repository first with the command.
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dpackaging=jar -Dversion=11.2.0.4 -Dfile=ojdbc6.jar -DgeneratePom=true
Then I import it in the pom file like this.
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4</version>
</dependency>
Ater that,i reimported the project dependencies and found that ojdbc6.jar showed up in the external libraries. All seemed to be perfect except when I try to run codes that fetches data from Oracle, this error appeared
2018-05-01 15:57:33.709 [http-nio-8080-exec-8] ERROR org.apache.tomcat.jdbc.pool.ConnectionPool - Unable to create initial connections of pool.
java.sql.SQLException: Unable to load class: oracle.jdbc.driver.OracleDriver from ClassLoader:sun.misc.Launcher$AppClassLoader#b4aac2;ClassLoader:TomcatEmbeddedWebappClassLoader
context: ROOT
delegate: true
----------> Parent Classloader:
sun.misc.Launcher$AppClassLoader#b4aac2
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:283)
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203)
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:735)
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:667)
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:482)
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154)
It doesn't make any sense to me.How could it not be able to load jdbc class when ojdbc.jar is clearly in the classpath?
Goto directory structure of your project where pom.xml lies and run following command
mvn spring-boot:run
if this successfully runs server then there is problem of classpath only.
Run this command mvn -U idea:idea. This command will add ojdbc jar into your IntelliJ classpath.
I am trying to use a jar given by my teacher in my code. So I placed the jar in a lib directory in my project and ran this command :
mvn install:install-file -Dfile=lib/IDLogger.jar -DgroupId=IDLogger -DartifactId=IDLogger -Dversion=1.0 -Dpackaging=jar
Everything is fine.
Then I add the dependency to the pom :
<dependency>
<groupId>IDLogger</groupId>
<artifactId>IDLogger</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
But then when I try to use the jar, the compilation fails and tells me that the symbol(the class) can't be found. I even tried adding an import statement :
import IDLogger.IDLogger;
but it tells me that there is no such package.
How can I use this jar in my code in maven?
This is the code :
IDLogger logger = IDLogger.getInstance();
...
logger.logID(id);
I get the symbol IDLogger not found error
This is as much as I know about this custom jar...
Try to add your lib in system scope :
1. add in your project :
Your Project/lib
+IDLogger.jar
2. in your pom :
<dependency>
<groupId>IDLogger</groupId>
<artifactId>IDLogger</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/IDLogger.jar</systemPath>
</dependency>
I am using the maven-jspc-plugin in my pom.xml.
When i try to execute the jsp-compile goal (which executes the plugin) I get:
Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.apache.juli.logging.Slf4jLog.<init>(Slf4jLog.java:29)
at org.apache.juli.logging.LogFactory.getLog(LogFactory.java:54)
at org.apache.juli.logging.LogFactory.getLog(LogFactory.java:35)
at org.apache.sling.scripting.jsp.jasper.compiler.OriginalTldLocationsCache.<init>(OriginalTldLocationsCache.java:81)
at org.apache.sling.maven.jspc.JspcMojo.initServletContext(JspcMojo.java:426)
I've tried downloading the (open) source for the maven-jspc-plugin and i am able to easily "mvn install" -- I don't get any build issues, however when i use that build in my project pom it still crashes and tells me it can't find LoggerFactory.
I've logged an issue with the Apache Sling project but am not making much headway.
https://issues.apache.org/jira/browse/SLING-2350
This link includes some more troubleshooting info as well as a simple maven project that uses the maven plugin. downloading the jspc-test.zip and "mvn install"ing will result in the error I've mentioned.
Also, i took a peak at the org.apache.juli pom.xml and it doesnt appear to list any dependencies at all.
Any thoughts on how to resolve would be appreciated.
Thanks!
Plugin dependencies are supplied in a different part of the POM:
<project>
<dependencies>
<!-- dependencies defined here don't get included for plugins -->
...
</dependencies>
<build>
<plugins>
<plugin>
.... jspc plugin section ....
<dependencies>
<dependency>
<!-- Try adding slf4j here --->
Though it does sounds like their POM is invalid if it doesn't already specify slf4j.