Connecting with mongodb in openshift is showing error. - java

I am developing a project based on java and mongodb. MongoDb is my backend, but when I try to connect it, says
[ERROR] /var/lib/openshift/someclass.java: error: cannot find symbol
[ERROR] package com.mongodb
I know this is a problem in Maven build as it cant find the methods and classes in my DBconnect class.
Please tell me how to solve the problem. I need to figure out as soon as possible. How to include my jar in maven repo and upload to openshift.

Double check that your dependencies are listed correctly in your pom.xml

If you can't or don't want to add the dependency to your pom.xml file, try following this KB article about how to add the jar file to your project: https://www.openshift.com/kb/kb-e1087-how-to-include-libraries-jar-files-in-your-java-application-without-using-maven

Related

Missing pom errror in maven while downloading ws4j dependency

I want to use ws4j for my project. And i can't able to connect to the internet all the time. So, most of time i download dependency to local repository using dependency:get command. Then i use it in project.
like that i tried download ws4j-1.0.1. But i get a error while downloading. It says Missing POM for edu.cmu.lti:ws4j:jar:1.0.1. But there is a pom file in the repository. see the url ws4j repository. But why i get the error.
The command i used was mvn dependency:get -Dartifact=edu.cmu.lti:ws4j:1.0.1
The image of the error i get
I am using maven version 3.6.3
Please, someone help to solve this issue.
mvn dependency:get -Dartifact=edu.cmu.lti:ws4j:1.0.1
This tries to download the dependency from https://repo.maven.apache.org/maven2/ and since it does not find the dependency there, it fails.
You need to specify "-DremoteRepositories" to fetch it from a remote repository.
For example: mvn dependency:get -Dartifact=org.apache.maven:maven-core:2.2.1:jar:sources -DremoteRepositories=https://repo.maven.apache.org/maven2 -Ddest=/tmp/myfile.jar
Please refer https://maven.apache.org/plugins/maven-dependency-plugin/usage.html

How to configure maven to use different artifact?

I m new to Spring framework. Need a help.
When I create a simple Spring Starter Project using STS (Type : maven, Dependency: Spring Web), it throws an error on POM.xml saying "Project build error: Non-resolvable parent POM..."
This looks like a firewall issue that maven repositories cannot be downloaded from internet in my network. But I have a artifactory where my network can access and download
all required jars from here. Something like: http://artifactory.mycompany.com/artifactory/spring-framework which has a username/password also.
So how do I tell maven to download dependencies from this repository instead of going outside and get it. Can anyone help here.
Thank you,

Maven: package does not exist

I was developing an application like ordinary Java Web application, but because I want to deploy it to Heroku, I needed it to become Maven project, so I created an empty Maven project with Eclipse and copied all of libraries I was using and all of my source code.
When I do mvn compile on my local machine, it goes well, but app isn't really working.
When I do git push heroku master I get error like
package com.mysite.java.classes does not exist
Locally I have maven-compiler-plugin ver 3.1 and source and target set to 1.7, although I'm using 1.8 jdk. I changed it to 1.7 since I saw here Pushing my repository to heroku fails that it has issues with Heroku.
Here is a project structure
I'm not really experienced with Maven, so I hope somebody can help. I guess imports aren't working as intended because I get whole list of errors like this
symbol: class Connection
location: class com.vukstankovic.professionalorientation.Personalities
[ERROR] /tmp/build_0bc5a80c-dc14-4126-b15b-69390f18dc9f/src/main/java/com/vukstankovic/professionalorientation/Personalities.java:[48,19] cannot find symbol
Class Connection in this example is mysql class from com.mysql.jdbc.Connection

Where to put JDBC driver in Java console program?

I've created a little test app as a console program in java that tries to work with hibernate, and I'm trying to connect to an instance of SQL-Server-2008. But when I run my app I'm getting an error stating that it can't find the JDBC driver.
Now I've created the project as a maven project so if the driver is available as a maven dependency that would be great, although I couldn't find it. I do however have the actual .jar file, but I have no idea where to put this in my project structure. Which look like this:
So.. any help would greatly be appreciated! Thanks :)
Download it from http://msdn.microsoft.com/en-us/sqlserver/aa937724 and then install
mvn install:install-file -Dfile=sqljdbc4.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=3.0 -Dpackaging=jar
Once you include it using maven, it is referenced from maven directory.

how to mvn deploy-deploy:file from java app

I am trying to deploy a file to the local repository using maven-embedder 3.0.4 from java program, but I'm getting following error:
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file
(default-cli) on project test: Failed to deploy artifacts/metadata: No connector available
to access repository local (file://~/.m2/repository) of type default
using the available factories
I'm trying to achieve this with MavenCli.doMain(String[], String, PrintStream, PrintStream) function, but it seems I can't make it work.
Any help will be very appreciated. Also, if there is another way to deploy file from java program please let me know.
I would suggest to use Aether instead of Maven embedder. Source on github.

Categories