fuwang

 

2006年12月15日

Configuring WebLogic 8.1 and Hibernate 3.0

Configuring WebLogic 8.1 and Hibernate 3.0

Prakash Malani's Blog | July 21, 2005  04:00 PM | Comments (25)


Recently, I was asked for step-by-step instructions for configuring Hibernate with WebLogic on bartsandbox. As you may already know, Hibernate is a very popular open source Object Relational Mapping (ORM) tool. Follow these steps to configure Hibernate with WebLogic 8.1.


  • First you create a domain. I created a WebLogic Workshop (WLW) domain, because I am going to use WLW to create and implement the application.
  • Either add hibernate...\lib\antlr-2.7.5H3.jar to the PRE_CLASSPATH or set the query.factory_class property in hibernate.cfg.xml file to user 2.x's query factory.
  • The WLW domain also starts a PointBase database instance. I am going to use this built in instance. I created a new user and schema. I populated the schema with some sample data.
  • In the server instance, you configure a connection pool and a data source. .
  • Create the application. I am going to use WebLogic Workshop to create an application.
  • Where should you put the libraries (jar files) required to successfully run Hibernate? Place the libraries in APP-INF/lib folder of the application. This includes hibernate.jar and additional 3rd party libraries. Refer to table 3-1 of the Hibernate Reference.
  • You create a Java project in WLW. This Java project contains the domain classes that map to the database. WLW compiles this project and puts the resultant jar file into the APP-INF/lib directory. In the Java project code the domain class. You create the Hibernate mapping file as well as the Hibernate configuration file. Additionally, you create the HibenateUtil class by copying the implementation from the Hibernate Reference. The Hibernate configuration file contains the JNDI name of the data source.
  • You create an EJB project (i.e., a module). This project contains session beans. You code a session bean that manipulates the domain class.
  • You create a Web or Web Service project (i.e., a module). This project contains components to interactively test the session beans.

The complete, working, and self-contained sample application is available here. This includes the schema and all the Hibernate configuration files. (Note: Free membership to bartsandbox is required.)

In the next few blog entries, I will enhance this basic configuration. In meantime, try out the above steps. Comments, questions, and feedback are most welcome.

Best regards,
+prakash

-----
My blog (http://dev2dev.bea.com/blog/pmalani/)
Answers to J2EE, Java, UML, Process, and Patterns! (http://www.bartssandbox.com/)
Los Angeles BEA Users Group (http://groups.yahoo.com/group/LABEAUG/)


Comments

Comments are listed in date ascending order (oldest first) | Post Comment

  • Hi Prakash,

    managed to run the sample application without much problem. It's very useful to have a sample that I can dissect around instead of the usual html article. Thanks!

    There's something that puzzling here. I refer you to Weblogic+Hibernate problem. Though I removed the ant-antlr-1.6.3.jar from APP-INF and re-built the application, I could not reproduce the problem.

    So it seems that the problem happens when you deploy the .ear, you'll run into this class-loading problem. Have you had this problem?

    Posted by: dontrango on July 24, 2005 at 12:49 AM

  • I am very glad that you got the example working.

    Ah... The way to reproduce the problem you describe "CharScanner; panic: ClassNotFoundException: org.hibernate.hql.ast.HqlToken" is the following. Don't change anything in the application. Now, execute a query. In updated example, the query is "from Person" inside of the getPersons() method. Hibernate query uses ANTLR and so does WebLogic. ANTRL does Class.forName() instead of using the context class-loader. Therefore, you get the above exception.

    There are at least two ways to solve this problem. One is to use the older query factory that does not use ANTLR. The second is to use put the patched version of ANTLR that ships with Hibernate. Put the patched version of ANTLR in the WebLogic PRE_CLASSPATH.

    I updated to blog entry above to reflect this. Also, I updated the sample application to illustrate this as well.

    Comments, questions, and feedback are most welcome...

    Best regards,
    +prakash

    Posted by: pmalani on July 25, 2005 at 03:44 PM

  • I am glad you found the sample application useful. I hope you will share your experiences in integrating Spring. I will update my blog as well as the sample application with Spring support. So, please stay tuned...

    Thanks for pointing out about getPerson2() method. This relies upon leveraging JNDI for session factory. Stay, tuned for my blog entry (very soon now) that talks about JNDI, JTA, JCA, and JMX. If you find any other anomalies, please don't hesitate to let me know...

    Wishing you the best,
    +prakash

    -----
    My blog (http://dev2dev.bea.com/blog/pmalani/)
    Answers to J2EE, Java, UML, Process, and Patterns! (http://www.bartssandbox.com/)
    Los Angeles BEA Users Group (http://groups.yahoo.com/group/LABEAUG/)

    Posted by: pmalani on July 28, 2005 at 03:01 PM

  • I am very new to this. the example package does not contain the index.jsp in the Webservice WEB-INF directory Please can you provide How i can call the werb service that call the collection of get persons

    Posted by: sbellare on July 29, 2005 at 04:22 PM

  • Assuming all the set-up is done and the server is running, I use the Workshop Test Browser to test it. Open up the DomainManagerService.jws in Workshop and hit the play button. This will lauch the Workshop Test Browser with the following URL: http://localhost:7001/WebServiceProject/test/service/DomainManagerService.jws?.EXPLORE=.TEST You can always go directly to this URL in any browser. From here, I can test the methods of the web-serivce including getPerson() method.

    Best regards,
    +prakash

    -----
    My blog (http://dev2dev.bea.com/blog/pmalani/)
    Answers to J2EE, Java, UML, Process, and Patterns! (http://www.bartssandbox.com/)
    Los Angeles BEA Users Group (http://groups.yahoo.com/group/LABEAUG/)

    Posted by: pmalani on August 01, 2005 at 03:43 PM

  • I am also new to hibernate. I was hoping to stay with 2.x because of the dev tools. Is there any reason this wouldn't work with 2.x ?? thanks

    Posted by: rickyd on August 30, 2005 at 09:45 AM

  • Hibernate 2.x configuration will probably be very similar. What kinds of dev tools you are talking about?

    Hibernate 3.x has been out for some time. I would highly recommend it versus 2.x.

    Best regards,
    +prakash

    -----
    My blog (http://dev2dev.bea.com/blog/pmalani/)
    Answers to J2EE, Java, UML, Process, and Patterns! (http://www.bartssandbox.com/)
    Los Angeles BEA Users Group (http://groups.yahoo.com/group/LABEAUG/)

    Posted by: pmalani on August 30, 2005 at 03:23 PM

  • I was referring to the hbm2java and middlegen tools. I haven't found those for the 3.x version.

    Posted by: rickyd on August 31, 2005 at 07:33 AM

  • Hey just wondering if you were going to also explain how to get Hibernate 3.0 working in Weblogic 9.0 in the future?

    Thanks,

    Mark Wolfe

    Posted by: markwolfe on October 03, 2005 at 10:31 PM

  • Hi Prakash, I'm using WebLogic 9.0 with Hibernate 3.0. I followed your suggestion and placed antlr-2.7.5H3.jar in the PRE_CLASSPATH directory to run my Struts/Hibernate application. But I still got this error: "CharScanner; panic: ClassNotFoundException: org.hibernate.hql.ast.HqlToken" which crashes the server. I tried to access your sample, but the notice Yahoo Groups gives me is that I must wait for membership acceptance. My team and I have been working on this problem now for quite a while and will appreciate any and all assistance. Thank you in advance. Regards, Ethelyn

    Posted by: eholmes2@cox.net on November 08, 2005 at 11:16 AM

  • Hi Prakash, Never mind, but I solved the problem by placing antlr-2.7.5H3.jar in a directory I created under my domain server directory and then modifying the classpath in setDomainEnv.cmd. The antlr jarfile must appear in the classpath before the weblogic jarfiles. Thanks, anyway. - Ethelyn

    Posted by: eholmes2@cox.net on November 08, 2005 at 03:59 PM

  • Another workaround for the Hibernate issue "CharScanner; panic: ClassNotFoundException: org.hibernate.hql.ast.HqlToken" is to set the Hibernate property "hibernate.query.factory_class" to "org.hibernate.hql.classic.ClassicQueryTranslatorFactory" (in your Spring configuration or in hibernate.properties). http://www.onthoo.com/blog/programming/2005/04/hibernate-moving-day.html)

    Posted by: drujensen on December 13, 2005 at 09:49 AM

  • Hi I am new to hibernate.Please let me know of links working examples of hibernate with weblogic 8.1.I have registered at bartsandbox to get code for sample application,waiting for its approval. Thanks in advance Raju

    Posted by: rkampli123 on March 16, 2006 at 03:14 AM

  • Hi Prakash, I have successfully build an WLW 8.1 application running hibernate 3.1.2 But I have to insert a new WLW project, then use it include and compile the hibernate source code. (Of course, I need to fix some code in order to make them able to be go through the jdk142_05, which is necessary for WLW 8.1) I have also tried to include the following JARs, without insert this new project. antlr.jar cglib.jar asm.jar asm-attrs.jars commons-collections.jar commons-logging.jar hibernate3.jar jta.jar dom4j.jar log4j.jar Then I go the following error: =========================================== javax.ejb.TransactionRolledbackLocalException: EJB Exception: : java.lang.ExceptionInInitializerError Caused by: java.lang.InternalError: erroneous handlers at util.HibernateUtil.getSessionFactory()Lorg.hibernate.SessionFactory;(HibernateUtil.java:53) at security.data.UserProfileStore.store(Ljava.lang.String;Lcom.pccw.esb.security.XUserProfile;)Ljava.lang.String;(UserProfileStore.java:43) . . . . =========================================== (where the UserProfileStore.jara is my homemade application) Have u ever encountered similar error before? Or do u have any suggestion so that I can look into?

    Posted by: rnmanhon on March 20, 2006 at 10:37 PM

  • seem my error start from EhCacheProvider. Error start here ----> Caused by: java.lang.InternalError: erroneous handlers at org.hibernate.cache.EhCacheProvider.start(Ljava.util.Properties;)V(EhCacheProvider.java:??? ) at org.hibernate.impl.SessionFactoryImpl.(Lorg.hibernate.cfg.Configuration;Lorg.hibernat e.engine.Mapping;Lorg.hibernate.cfg.Settings;Lorg.hibernate.event.EventListeners;)V(SessionFactoryImpl .java:172) at org.hibernate.cfg.Configuration.buildSessionFactory()Lorg.hibernate.SessionFactory;(Configu ration.java:1176)

    Posted by: rnmanhon on March 20, 2006 at 10:53 PM

  • Oh, Prakash, My problem is solved after I add back the ehcache-1.1.jar to the Library directory under WLW 8.1. So all JAR that need are: antlr.jar, cglib.jar, asm.jar, asm-attrs.jars, commons-collections.jar, commons-logging.jar, hibernate3.jar, jta.jar, dom4j.jar, log4j.jar, ehcache-1.1.jar

    Posted by: rnmanhon on March 20, 2006 at 11:18 PM

  • Thanks Prakash. Your blog helped me fix the ClassNotFoundException with the hibernate install.

    Posted by: kihatti on April 19, 2006 at 10:43 PM

  • Hi Prakash: I am using Weblogic 7sp4 and trying to integrate with struts 1.1,Hibernate 3.05, and Spring 1.25. I inserted the code below in my C:\bea\weblogic700\common\bin\Commenv.cmd file. Here is how I set my classpath in Commenv.cmd set COMM_WEBLOGIC_CLASSPATH=C:\bea\weblogic700\server\lib\antlr-2.7.5H3.jar;%COMM_JAVA_HOME%\lib\tools.jar;%COMM_WL_HOME%\server;%COMM_WL_HOME%\server\lib\weblogic_sp.jar;%COMM_WL_HOME%\server\lib\weblogic.jar Is this correct. Or is there another way to set classpath for weblogic 7 sp4. Yours, Desperate

    Posted by: jadeite100 on May 29, 2006 at 09:36 AM

  • Hi Prakash: Can you please tell me how to set Hibernate property "hibernate.query.factory_class" to "org.hibernate.hql.classic.ClassicQueryTranslatorFactory" in my Spring's ApplicationContext-app.xml. Thank You. Yours, Desperate.

    Posted by: jadeite100 on May 29, 2006 at 09:41 AM

  • Hi Prakash: I got my web application to work with weblogic 7 sp4, struts 1.1,Hibernate 3.05, and Spring 1.25. I am currently using weblogic 7 sp4 and I have a myserver that has several domain and each domain has several applications. In the startWeblogic.cmd, I have the following code: @rem Call Weblogic Server call "C:\bea\weblogic700\server\bin\startWLS.cmd" In the startWLS.cmd, I have the following: set CLASSPATH=%WL_HOME%\server\lib\antlr-2.7.5H3.jar;%JAVA_HOME%\lib\tools.jar;%WL_HOME%\server\lib\weblogic_sp.jar;%WL_HOME%\server\lib\weblogic.jar;%CLASSPATH%; My problem is that mydomain called Achievers has several web applications. For the Blanks.war file, I needed to put the following in front of the classpath: %WL_HOME%\server\lib\antlr-2.7.5H3.jar I needed to do it in such a way that it only affects the application called "Blank.war". It cannot affect other applications. Is there a way to do that in Weblogic 7 sp4. Yours, Desperate

    Posted by: jadeite100 on May 29, 2006 at 12:55 PM

  • If you put the jar in the server CLASSPATH, then it affects all the applications. I don't know of way to control so that it will only affect one application.
    Best regards,
    +prakash
    -----
    My blog (http://dev2dev.bea.com/blog/pmalani/)
    Answers to J2EE, Java, UML, Process, and Patterns! (http://www.bartssandbox.com/)
    Los Angeles BEA Users Group (http://groups.yahoo.com/group/LABEAUG/)
    Java Enterprise in a Nutshell (http://www.oreilly.com/catalog/javaentnut3/)

    Posted by: pmalani on June 02, 2006 at 07:21 PM

  • jadeite: I don't know you exact requirement , but creation of managed server for each application may help you, shared domain.

    Posted by: sanjay_kumar.prabhakar@novartis.com on June 13, 2006 at 03:41 PM

  • Hi, I am getting a NullPointerException in hibernate 3.1.2 and 3.1.3 API stack when I do the following to retrieve the list of already persisted ParentTest instances. Criteria crit = getSession().createCriteria(ParentTest.class); crit.list(); I am on WebLogic Integration Server 8.5 (WLI 8.5) and using HSQL DB 1.8.0. Any idea as to what may be causing this issue? Any help would be greatly appreciated as I already spent 2 days on this... Thanks. Below is the source code for ParentTest, Customer and hibernate mapping file. package ca.aol.backlog.core; import ca.aol.backlog.core.Customer; public class ParentTest { //id is required by Hibernate private Long id = null; private String name = null; private Customer customer; ParentTest() { super(); // TODO Auto-generated constructor stub } public ParentTest(String name) { this.name = name; } public Customer getCustomer() { return customer; } public void setCustomer(Customer customer) { this.customer = customer; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } package ca.aol.backlog.core; public class Customer { // id is required by Hibernate private Long id = null; private String name = null; private boolean disabled = false; Customer() { super(); // TODO Auto-generated constructor stub } public Customer(String name) { this.name = name; } public Long getId() { return id; } private void setId(Long id) { this.id = id; } public String getName() { return name; } /** * Once set customer name cannot be modified * @param name */ private void setName(String name) { this.name = name; } public boolean isDisabled() { return disabled; } public void setDisabled(boolean disabled) { this.disabled = disabled; } } Here is the full stack trace. java.lang.NullPointerException at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372) at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121) at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87) at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:891) at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:859) at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266) at org.hibernate.type.EntityType.resolve(EntityType.java:303) at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842) at org.hibernate.loader.Loader.doQuery(Loader.java:717) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.doList(Loader.java:2145) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029) at org.hibernate.loader.Loader.list(Loader.java:2024) at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1552) at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283) at ca.aol.backlog.dao.hibernate.GenericHibernateDAO.findByCriteria(GenericHibernateDAO.java:97) at ca.aol.backlog.dao.hibernate.GenericHibernateDAO.findAll(GenericHibernateDAO.java:61) at ca.aol.backlog.ui.action.test.ShowAllParentAction.execute(ShowAllParentAction.java:23) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1072) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27) at ca.aol.backlog.web.filter.HibernateThreadFilter.doFilter(HibernateThreadFilter.java:47) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6987) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3892) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2766) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183) Below is my hibernate configuration file. /jdbc/MyHSQL weblogic.jndi.WLInitialContextFactory t3://127.0.0.1:7001 org.hibernate.dialect.HSQLDialect thread org.hibernate.cache.NoCacheProvider true

    Posted by: burakm on June 21, 2006 at 04:28 PM

  • Hi Prakash,

    I am trying to add Caching with hibernate to a Enterprise Application deployed on WLS 8.1.5. I have tried using EHCache on the hibernate3 and the one available separatly. But eveytime i get is following. EHCache is present in the application Lib gave me the same result. Then I have added EHCache to the Weblogic start up classpath as well but haing the same result.
    I have the follwoing lines in the hibernate cfg file.

    net.sf.hibernate.cache.EhCacheProvider ehcache.xml

    ehcache is in the same dir as that of cfg file.

    INFO 20 Jul 2006 11:53:24,493 [11:53:24] (SettingsFactory.java:createCacheProvider:325) - Cache provider: net.sf.hibernate.cache.EhCacheProvider ERROR 20 Jul 2006 11:53:24,509 [11:53:24] (HibernateUtil.java::64) - Initial SessionFactory creation failed. org.hibernate.HibernateException: could not instantiate CacheProvider: net.sf.hibernate.cache.EhCacheProvider at org.hibernate.cfg.SettingsFactory.createCacheProvider(SettingsFactory.java:330) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:219) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174) at com.hp.bep.component.utils.HibernateUtil.(HibernateUtil.java:59) at com.hp.bep.component.utils.HibernateUtil.getUtil(HibernateUtil.java:77) at com.hp.bep.business.service.session.partservice.PartServiceManagerBean.getSession(PartServiceManagerBean.java:476) at com.hp.bep.business.service.session.partservice.PartServiceManagerBean.getPartServiceItemListfromDB(PartServiceManagerBean.java:261) at com.hp.bep.business.service.session.partservice.PartServiceManagerBean.getPartServiceItemList(PartServiceManagerBean.java:237) at com.hp.bep.business.service.session.partservice.PartServiceManagerBean.renderPartUI(PartServiceManagerBean.java:184) at com.hp.bep.business.service.session.partservice.PartServiceManagerBean_2s69py_EOImpl.renderPartUI(PartServiceManagerBean_2s69py_EOImpl.java:102) at com.hp.bep.presentation.testing.TestBEPAstroGetPartServices.testBEP_PartServiceManagerBean_renderPartUI_05(TestBEPAstroGetPartServices.java:1445) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153) at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119) at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93) at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:117) at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java) at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101) at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:117) at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java) at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72) at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:117) at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1072) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27) at com.hp.bep.presentation.common.filters.AuthenticationFilter.doFilter(AuthenticationFilter.java:106) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6987) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3892) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2766) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)

    Caused by: java.lang.ClassNotFoundException: net.sf.hibernate.cache.EhCacheProvider at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:199) at java.lang.ClassLoader.loadClass(ClassLoader.java:289) at java.lang.ClassLoader.loadClass(ClassLoader.java:235) at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:224) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:141) at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108) at org.hibernate.cfg.SettingsFactory.createCacheProvider(SettingsFactory.java:327) ... 43 more

    Posted by: debashish_saha on July 20, 2006 at 12:14 AM

  • Hi I am using the weblogic along with EJB and hibernate I am getting following error EJB Exception: : java.lang.InternalError: erroneous handlers at org.hibernate.cache.EhCacheProvider.start(Ljava.util.Properties;)V(EhCacheProvider.java:???) at org.hibernate.impl.SessionFactoryImpl.(Lorg.hibernate.cfg.Configuration;Lorg.hibernate.engine.Mapping;Lorg.hibernate.cfg.Settings;Lorg.hibernate.event.SessionEventListenerConfig;)V(SessionFactoryImpl.java:157) at org.hibernate.cfg.Configuration.buildSessionFactory()Lorg.hibernate.SessionFactory;(Configuration.java:1043) at com.puc.util.HibernateUtil.getSession()Lorg.hibernate.Session;(HibernateUtil.java:15) at com.puc.dao.user.UserDAO.validate(Lcom.puc.transferobject.UserTO;)Z(UserDAO.java:18) at com.puc.session.user.User.validate(Lcom.puc.transferobject.UserTO;)Z(User.java:86) at com.puc.session.user.User_3c57l6_EOImpl.validate(Lcom.puc.transferobject.UserTO;)Z(User_3c57l6_EOImpl.java:150) at com.puc.session.user.User_3c57l6_EOImpl_CBV.validate(Lcom.puc.transferobject.UserTO;)Z(Unknown Source) at jrockit.reflect.NativeMethodInvoker.invoke0(Ljava.lang.Object;ILjava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source) at jrockit.reflect.NativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source) at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source) at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source) at com.bea.wlw.runtime.core.control.EJBControlImpl.invoke(Ljava.lang.reflect.Method;[Ljava.lang.Object;)Ljava.lang.Object;(EJBControlImpl.jcs:665) at com.bea.wlw.runtime.core.dispatcher.DispMethod.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(DispMethod.java:377) at com.bea.wlw.runtime.core.container.Invocable.invoke(Ljava.lang.Object;Ljava.lang.String;Lcom.bea.wlw.runtime.core.dispatcher.DispMethod;[Ljava.lang.Object;)Ljava.lang.Object;(Invocable.java:423) at com.bea.wlw.runtime.core.container.Invocable.invoke(Lcom.bea.wlw.runtime.core.dispatcher.DispMethod;[Ljava.lang.Object;)Ljava.lang.Object;(Invocable.java:396) at com.bea.wlw.runtime.core.container.Invocable.invoke(Lcom.bea.wlw.runtime.core.request.Request;)Lcom.bea.wlw.runtime.core.dispatcher.InvokeResult;(Invocable.java:248) at com.bea.wlw.runtime.jcs.container.JcsContainer.invoke(Lcom.bea.wlw.runtime.core.request.Request;)Lcom.bea.wlw.runtime.core.dispatcher.InvokeResult;(JcsContainer.java:85) at com.bea.wlw.runtime.core.bean.BaseContainerBean.invokeBase(Lcom.bea.wlw.runtime.core.request.Request;)Lcom.bea.wlw.runtime.core.dispatcher.InvokeResult;(BaseContainerBean.java:224) at com.bea.wlw.runtime.core.bean.SLSBContainerBean.invoke(Lcom.bea.wlw.runtime.core.request.Request;)Lcom.bea.wlw.runtime.core.dispatcher.InvokeResult;(SLSBContainerBean.java:103) at com.bea.wlwgen.StatelessContainer_ly05hg_ELOImpl.invoke(Lcom.bea.wlw.runtime.core.request.Request;)Lcom.bea.wlw.runtime.core.dispatcher.InvokeResult;(StatelessContainer_ly05hg_ELOImpl.java:207) at com.bea.wlwgen.GenericStatelessSLSBContAdpt.invokeOnBean(Ljava.lang.Object;Lcom.bea.wlw.runtime.core.request.Request;)Lcom.bea.wlw.runtime.core.dispatcher.InvokeResult;(GenericStatelessSLSBContAdpt.java:62) at com.bea.wlw.runtime.core.bean.BaseDispatcherBean.runAsInvoke(Lcom.bea.wlw.runtime.core.request.Request;)Lcom.bea.wlw.runtime.core.request.Response;(BaseDispatcherBean.java:153) at com.bea.wlw.runtime.core.bean.BaseDispatcherBean.invoke(Lcom.bea.wlw.runtime.core.request.Request;)Lcom.bea.wlw.runtime.core.request.Response;(BaseDispatcherBean.java:54) at com.bea.wlw.runtime.core.bean.SyncDispatcherBean.invoke(Lcom.bea.wlw.runtime.core.request.Request;)Lcom.bea.wlw.runtime.core.request.Response;(SyncDispatcherBean.java:168) at com.bea.wlw.runtime.core.bean.SyncDispatcher_k1mrl8_EOImpl.invoke(Lcom.bea.wlw.runtime.core.request.Request;)Lcom.bea.wlw.runtime.core.request.Response;(SyncDispatcher_k1mrl8_EOImpl.java:100) at com.bea.wlw.runtime.core.dispatcher.Dispatcher.remoteDispatch(Lcom.bea.wlw.runtime.core.dispatcher.DispFile;Lcom.bea.wlw.runtime.core.request.Request;)Lcom.bea.wlw.runtime.core.request.Response;(Dispatcher.java:161) at com.bea.wlw.runtime.core.dispatcher.ServiceHandleImpl.invoke(Lcom.bea.wlw.runtime.core.request.Request;)Ljava.lang.Object;(ServiceHandleImpl.java:436) at com.bea.wlw.runtime.core.dispatcher.WlwProxyImpl._invoke(Lcom.bea.wlw.runtime.core.request.ExecRequest;)Ljava.lang.Object;(WlwProxyImpl.java:326) at com.bea.wlw.runtime.core.dispatcher.WlwProxyImpl.invoke(Ljava.lang.Object;Ljava.lang.reflect.Method;[Ljava.lang.Object;)Ljava.lang.Object;(WlwProxyImpl.java:315) at $Proxy8.validate(Lcom.puc.transferobject.UserTO;)Z(Unknown Source) at Login.LoginController.login(LLogin.LoginController$LoginForm;)Lcom.bea.wlw.netui.pageflow.Forward;(LoginController.jpf:99) ; nested exception is: java.lang.InternalError: erroneous handlers caused by: : java.lang.InternalError: erroneous handlers

    Posted by: manasshinde on July 21, 2006 at 01:08 AM

  • Configuring WebLogic 8.1 and Hibernate 3.0 - Part II

    Prakash Malani's Blog | July 29, 2005  03:02 PM | Comments (5)


     

    My previous blog entry described step-by-step instructions on configuring WebLogic 8.1 with Hibernate 3.0. The response and interest in the entry has been tremendous! In this blog entry, I evaluate advanced configuration where Hibernate leverages WebLogic's implementation of Java Naming and Directory Interface (JNDI), Java Transaction API (JTA), Java Connector Architecture (JCA), and Java Management eXtensions (JMX).

    Let me start with JNDI. Just by naming the SessionFactory in the hibernate.cfg.xml file, Hibernate makes the SessionFactory available in the JNDI. Alas! This does not work for WebLogic. As described here WebLogic JNDI and Hibernate do not play well together. There are multiple workarounds. The workarounds manually bind the SessionFactory with in the JNDI either via a WebLogic startup class or a start-up servlet. However, I was not able to get the SessionFactory instance reliably back from the JNDI. Therefore, a reasonable compromise is to add an accessor for the SessionFactory to the HibernateUtil utility class.

    In order to configure Hibernate to use JTA, I configured transaction.factory_class in the hibernate.cfg.xml file. There are two possible options: org.hibernate.transaction.JTATransactionFactory and org.hibernate.transaction.CMTTransactionFactory. The documentation recommends using the JTATransactionFactory for a bean with Bean Managed Transaction Demarcation (BMTD) and CMTTransactionFactory for a bean with Container Managed Transaction Demarcation (CMTD). The JTATransactionFactory seems more generic of the two transaction factories. It seems to support beans with BMTD as well as CMTD. Therefore, I configured JTATransactionFactory. Additionally, to lookup a transaction in a container-specific way, I configured transaction.manager_lookup_class in the hibernate.cfg.xml file. With this configuration, I do not need to use the Hibernate Transaction API at all as illustrated in the DomainManagerBean.updateWorkPhone() method.

    JCA support for Hibernate is experimental and currently not fully baked for WebLogic. In the future, I can imagine that Hibernate is packaged as Resource ARchive (RAR) file. The Hibernate RAR file is deployed as a resource adapter. The adapter makes the Session available in the JNDI. All the configuration elements are done with the resource adapter (xml file) instead of the hibernate.cfg.xml file or by some other means. Why configure Hibernate using JCA into WebLogic? JCA is designed to encapsulate legacy system's connections, transactions, etc. and make them available in the J2EE world. However, Hibernate is designed from group up to play well in the J2EE world. Therefore, the traditional resource adapter benefits are not fully realized. Once Hibernate is configured as a resource adapter, the coupling of specific applications to Hibernate is weakened a little. Multiple different applications can leverage the same Hibernate resource adapter. The benefits of this configuration will be even more pronounced with the standardization of persistence APIs of Enterprise JavaBeans (EJBs), Hibernate, and Java Data Objects (JDO) with current ongoing EJB 3.0 effort. Theoretically, hot (re)deploying the adapter and changing the persistence implementation is possible.

    Hibernate ships with JMX Management Bean (MBean) implementation. I did not see a way to deploy Hibernate into WebLogic using JMX. What are the benefits of leveraging JMX with Hibernate and WebLogic? I see at least two benefits. One is deployment as well as re-deployment. But, more importantly is being able to monitor Hibernate and obtain statistics. Runtime monitoring from a JMX console is essential for health and caring of a deployed application.

    Please try out these new additional configurations. I have updated the sample application, and it is available here. (Note: Free membership to bartsandbox is required.) I look forward to hearing your experiences on leveraging WebLogic's implementation of JNDI, JTA, JCA, and JMX with Hibernate. Comments, feedback, and questions are most welcome.

    In the future blog, entries I will discuss Spring integration with WebLogic 8.1 as well as Hibernate 3.0. So please stay tuned...

    Best regards,
    +prakash

    -----
    My blog (http://dev2dev.bea.com/blog/pmalani/)
    Answers to J2EE, Java, UML, Process, and Patterns! (http://www.bartssandbox.com/)
    Los Angeles BEA Users Group (http://groups.yahoo.com/group/LABEAUG/)


     

    Comments

    Comments are listed in date ascending order (oldest first) | Post Comment

    • I appologize if this question has already been answered. I don't want to use WLW but I do want to use weblogic 8.1sp4. Could you explain how to get Hibernate 3.0 running with WL 8.1sp4 from the linux console, talking to a mysql db. I've got the JDBC pool running, JNDI setup but not tested, Hibernate 3.0 running with ~70% of its JUnit test being successful. If there are specific reasons why you are ".. not comfortable with the dependencies from Java or EJB projects (modules into a Web project (module)." could you please explain them? Cheers, Seth

      Posted by: sethatklipmart on August 17, 2005 at 09:06 AM

    • nevermind. We are going with Spring.

      Posted by: sethatklipmart on August 17, 2005 at 12:08 PM

    • Has anybody been able to deploy hibernate 3.0 to WebLogic 9.0 using the same theory above? Im really interested in finding a way to use the JMX API's to do both deploy's and remote mgmt. Thanks in advance!!

      Posted by: robert.heise on October 13, 2005 at 05:55 PM

    • I am trying to bind the Hibernate 3.0.5 SessionFactory to the Weblogic 8.1 JNDI on the cluster. For this I did the following. 1. Wrote a startup class to instantiate a SessionFactory like this. SessionFactory sessionFactory = new Configuration().configure(cfgFile) .buildSessionFactory(); where cfgfile is a user passed parameter to the startup class and is by default hibernate.cfg.xml. 2. My hibernate.cf.xml looks like this. t3://localhost:7001 weblogic.jndi.WLInitialContextFactory jdbc/myDataSource true org.hibernate.dialect.PointbaseDialect org.hibernate.transaction.CMTTransactionFactory org.hibernate.transaction.WeblogicTransactionManagerLookup 3. I configured the startup class in the Deployment section of Admin Console. Results 1. If this startup class is targeted to one server like the admin server, it binds the SessionFactory to the JNDI tree in the admin server. 2. If this startup class is targeted to the cluster then the startup code runs fine without any fatal exception on all the managed servers but does not bind the SessionFactory to the JNDI name specified in the hibernate.cfg.xml file on either of the managed servers. The only difference I see between the execution of this startup code on a single server as opposed to on a cluster is that I see the following warning message logged by one of the Hibernate classes. "WARN SessionFactoryObjectFactory:101 -InitialContext did not implement EventContext" Has anyone faced a simple problem while starting to bind the SessionFactory to the Weblogic Cluster?

      Posted by: rn056569 on November 16, 2005 at 05:24 PM

    • I am using Weblogic 9.0 and Hibernate 3.0. I have developed a session bean which invokes hibernate object. EJB had been deployed successfully. When the EJB tries to get hold of Hibernate session factory , nothing happens. Also I have defined a datasource in weblogic server by giving JNDI name Could u pl tell me what I have to do to make this work
      Regards
      seshadri

      Posted by: SESHADRI on November 18, 2005 at 12:19 AM

posted @ 2006-12-15 02:55 扶王 阅读(1019) | 评论 (0)编辑 收藏

hibernate3.x的hql不能在weblogic8.1上正确解析的解决方法

hibernate3.x的hql不能在weblogic8.1上€正确解析的解决方法
转载1
hibernate3.0后hql采用了antlr(ANother Tool for Language Recogition)机制,由于Weblogic默认启动另外版本的antlr并且不能在启动后加载其他的antlr包。所以只能在weblogic启动时强制加载自己的antlr包。weblogic的启动参数是在startWeblogic.cmd中设置的。我修改该文件:添加 @REM Set hibernate classpath set HIBERNATE_LIB=C:\bea\user_projects\domains\mydomain\applications\embed\WEB-INF\lib 在set CLASSPATH的最前面加上 set CLASSPATH=%HIBERNATE_LIB%\antlr-2.7.6rc1.jar 参考资料如下:错误原因: If you get CharScanner; panic: ClassNotFoundException: org.hibernate.hql.ast.HqlToken - Hibernate 3.x includes a new query parser that doesn't run on Weblogic - the reason is a packaging error of ANTLR in Weblogic's boot classpath. Read the section in the Hibernate3 Migration Guide. Hibernate建议 Hibernate3 uses ANTLR for the new query parser. Unfortunately BEA Weblogic includes a version of ANTLR in the system classpath which will be loaded before any application libraries and, because Weblogic doesn't seem to support proper class loader isolation, will not see the Hibernate classes in the application's context. BEA seems to solve this issue by prefixing package names, but the distributed ANTLR doesn't have this prefix. Another source for this issue is the usage of Class.forName() in ANTLR itself. Until both parties have solved these issues we can only provide workarounds: Place all your Hibernate and dependent libraries on the application server's boot classpath or use the old query parser as described above.

转载2

在运行过程中出现
ClassNotFoundException: org.hibernate.hql.ast.HqlToken 错误weblogic异常退出。
原因:
Hibernate3.0 采用新的基于ANTLR的HQL/SQL查询翻译器,在Hibernate的配置文件中,hibernate.query.factory_class属性用来选择查询翻译器。
(1)选择Hibernate3.0的查询翻译器:
hibernate.query.factory_class= org.hibernate.hql.ast.ASTQueryTranslatorFactory
(2)选择Hibernate2.1的查询翻译器
hibernate.query.factory_class= org.hibernate.hql.classic.ClassicQueryTranslatorFactory
为了使用3.0的批量更新和删除功能,只能选择(1)否则不能解释批量更新的语句,当使用的时候出现了不支持条件输入中文的情况。选择(2)可以支持输入中文,但没法解释批量更新语句了
hibernate3中需要用到antlr,然而这个包在weblogic.jar中已经包含了antrl类库,就会产生一些类加载的错误,无法找到在war或者ear中的hibernate3.jar。
出现这个错误之后,antlr会调用System.exit(),这样weblogic就会中止服务。
解决方法:
1.是在hibernate.properties文件中增加属性:hibernate.query.factory_class,属性的值是org.hibernate.hql.classic.ClassicQueryTranslatorFactory,这样就可以解决问题了。
但是部分功能会有问题,譬如
但本系在批量删除和更新会有问题,本系统不采用
2.将antlr-2.7.5H3.jar到Weblogic的pre_Classpath :用WinRar或Winzip打开C:\bea\weblogic81\server\lib\weblogic.jar 删除里面的antlr目录, 然后再antlr-2.7.5H3.jar放在weblogic.jar的同一目录(注:替换之后没做做过严格测试,尚不知是否有后遗症)
3. 1、拷贝Hibernate3里带的包antlr-2.7.5H3.jar到%WL_HOME%\server\lib下
2、修改% mydomain% \ startWebLogic.cmd :
在set CLASSPATH之前加上下面一句:
set PRE_CLASSPATH=%WL_HOME%\server\lib\antlr-2.7.5H3.jar;
在set CLASSPATH之后加上下面一句:
set CLASSPATH=%PRE_CLASSPATH%;%CLASSPATH%

posted @ 2006-12-15 02:51 扶王 阅读(921) | 评论 (0)编辑 收藏

2006年11月8日

maximo太不可控了

        在无demo的开发库中新建了一个表,然后用应用程序设计器定制了一个界面,保存后运行,点击进入任何一个app,竟然都报mshtml.dll的错误,导致浏览器自动关闭。这个错误把我害惨了。上次发生这个错误时,我以为是自己的IE出了问题,就在网上不停的搜,下补丁、重装IE等方法都用尽了,都没能解决。最后还是重装XP系统后,阴差阳错给解决的。这次我可不想重装XP了。我尝试连demo库,一点问题都没有。看样子是我在新建表上新建app时导致maximo出错了。我用那一串sql把这个新建的app删掉,然后重启weblogic,竟然奇迹般的好了。

        感觉maximo有点牵一发而动全身,一个新建的app竟然把整个maximo给弄瘫痪了。现在还没找到出错的原因,不知道谁能给解决,总不能一出错就删app吧。

posted @ 2006-11-08 12:06 扶王 阅读(431) | 评论 (0)编辑 收藏

2006年9月6日

使用BigDecimal为何会导致NoSuchMethodError

用jasperreports1.2.3时,只要一用到BigDecimal类型的variable,就报错:
java.lang.NoSuchMethodError: java.math.BigDecimal <init> ( I)V
可能是jdk版本的问题.升级到jdk1.5就好了,用jdk1.4.2.03还不行.

posted @ 2006-09-06 08:45 扶王 阅读(1072) | 评论 (0)编辑 收藏

2006年8月13日

Quartz的cron表达式(转)

Quartz的cron表达式


一个cron表达式有至少6个(也可能7个)有空格分隔的时间元素。

按顺序依次为

秒(0~59)

分钟(0~59)

小时(0~23)

天(月)(0~31,但是你需要考虑你月的天数)

月(0~11)

天(星期)(1~7 1=SUN 或 SUN,MON,TUE,WED,THU,FRI,SAT)

7.年份(1970-2099)

其中每个元素可以是一个值(如6),一个连续区间(9-12),一个间隔时间(8-18/4)(/表示每隔4小时),一个列表(1,3,5),通配符。由于"月份中的日期"和"星期中的日期"这两个元素互斥的,必须要对其中一个设置?.

0 0 10,14,16 * * ? 每天上午10点,下午2点,4点
0 0/30 9-17 * * ?   朝九晚五工作时间内每半小时
0 0 12 ? * WED 表示每个星期三中午12点

有些子表达式能包含一些范围或列表

例如:子表达式(天(星期))可以为 “MON-FRI”,“MON,WED,FRI”,“MON-WED,SAT”

“*”字符代表所有可能的值

因此,“*”在子表达式()里表示每个月的含义,“*”在子表达式(天(星期))表示星期的每一天

 

“/”字符用来指定数值的增量

例如:在子表达式(分钟)里的“0/15”表示从第0分钟开始,每15分钟

         在子表达式(分钟)里的“3/20”表示从第3分钟开始,每20分钟(它和“3,23,43”)的含义一样


“?”字符仅被用于天(月)和天(星期)两个子表达式,表示不指定值

当2个子表达式其中之一被指定了值以后,为了避免冲突,需要将另一个子表达式的值设为“?”

 

“L” 字符仅被用于天(月)和天(星期)两个子表达式,它是单词“last”的缩写

但是它在两个子表达式里的含义是不同的。

在天(月)子表达式中,“L”表示一个月的最后一天

在天(星期)自表达式中,“L”表示一个星期的最后一天,也就是SAT

如果在“L”前有具体的内容,它就具有其他的含义了

例如:“6L”表示这个月的倒数第6天,“FRIL”表示这个月的最一个星期五

注意:在使用“L”参数时,不要指定列表或范围,因为这会导致问题

转自http://www.blogjava.net/xfan/archive/2006/06/14/52801.html 和
        http://kliweik.spaces.live.com/Blog/cns!1p_cOaBNr-K7UR23IQIXmE0g!105.entry

posted @ 2006-08-13 05:03 扶王 阅读(937) | 评论 (0)编辑 收藏

2006年8月12日

cvs处理二进制文件的问题

做的jasperreports报表文件,在我本机运行正常。通过cvs上传到服务器,别人再下载下来就不能用了。
不知道折腾了多久,才发现别人下下来的文件大小与我的不一样,多了100多字节。不知道cvs怎么处理2进制的。为什么报表文件不行,jar包却可以呢?

posted @ 2006-08-12 09:52 扶王 阅读(656) | 评论 (0)编辑 收藏

仅列出标题  

导航

统计

常用链接

留言簿(1)

随笔分类

随笔档案

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜