Roman Merkushen

Greenhorn
+ Follow
since May 25, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Roman Merkushen

It looks like your jar file is missing from the classpath.
Make sure to add pvjdbc2.jar to your classpath (WEB-INF/lib if using web container)
Good luck
You can try compiling class and then extracting methods and fields using java.lang.reflect package or commons beanutils package.
Roman.
19 years ago
Hello,
I am using log4j 1.2.9 in weblogic 8.1 sp3 with 3 applications installed. Log4j.properties file configured for two application with different file paths and both apps are logging to the same file. properties listed below for app1, app2 is the same and reside in application 2 WEB-INF/classes directory.



I have read on apache website on how to configure custom LoggerRepository interface and implemeted the folliwong logic:



and servlet context listener is :



While deploying application the following error occurs:



I referred to Log4j javadoc page and it seems that the constructor does exist for


I spent 2 days trying to debug this and have no idea what is happening. Thanks in advance.
Roman.

web.xml
19 years ago
Hi,
I hope you can help me. I have battling connection timeout issue with Mysql for a month now. I am using hibernate 2 with c3p0 connection pool. Hibernate config file below:

<session-factory>
<!-- properties -->
<property name="session_factory_name">jdbcSessionFactory</property>
<property name="jdbc.use_scrollable_resultset">true</property>
<property name="cglib.use_reflection_optimizer">false</property>
<property name="show_sql">false</property>
<property name="use_outer_join">true</property>
<property name="query.substitutions">true=1, false=0</property>

<!-- connection parameters -->
<property name="connection.provider_class">net.sf.hibernate.connection.C3P0ConnectionProvider</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/mydb?autoReconnect=true</property>
<property name="connection.username">username</property>
<property name="connection.password">password</property>
<property name="connection.autoReconnect">true</property>
<property name="connection.autoReconnectForPools">true</property>
<property name="connection.failOverReadOnly">true</property>
<property name="connection.is-connection-validation-required">true</property>

<!-- connection pool settings -->
<property name="c3p0.minPoolSize">5</property>
<property name="c3p0.maxPoolSize">60</property>
<property name="c3p0.timeout">600</property>
<property name="c3p0.max_statement">300</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>

<!-- mapping files -->
<mapping resource="com/planet/struts/beans/or-mapping.hbm.xml"/>
<mapping resource="com/planet/struts/beans/admin/or-mapping.hbm.xml"/>
</session-factory>

After certain period of time connection timesout, then once refreshed it works fine. Any suggestions are appreciated.
Thank you.
Thank you,
I solved it with
Configuration cfg = new Configuration().configure(new File("d:/work/Hibernate/classes/hibernate.cfg.xml"));
Thank you for your help. I fixed the code and realized that dom4j-1.4.jar was not in the classpath.
However, I am still getting runtime errors :
0 [main] INFO cfg.Environment - Hibernate 2.1.3
0 [main] INFO cfg.Environment - hibernate.properties not found
16 [main] INFO cfg.Environment - using CGLIB reflection optimizer
16 [main] INFO cfg.Configuration - configuring from resource: /hibernate.cfg.xml
16 [main] INFO cfg.Configuration - Configuration resource: /hibernate.cfg.xml
16 [main] WARN cfg.Configuration - /hibernate.cfg.xml not found
net.sf.hibernate.HibernateException: /hibernate.cfg.xml not found
at net.sf.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:849)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:873)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:860)
at com.hibernate.test.Runner.createSession(Runner.java:76)
at com.hibernate.test.Runner.update(Runner.java:33)
at com.hibernate.test.Runner.main(Runner.java:20)

Both xml and properties files are in my classpath. This is a test program and I am trying to get it to work. Can session factory be stored in context and is there an easy way to configure it through hibernate config file?
Thanks for your help.
Roman.
I apologise for posting it wrong. It is
Configuration cfg = new Configuration().configure();
I tried running it as a standalone program and still getting the following stack trace:
java.lang.NullPointerException

at com.hibernate.test.Runner.update(Runner.java:49)

at com.hibernate.test.Runner.main(Runner.java:19)

The code is below:

package com.hibernate.test;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.MappingException;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.Session;
import net.sf.hibernate.cfg.Configuration;
import com.hibernate.beans.*;
import java.sql.SQLException;

public class Runner
{
public Runner()
{
}

public static void main(String[] args)
{
Runner run = new Runner();
run.update("ULT5005D","ULT5000");

}

/**
* update objet
*/
public void update(String desc,String header)
{
Session session = null;
try
{
session = createSession();
Product prod = new Product();
prod.setProductDesc(desc);
prod.setProductName(header);

//add
session.beginTransaction();
session.saveOrUpdate(prod);
session.connection().commit();
}
catch(Exception e)
{
e.printStackTrace(System.out);
}
finally
{
try
{
session.close();
}
catch(HibernateException e)
{
System.out.println("trying to close " + e.toString());
}
}
}

/**
* create session
*
* @return session current session
*/
public Session createSession() throws MappingException,HibernateException
{
Configuration cfg = new Configuration().configure();
cfg.addClass(com.hibernate.beans.Product.class);
SessionFactory sessions = cfg.buildSessionFactory();
return sessions.openSession();
}
}

The line that is throwing NullPointerException is Configuration initialization. I tried using Environment Class to get init properties, both hibernate.properties and hibernate.cfg.xml are in the classpath, it gives me system properties and not hibernate parameters. I have no idea what could have gone wrong, but by looking at hibernate Configuration source code I think that it is not reading initial parameters.
Thanks for your help.
java.lang.NullPointerException
at com.hibernate.test.Runner.update(Runner.java:57)
at jsp_servlet.__test._jspService(__test.java:173)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
While running

Configuration cfg = new Configuration.configure();

throws NullPointerException. I tried both hibernate.properties and hibernate.cfg.xml files, bot are in class path. Configuration file posted below:

<hibernate-configuration>

<!-- a SessionFactory instance listed as /jndi/name -->
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<session-factory name="java:comp/env/hibernate/SessionFactory">

<!-- properties -->
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.username">user</property>
<property name="connection.password">password</property>
<property name="connection.url">jdbc racle:thin:@localhost:1521 b</property>
<property name="connection.datasource">my/first/datasource</property>
<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>
<property name="show_sql">true</property>
<property name="use_outer_join">true</property>
<property name="batch_size">25</property>
<!-- mapping files -->
<mapping resource="com/hibernate/beans/Product.hbm.xml"/>

</session-factory>

</hibernate-configuration>

Please let me know if you know what might be happening.
Thank you.

Java Code:
cfg.addClass(com.hibernate.beans.Product.class);
SessionFactory sessions = cfg.buildSessionFactory();
return sessions.openSession();
[ May 25, 2004: Message edited by: Roman Merkushen ]