Hibernate + Maven + MySQL Connector - java

I have a little bit of a problem here.
When I started a new project in Eclipse for instance, I add a new dependency with Maven to manage the MySQL connector dependency.
But when I configure a new Driver Definition, it says that it is unable to locate JAR/zip file of the driver definition mysql-connector-java. But as long as I understand it is manage by Maven so it should be anywhere on the Eclipse project right? If I have to downloaded manually and save it on my local drive what is the use of manage that dependency with Maven?

Not sure about maven, but I use Gradle... In these cases, what happens, there is a .gradle folder available.
We normally delete the ...users/.gradle/files/cache/{project} contents from the same path and do the gradle refresh. You can try with the same.

Related

JDBC ClassNotFound even with MySQL library

So I am trying to connect to my server, I had it working before but now I moved to a different machine it's not working as you can see below.
I have added the MySQL driver into my path and I'm not sure what the problem could be.
Any ideas?
Thanks.
You indeed have defined that MySQL connector is a library for your project, but you also need to add it as a module dependency on the Modules tab in Project Structure.
If you haven't dependency management such as maven (gradle, etc), create lib folder in project root folder. Move jar to lib folder and right click on it and select "Add as library".
This should help you.

How to download all possible maven dependencies so they are local

I work behind a very massive firewall that likes to hiccup on random connections, which makes all work with remote repositories a living nightmare for me!
I am looking to work with a project from Git (this one https://github.com/mrniko/netty-socketio) which heavily utilizes maven for downloading dependencies.
What I would like to do is on another terminal (such as http://cloud9.io or something) download all the maven dependencies so that the entire project can be run standalone.
I have already tried mvn clean install and then zipping up the source folder, but its actually not enough! I still get ClassNotFound related errors when I try to run the project locally in eclipse. And for the record, I did add the compiled *.class files in the build properties, so Eclipse knows where they are. It seems like there are some random classes that get generated dynamically which still aren't present (such as log4j -- and I really don't want to hunt each one down individually)
I am wondering if there is a fully thorough way to download all possible dependencies from maven and then either run a project 100% standalone, or create a local maven server from it?
I am running Java 7 on Eclipse Luna and I do have Maven installed on my windows 7 machine (though again it barely works on remote repositories). I also have a Cloud9 instance which I could use to run Maven commands, then zip up the results for local download.
When you execute mvn clean install, maven downloads all dependencies of currently built project to your local maven repository. This is usually located in
%USERPROFILE%\.m2\repository
When you build your project, maven uses that path, to lookup required dependencies.
If you want do download them all, you can try using mvn dependency:copy-dependencies. Then, you'll find all project dependencies intarget/dependencies directory of your project. This also includes transitive dependencies.
To add them all as eclipse dependencies, you may want to try maven-eclipse-plugin. Using that plugin, you can generate eclipse .project and .classpath files, using mvn eclipse:eclipse command. This will populate eclipse files with required dependencies from maven. You should then import the project to eclipse using Import existing projects into workspace, instead of Import existing maven projects.
maven-eclipse-plugin will add all those jars relative to a folder specified by M2_REPO variable. Just make sure you edit this variable inside eclipse project properties, and you should be set.
I've had to deal with similar issues. I would find that due to changes in firewall policies, occasionally all the .jar files in my project had been updated to be a 1K file that, when opened within notepad++ contained a message from the firewall saying that the download had been blocked.
I recommend looking into Nexus for your local repository management, it means your local projects don't have to go past your firewalls to check for maven updates.
http://www.andrejkoelewijn.com/blog/2010/03/09/getting-started-with-nexus-maven-repository-manager/
Use dependency plugin go-offline task.

Adding Sherlock os a Maven dependency behind a firewall and without referenceing a project

My company operates behind a firewall with no access to outside networks (including the internet.) We use Maven and wish to use the ActionBarSherlock code. There are two problems:
If you want to simply include the dependency to the libapk in your pom file, you need internet connectivity to download this file.
Otherwise, you must load in the Sherlock as a separate project and reference it in your Android project. This is a hassle in that anybody else that wants to work on the project must download both projects, not to mention that Maven will still not work.
Is there any way to install Sherlock as a true dependency (installed in your Maven repository) without internet and without creating another project?
I tried several things (making a libapk from the actionbarsherlock project and sticking it in the repo, Creating a jar from the actionbarsherlock project and adding it to libs folder - but then you cannot find the resources needed like themes, adding the .jar file in to maven) but nothing seems to work.
Any help would be appreciated.
You can manually install jars into your local maven repository:
Guide to installing 3rd party JARs
Later if maven tries to access internet when compiling or on other phase you can use mvn -o to manage dependencies offline

why I can use the sources or jar downloaded in my project?

I am trying to use Maven and JDeveloper for a week now and I'm always get stuck with the same problem. I can download and install the extensions and create new Maven projects. When I package or compile them I can see that the sources are being downloaded and added to my local repository but they are not added in my .jar and I cannot use them in my project unless I add them as lib manually in my project.
If I try to add the folder (where the downloaded jars are) as lib folder to project they are only added as jar and I cannot use them.
Is there another way to update my dependencies from JDeveloper? How can I integrate them properly to my project so I can use them? Is there a newer Hands-On maybe solving my problems? What am I doing wrong? Is there a template project to download maybe? I hope I could explain my problem good enough...

Required Java libraries in Eclipse when working on multiple OSs

I'm developing an AppEngine project in Java.
I'm working on a MacBook and on other two PCs.
I'm using a hosted SVN as my RC.
I included some libraries from the GAE plugin in my project:
gwt-dev.jar, gwt-user.jar', validation-api-1.0.0.GA.jar.
I did that in the Java Build Path in the project properties.
Every time I switch a computer, I get an error:
Project '' is missing required library: ''. Off course, the path is changing between computers.
How can I resolve this issue?
Should I remove this settings from being stored on the SVN repository? If I shpould, how can I do that?
You should not persist any user-specific path information. Set your projects up by hand and then check out the user-agnostic stuff.
We have the same problem with IntelliJ. The answer is to check in only user-agnostic information, or get an IDE that's smart enough to use relative paths.
If you add 3rd party libraries to the project, make sure they are copied into your /lib directory and not in a path that's unique to you.
Create a project for the libraries.
Put the libraries in the project.
Export the jar files.
Set this newly created project as a dependency in the main project.

Categories