-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Schemaexport - DataSource problem with WLS8.1
PostPosted: Thu Nov 03, 2005 5:53 am 
Newbie

Joined: Thu Nov 03, 2005 5:21 am
Posts: 4
Hi,

I'm using schemaexport with MySQL on WLS8.1SP3

I've used the mapping document below to run the application and it works. I managed to deploy the connection pool and test it on WLconsole. On MySQL log, I can get the test string I specified on the console. It seems the WL side is working ok.

However, when I started to write some POJOs and tried to run schemaexport, I got the stack trace below.

I've tried some properties on hibernate_reference manual,
using < property name="jndi.url">t3://localhost:7001/jdbc/semJDBCDataSource</property>

Modified connection.datasource to java:/comp/env/jdbc/semJDBCDataSource

but none of these works.

Is there some property that I'm missing here? Is it possible to pass the JNDI url to the JNDI initialContext explicitly ( hibernate API says that connection.datasource should suffice )?

Thanks for the reply.

Hibernate version: 3.0

Mapping documents:
Code:
<hibernate-configuration>
   <session-factory name="hibernate_SessionFactory">
      <property name="connection.datasource">jdbc/semJDBCDataSource</property>
                <property name="show_sql">true</property>
                <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
      
        <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
        <property name="transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</property>   

                         <mapping resource="Person.hbm.xml"/>
   </session-factory>
</hibernate-configuration>


Full stack trace of any exception that occurs:
Code:
schemaexport:
[schemaexport] 16:42:59,115 FATAL DatasourceConnectionProvider: - Could not find datasource: jdbc/semJDBCDataSource
[schemaexport] javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
[schemaexport]  at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
[schemaexport]  at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
[schemaexport]  at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
[schemaexport]  at javax.naming.InitialContext.lookup(InitialContext.java:351)
[schemaexport]  at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:44)
[schemaexport]  at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:80)
[schemaexport]  at org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.getConnection(SchemaExport.java:431)
[schemaexport]  at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:130)
[schemaexport]  at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:99)
[schemaexport]  at org.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:142)
[schemaexport]  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[schemaexport]  at org.apache.tools.ant.Task.perform(Task.java:364)
[schemaexport]  at org.apache.tools.ant.Target.execute(Target.java:341)
[schemaexport]  at org.apache.tools.ant.Target.performTasks(Target.java:369)
[schemaexport]  at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[schemaexport]  at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[schemaexport]  at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[schemaexport]  at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[schemaexport]  at org.apache.tools.ant.Main.runBuild(Main.java:668)
[schemaexport]  at org.apache.tools.ant.Main.startAnt(Main.java:187)
[schemaexport]  at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
[schemaexport]  at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)

Name and version of the database you are using:
MySQL-standar-4.1.11
mysql-connector-java-3.1.10-bin.jar


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 03, 2005 8:35 am 
Newbie

Joined: Thu Nov 03, 2005 5:21 am
Posts: 4
Referring to this link http://www.hibernate.org/120.html#A8, I've modified the mapping document. The link to Mathias' blog is broken so there's no way to read his experience

<property name="jndi.url">t3://localhost:7001</property>
<property name="jndi.class">weblogic.jndi.WLInitialContextFactory</property>

which leads to:

Code:

# ant schemaexport

[schemaexport] javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory]
[schemaexport]  at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
[schemaexport]  at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
[schemaexport]  at javax.naming.InitialContext.init(InitialContext.java:223)
[schemaexport]  at javax.naming.InitialContext.<init>(InitialContext.java:197)
[schemaexport]  at org.hibernate.util.NamingHelper.getInitialContext(NamingHelper.java:28)
[schemaexport]  at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:44)
[schemaexport]  at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:80)
[schemaexport]  at org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.getConnection(SchemaExport.java:431)
[schemaexport]  at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:130)
[schemaexport]  at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:99)
[schemaexport]  at org.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:142)
[schemaexport]  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[schemaexport]  at org.apache.tools.ant.Task.perform(Task.java:364)
[schemaexport]  at org.apache.tools.ant.Target.execute(Target.java:341)
[schemaexport]  at org.apache.tools.ant.Target.performTasks(Target.java:369)
[schemaexport]  at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[schemaexport]  at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[schemaexport]  at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[schemaexport]  at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[schemaexport]  at org.apache.tools.ant.Main.runBuild(Main.java:668)
[schemaexport]  at org.apache.tools.ant.Main.startAnt(Main.java:187)
[schemaexport]  at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
[schemaexport]  at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
[schemaexport] Caused by: java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory
[schemaexport]  at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
[schemaexport]  at java.security.AccessController.doPrivileged(Native Method)
[schemaexport]  at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
[schemaexport]  at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[schemaexport]  at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
[schemaexport]  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
[schemaexport]  at java.lang.Class.forName0(Native Method)
[schemaexport]  at java.lang.Class.forName(Class.java:242)
[schemaexport]  at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
[schemaexport]  at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
[schemaexport]  ... 22 more


where my ant target is:

Code:
<target name="schemaexport">
        <schemaexport config="${src.java.dir}/hibernate.cfg.xml"/>


I wonder if the problem described is still present in WLS8.1SP3


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 03, 2005 9:21 am 
Newbie

Joined: Thu Nov 03, 2005 5:21 am
Posts: 4
Looks like there's nothing wrong with WL's JNDI implementation

when I remove the property jndi.url and jndi.class, I'm able to get the Session from the context

Code:
InitialContext aInitialContext = new InitialContext();
SessionFactory aSessionFactory =
            (SessionFactory) aInitialContext.lookup("hibernate_SessionFactory");


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 03, 2005 10:48 am 
Newbie

Joined: Thu Nov 03, 2005 5:21 am
Posts: 4
IIRC, there's some old issue with the thread classloader between ant and java.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.