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.
Related
I am getting below error when I am starting server or triggering pipeline.
java.sql.SQLException: Unable to load class:
oracle.jdbc.driver.OracleDriver from
ClassLoader:java.net.URLClassLoader#545b995e;
I checked in lib folder of Tomcat and ojdbc jar was also missing
I checked in pom.xml, and dependency was missing, so I put below dependency in pom.xml and triggered a build again.
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc</artifactId>
<version>8.0</version>
<scope>provided</scope>
</dependency>
Still, I am getting same issue. Below is the detail log. What could be the possible reason?
java.sql.SQLException: Unable to load class: oracle.jdbc.driver.OracleDriver from ClassLoader:java.net.URLClassLoader#545b995e;ClassLoader:java.net.URLClassLoader#545b995e
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:316)
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:228)
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:764)
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:692)
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:496)
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:121)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:110)
at org.apache.tomcat.jdbc.pool.DataSourceFactory.createDataSource(DataSourceFactory.java:560)
If you check in maven repo, does not exists the 8.0 version, the correct version is 19.3.0.0
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.
When starting my Quarkus project locally with mvn quarkus:dev I have no errors when executing a function which utilizes JJWT.
However when I export my project into a docker container it gives me an error stating that it can't find DefaultJwtBuilder.
When dockerizing my project I first execute
./mvnw package -Pnative -Dquarkus.native.container-build=true
as stated in the Quarkus docs for creating a Linux executable without GraalVM.
Followed by
docker build -f src/main/docker/Dockerfile.native -t quarkus-quickstart/getting-started .
When starting the project with Docker Desktop I get the error.
The dependencies I have in my pom.xml are the following.
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.2</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.2</version>
<scope>runtime</scope>
</dependency>
The detailed error message is
io.jsonwebtoken.lang.UnknownClassException: Unable to load class named [io.jsonwebtoken.impl.DefaultJwtBuilder] from the thread context, current, or system/application ClassLoaders. All heuristics have been exhausted. Class could not be found. Have you remembered to include the jjwt-impl.jar in your runtime classpath?
at io.jsonwebtoken.lang.Classes.forName(Classes.java:92)
at io.jsonwebtoken.lang.Classes.newInstance(Classes.java:136)
at io.jsonwebtoken.Jwts.builder(Jwts.java:141)
at org.roguedevelopment.logic.JWT.GenerateJWT(JWT.java:21)
at org.roguedevelopment.logic.JWT_ClientProxy.GenerateJWT(JWT_ClientProxy.zig:224)
at org.roguedevelopment.logic.AuthHandler.LoginUser(AuthHandler.java:62)
at org.roguedevelopment.logic.AuthHandler_ClientProxy.LoginUser(AuthHandler_ClientProxy.zig:164)
at org.roguedevelopment.controllers.AuthController.login(AuthController.java:72)
at java.lang.reflect.Method.invoke(Method.java:566)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:643)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:507)
at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:457)
at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:459)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:419)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:393)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:68)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:131)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.access$000(VertxRequestHandler.java:37)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:94)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
at java.lang.Thread.run(Thread.java:834)
at org.jboss.threads.JBossThread.run(JBossThread.java:479)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:517)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
The dockerfile I use to build my docker image is
## Stage 1 : build with maven builder image with native capabilities
FROM quay.io/quarkus/centos-quarkus-maven:20.2.0-java11 AS build
COPY pom.xml /usr/src/app/
RUN mvn -f /usr/src/app/pom.xml -B de.qaware.maven:go-offline-maven-plugin:1.2.5:resolve-dependencies
COPY src /usr/src/app/src
USER root
RUN chown -R quarkus /usr/src/app
USER quarkus
RUN mvn -f /usr/src/app/pom.xml -Pnative clean package
## Stage 2 : create the docker final image
FROM registry.access.redhat.com/ubi8/ubi-minimal
WORKDIR /work/
COPY --from=build /usr/src/app/target/*-runner /work/application
# set up permissions for user `1001`
RUN chmod 775 /work /work/application \
&& chown -R 1001 /work \
&& chmod -R "g+rwX" /work \
&& chown -R 1001:root /work
EXPOSE 8000
USER 1001
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
Any help would be greatly appreciated.
I know, I'm quite late. I got the same issue with jjwt 0.11.5. I didnot had <artifactId>jjwt-impl</artifactId>.
I added this dependency and got some Serializer error
Unable to find an implementation for interface io.jsonwebtoken.io.Serializer using java.util.ServiceLoader. Ensure you include a backing implementation .jar in the classpath, for example jjwt-impl.jar, or your own .jar for custom implementations.
Then i added
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId> <!-- or jjwt-gson if Gson is preferred -->
<version>0.11.1</version>
<scope>runtime</scope>
</dependency>
and changed all the versions to 0.11.1 and it worked.
It doesn't work because your are using native mode and the io.jsonwebtoken library seems that does not support it.
Quarkus does its best to integrate libraries and make them work with native mode, by adding the pieces required by native mode. For native mode limitations, please check this link: https://www.graalvm.org/reference-manual/native-image/Limitations/.
Please check Quarkus JWT support that works with native mode: https://quarkus.io/guides/security-jwt.
If you really want to keep using io.jsonwebtoken you may need to provide additional metadata to the native image build: https://quarkus.io/guides/writing-native-applications-tips.
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?
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