Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

hibernate example using maven

Hi

I am working on below example

https://www.mkyong.com/hibernate/maven-3-hibernate-3-6-oracle-11g-example-xml-mapping/

i downloaded code and unzipped adn impred as maven project to eclipse.
when i open pom i see error
Project build error: 'dependencies.dependency.version' for com.oracle:ojdbc6:jar is missing.

how to resolve this error and execue


when i right click run as maven install gave below error


[INFO] Scanning for projects...
[INFO]                                                                        
[INFO] ------------------------------------------------------------------------
[INFO] Building HibernateExample 1.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.oracle:ojdbc6:jar:11.2.0 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.510 s
[INFO] Finished at: 2017-01-21T15:56:34-05:00
[INFO] Final Memory: 6M/155M
[INFO] ------------------------------------------------------------------------
Failed to execute goal on project HibernateExample: Could not resolve dependencies for project com.mkyong.common:HibernateExample:jar:1.0: Failure to find com.oracle:ojdbc6:jar:11.2.0 in http://repository.jboss.org/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of JBoss repository has elapsed or updates are forced -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException



please advise
ASKER CERTIFIED SOLUTION
Avatar of gurpsbassi
gurpsbassi
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

You need to download it and install it.

have you not read and followed the instructions stated quite clearly in section 4?

i already have ojdbc5 jar at
C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib
how to install it and integrate to maven?

which section 4?

please advise
Avatar of gudii9

ASKER

		<!-- ORACLE database driver -->
		<dependency>
			<groupId>com.oracle</groupId>
			<artifactId>ojdbc5</artifactId>

		</dependency>

Open in new window



remove aboe oracle entry

and

simply

add that jar from java build path??
Can you not see section 4 of the link YOU posted ?

It quite clearly has a link to a page that tells you how to install oracle driver into maven.
Avatar of gudii9

ASKER

For Oracle JDBC driver, you need to install it into your local maven repository manually.
For Oracle JDBC Driver
Read this guide – How to add Oracle JDBC driver in your Maven local repository


i see it now . I will try it today
Avatar of gudii9

ASKER

\HibernateExample>mvn install:install-file -Dfile=C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc6.jar
'mvn' is not recognized as an internal or external command,
operable program or batch file.

getting above error. looks like ned to set maven path
Yes so do it
Avatar of gudii9

ASKER

http://www.mkyong.com/maven/how-to-install-maven-in-windows/

just completed
>mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T11:41:47-05:00)
Maven home: C:\gpSoftwares\apache-maven-3.3.9-bin\apache-maven-3.3.9
Java version: 1.8.0_102, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_102\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"
Avatar of gudii9

ASKER

D:\>mvn install:install-file -Dfile=D:\app\mkyong\product\11.2.0\dbhome_1\jdbc\lib\ojdbc6.jar

Step 4 says above step.

in my case in instead of D which directory i have to go? to my eclipse workspace as below?

C:\Users\xyz\gpJava\edu\HibernateExample


above gives below error




C:\Users\xyz\gpJava\edu\HibernateExample>mvn install:install-file -Dfile=C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc5.jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HibernateExample 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ HibernateExample ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.196 s
[INFO] Finished at: 2017-01-24T22:47:36-05:00
[INFO] Final Memory: 7M/123M
[INFO] ------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install-file (default-cli) on project HibernateExample: The artifact information is incomplete or not valid:
[0]  'groupId' is missing.
[1]  'artifactId' is missing.
[2]  'packaging' is missing.
[3]  'version' is missing.
-> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

actually i mised some commamd




HibernateExample>mvn install:install-file -Dfile=C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HibernateExample 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ HibernateExample ---
[INFO] Installing C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc6.jar to C:\Users\saiganesh\.m2\repository\com\oracle\ojdbc6\11.2.0\ojdbc6-11.2.0.jar
[INFO] Installing C:\Users\SAIGAN~1\AppData\Local\Temp\mvninstall6710084641366731140.pom to C:\Users\saiganesh\.m2\repository\com\oracle\ojdbc6\11.2.0\ojdbc6-11.2.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.099 s
[INFO] Finished at: 2017-01-24T22:58:36-05:00
[INFO] Final Memory: 7M/123M
[INFO] --------------------------------------------------------

above is fine
Avatar of gudii9

ASKER

finally works as attached
hibernateWorksMAven.png
Avatar of gudii9

ASKER

final command i used is
mvn install:install-file -Dfile=C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar
Avatar of gudii9

ASKER

my modified hibernate config file is
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
        <property name="hibernate.connection.username">sample</property>
        <property name="hibernate.connection.password">admin</property>
        <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
        
        <property name="show_sql">true</property>
        <mapping resource="com/mkyong/user/DBUser.hbm.xml"></mapping>
    </session-factory>
</hibernate-configuration>




   

Open in new window