ClassNotFoundException weblogic.jdbc.wrapper.JTSConnection with default persistence provider? - mysql

I'm a newbie to EE and I'm working on an application on Weblogic 12c. Data Source tests fine in the Admin Console. When the EJB tries to access it, it throws this ClassNotFoundException. I've done three hours of research and I know the issue is that some jar is not in the server's classpath, but I can't figure out which one!!! I'm using the default EclipseLink persistence provider and using MySQL Driver. BOTH of these come packaged with Weblogic (according to Oracle documentation) so I shouldn't have to explicitly add them to the classpath. And besides, adding them didn't work. Any other ideas?
Here's the persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="YLE_PU" transaction-type="JTA">
<jta-data-source>YLEDataSource</jta-data-source>
<class>com.yle.studentmodule.entity.Address</class>
<class>com.yle.studentmodule.entity.Contact</class>
<class>com.yle.studentmodule.entity.Semester</class>
<class>com.yle.studentmodule.entity.Student</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="eclipselink.cache.type.default" value="NONE"/>
</properties>
</persistence-unit>
Quote from WebLogic Documentation:
"In addition to the Oracle Thin Driver, the mySQL 5.0.x (mysql-connector-java-commercial-5.0.x-bin.jar) JDBC driver is installed with WebLogic Server.
This driver is installed in the WL_HOME\server\lib folder (where WL_HOME is the folder where WebLogic Server is installed) with weblogic.jar. The manifest in weblogic.jar lists this file so that it is loaded when weblogic.jar is loaded (when the server starts). Therefore, you do not need to add this JDBC driver to your CLASSPATH."
Thanks!

In other case,
Check your jdk version and bit
I solved that change to 64bit jdk

There can be another situation, that more than one class file (jars) are available at the server, which creates ambiguity. This situation also generates the same error.
My suggestion is to keep only one jar (related to JDBC) at your server.
I resolved the same issue in weblogic 12c with Oracle as DBMS.
In my case I had the .jar file of the Oracle driver inside the jdk/jre/lib/ext folder and another one inside weblogic folder as well. Removing the driver from the JDK folder solved my problem.

Related

Connecting database with hibernate

I know thats a known problem and i made my research but still couldnt find a proper answer and what to do, so my last hope is here. The problem is, when i use phpAdmin i can connect and create my tables in m database. But when i run hibernates connection wizard, after entering the connection properties, if i press the test connection it gives me this error :
"Timeout expired. IDE unable to establish connection. Check your proxy settings or try again later. The server may be unavailable at the moment.   You may also want to make sure that your firewall is not blocking network traffic."
My hibernate.cfg.xml looks like this
<?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.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://127.11.83.2:3306</property>
<property name="hibernate.connection.username">admin1s6nbcM</property>
<property name="hibernate.connection.password">*******</property>
</session-factory>
</hibernate-configuration>
I m suspecting that there is something wrong with MySQL Java Connector library ;
dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.30</version>
</dependency>
because i get this warning when i build my application:
Some problems were encountered while building the effective model for cardsystelefonbuch:cardsystelefonbuch:war:1.0
'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: mysql:mysql-connector-java:jar -> version 5.1.25 vs 5.1.30 # line 83, column 13
It is highly recommended to fix these problems because they threaten the stability of your build.
For this reason, future Maven versions might no longer support building such malformed projects.
Any ideas would be greatly appreciated !

Trying to install HikariCP on tomcat 7 and getting javax.naming.NamingException on startup

I am trying to configure HikariCP as my datasource connection pool on tomcat 7 with mysql. Here is my context file...
<?xml version="1.0" encoding="UTF-8"?>
<Context allowCasualMultipartParsing="true">
<Resource name="jdbc/application" auth="Container"
factory="com.zaxxer.hikari.HikariJNDIFactory"
type="javax.sql.DataSource"
minimumIdle="5"
maximumPoolSize="10"
connectionTimeout="300000"
dataSource.implicitCachingEnabled="true"
dataSource.user="root"
dataSource.password="pass"
dataSource.url="jdbc:mysql://localhost:3306/Database"/>
</Context>
But on startup I get this error...
WARNING: Failed to retrieve JNDI naming context for container
javax.naming.NamingException: No naming context bound to this class loader
How can I configure HikariCP-2.3.0 on tomcat?
may be this could help you
Configuring the Tomcat Definitions
Location of your JNDI datasource definitions depends upon the scope for the connections. You can define them globally by specifying them in Tomcat's conf/server.xml and conf/context.xml, or you can scope them to individual applications by defining them in conf/Catalina/localhost/WebAppContext.xml (where WebAppContext is the web application context for the app, basically the directory name from Tomcat's webapps directory).
<Resource name="jdbc/LiferayPool" auth="Container"
factory="com.zaxxer.hikari.HikariJNDIFactory"
type="javax.sql.DataSource"
minimumIdle="5"
maximumPoolSize="10"
connectionTimeout="300000"
dataSourceClassName="org.postgresql.ds.PGSimpleDataSource"
dataSource.url="jdbc:postgresql://localhost:5432/lportal"
dataSource.implicitCachingEnabled="true"
dataSource.user="user"
dataSource.password="pwd" />
https://community.liferay.com/blogs/-/blogs/tomcat-hikaricp

Doing Releases with Maven/Hudson/Mercurial

I am attempting to do a release via the Maven release plugin and am having issues with the SCM config. I am using Eclipse with m2eclipse installed. We use Mercurial and on my machine (Win7) I have TortoiseHg installed. I have a test project that creates a jar. We make use of a super pom for our projects, so the test project pom does as well. I have set up this in the super pom:
<build>
<plugins>
....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin
<version>1.6</version>
<configuration>
<connectionType>connection</connectionType>
</configuration>
</plugin>
</plugins>
</build>
My test project pom looks like this:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.group</groupId>
<artifactId>TestJar
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>my.group</groupId>
<artifactId>super-pom</artifactId>
<version>1.0</version>
</parent>
<scm>
<connection>
scm:hg:ssh://our.scm.server:22//path/to/TestJarProject
</connection>
<developerConnection>
scm:hg:ssh://our.scm.server:22//path/to/TestJarProject
</developerConnection>
</scm>
</project>
Note that we ssh to our SCM server. I suspect some of the issues I'm encountering my be related to this. I've only been able to find examples that use http.
In my settings.xml file, I added this:
<servers>
...
<server>
<id>our.scm.server</id>
<username>username</username>
<password>password</password>
</server>
</servers>
When I run release:prepare release:perform, a TortoisePlink dialog pops up prompting me for a password. The dialog box is asking of "#our.scm.server's password".
It appears it is not using the username or password from the settings.xml file which is what I was expecting by adding the server element to it. Should it be? I have also tried adding my username to the connection url:
<connection>
scm:hg:ssh://username#our.scm.server:22//path/to/TestJarProject
</connection>
but am still prompted for an empty username's password.
QUESTION ONE
Has anyone successfully used ssh to connect to Mercurial while doing Maven releases?
Since I ultimately want to do the builds in Hudson, I set up a Hudson job to do the release but it fails with this error:
[INFO] o.h.m.e.h.MavenExecutionResultHandler - Build failed with exception(s)
[INFO] o.h.m.e.h.MavenExecutionResultHandler - [1] org.apache.maven.lifecycle.\
LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:\
maven-release-plugin:2.0:prepare (default-cli) on project TestJar: Cannot \
prepare the release because you have local modifications :
[.maven/repo/ca/shaw/eng/nms/nms-super-pom/1.0/_maven.repositories:unknown]
[.maven/repo/ca/shaw/eng/nms/nms-super-pom/1.0/nms-super-pom-1.0.pom:unknown]
[.maven/repo/ca/shaw/eng/nms/nms-super-pom/1.0/nms-super-pom-1.0.pom.sha1:unknown]
... many, many more lines of this nature .....
QUESTION TWO
What local modifications is Maven encountering?
Since the project is being pulled from the repo, the only change I can think of is the update to the pom file (removing SNAPSHOT from the version). But Maven shouldn't be complaining about this since it made the change itself, no?
UPDATE
As per khmarbaise's suggestion, I've added this to my parent POM:
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.2</version>
</plugin>
</plugins>
</pluginManagement>
QUESTION ONE
Has anyone successfully used ssh to connect to Mercurial while doing Maven releases?
The answer appears to be that the Maven Release Plugin only works with https. We were able to get https working on our Mercurial server by generally following the instructions on this page:
https://www.mercurial-scm.org/wiki/HgWebDirStepByStep
QUESTION TWO
What local modifications is Maven encountering?
The local modifications are the .maven directory that is created during the build. By adding .maven/* to my .hgignore file, I was able to complete the build.
I am unable to reproduce this right now, but from earlier experience I remember that ssh connections only work with key-based authentication, not with usernames and passwords. This is not necessarily specific to the release plugin and/or its Mercurial support.
EDIT: I have tried key-based ssh access with Mercurial and the release plugin version 2.4.1 today, and it works nicely. One possible source of problems is the SCM URL format. In my case it's:
scm:hg:ssh://user#hostname.com/path
So the answer to your question one is: yes, but not with username/password authentication. I did not encounter any "local modifications" problem, but I have target in my .hgignore so that might be it.

Do I need DataSource in JPA Hibernate project?

I am preparing some application with usage of JPA 2.0, Hibernate as provider, MySQL 5 as database, which will be deployed on JBoss AS 7.0.2.I have already configured some basics in persistence.xml and I came into some kind of trouble. I have noticed that some people also defines some specific DataSource on JBoss Management Console level.
My question is. Do I really need to worry about some DataSource or anything like that in Hibernate application?I thought it is important in old JDBC approach.In some books, where examples are shown, there is no such configuration in persistence.xml or hibernate.cfg.xml
Do I have to place mysql connector into JBOSS_HOME/standalone/deployments directory to use MySQL in my application?Here is content of my persistence.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="SomeApp">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/somedb" />
<property name="hibernate.connection.username" value="" />
<property name="hibernate.connection.password" value="" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
</properties>
</persistence-unit>
</persistence>
Well, you can either access the database by:
providing the url/driver/password/etc. information in the persistence.xml using your jpa-provider properties (in your case hibernate.connection.*) or the JPA 2.0 standardised javax.persistence.jdbc.* ones - this basically looks like the example you've posted,
creating a Data Source in the ApplicationServer and just referring to it in the persistence.xml (through it's JNDI name you provide during creation) which might look similar to this (without the XML schema definition for the sake of brevity) :
<persistence>
<persistence-unit name="SomeApp">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/myDB</jta-data-source>
</persistence-unit>
</persistence>
What you're actually doing right now (with these properties) is using the JDBC.
I would definitely go with the creation of the Data Source in the ApplicationServer rather than providing it in the properties in persistence.xml. It allows you to dynamically change the end-database, it's type, credentials, manage connection pools, etc. without even touching your descriptor.
It's also safer, as the credentials are not written in the plain file left on your server.
As a side note, please remember that the javax.persistence.jdbc.* properties are a JPA provider must requirement for the Java SE environment, but it's optional for Java EE.
Hope that helps!
Do I have to place mysql connector into
JBOSS_HOME/standalone/deployments directory to use MySQL in my
application?
Yes you need to put Mysql J/connector for use it as JDBC Driver. Your application server (JBOss, Weblogic, Glassfish, etc) doesn't provide it because depend of the RDBMS that you are using (in this case Mysql) and the version of it.
In the case of JBoss 7 the JDBC driver can be installed into the container in one of two ways: either as a deployment or as a core module. For the pros/cons of both modes an detailed explanatio you can check the following documentation: http://community.jboss.org/wiki/DataSourceConfigurationInAS7

Mysql, NHibernate and visual studio 2008 configuration

I am a beginer with visual studio 2008 (C#), mysql and NHibernate.
I have problems with mysql connector as I don't know how to add reference to it.
In my project I have:
/lib/mysql-connector-net-6.1.4-src/
(downloaded from http://dev.mysql.com/downloads/mirror.php?id=387799#mirrors)
Now I right click on my project -> addReference -> browse -> What now?
Should I also edit my hibernate configuration?
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
<property name="connection.connection_string">Server=localhost;database=Pets;Database=pets,User ID=root,Password=;</property>
<property name="dialect">NHibernate.Dialect.MySQL5Dialect</property>
<property name="proxyfactory.factory_class"> NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu </property>
<property name="show_sql">false</property>
</session-factory>
</hibernate-configuration>
Thanks
You need to add a reference to the MySQL connector DLL that corresponds to the version of .NET you are targeting.
From the link provided, it seems like you downloaded the source code for the MySQL connector, so you'll either need to build this code and take the desired DLL out of the /bin folder afterwards or download a full installer (which will include the binaries) from the second link here:
http://dev.mysql.com/downloads/connector/net/6.1.html
Once you add this DLL to your project, you'll need to edit that NHibernate configuration to update the "connection.connection_string" property with the connection string for your database.
Hope this helps. There is some more documentation available here:
http://dev.mysql.com/doc/refman/5.1/en/connector-net.html