Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Errors in named query while deploying ear in weblogic 10.3
PostPosted: Wed Jun 09, 2010 10:25 pm 
Newbie

Joined: Wed Jun 09, 2010 10:10 pm
Posts: 2
Hi All,

I am migrating my appln from Jboss to weblogic 10.3 . I am using the same ear file, that is deployed in JBoss, to deploy in weblogic 10.3. In Jboss the deployment is successful and the appln runs fine.

However when I deploy the ear in weblogic, it shows an error

An error occurred during activation of changes, please see the log for details.
weblogic.management.DeploymentException:
Substituted for missing class org.hibernate.HibernateException - Errors in named queries: deleteSession, selectName



'deleteSession'-for deleting an entry in table , 'selectName' - for selecting an entry in table are the names of the named query.


After having done some research i found that Weblogic 10.3. depends on ANTLR
Hibernate EntityManager also depends on ANTLR which is not loaded by the classloader.

Hibernate3 uses the ANTLR libraries to parse NamedQueries and thus this error.

So I changed my persistence.xml by adding this property: <property name="hibernate.query.factory_class" value="org.hibernate.hql.classic.ClassicQueryTranslatorFactory" />

to use the classic query parser from Hibernate instead of the ANTLR based one.



Now if i try to deploy i am getting the error msg as

An error occurred during activation of changes, please see the log for details.
weblogic.management.DeploymentException:
Substituted for missing class org.hibernate.HibernateException - Errors in named queries: deleteSession.


The full stack trace is as follows:

weblogic.management.DeploymentException:
at weblogic.application.internal.BaseDeployment.throwAppException(BaseDeployment.java:157)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:371)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:58)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:154)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:98)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

Caused By: org.hibernate.HibernateException: Errors in named queries: deleteSession
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:365)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:713)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127)
at weblogic.deployment.PersistenceUnitInfoImpl.createEntityManagerFactory(PersistenceUnitInfoImpl.java:352)
at weblogic.deployment.PersistenceUnitInfoImpl.createEntityManagerFactory(PersistenceUnitInfoImpl.java:332)
at weblogic.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:134)
at weblogic.deployment.AbstractPersistenceUnitRegistry.storeDescriptors(AbstractPersistenceUnitRegistry.java:336)
at weblogic.deployment.EarPersistenceUnitRegistry.initialize(EarPersistenceUnitRegistry.java:75)
at weblogic.application.internal.flow.InitJpaFlow.prepare(InitJpaFlow.java:38)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:1221)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:367)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:58)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:154)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:98)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

Can anyone help in overcoming this problem?


Top
 Profile  
 
 Post subject: Re: Errors in named query while deploying ear in weblogic 10.3
PostPosted: Wed Jun 30, 2010 10:42 am 
Newbie

Joined: Wed Jun 30, 2010 10:23 am
Posts: 2
Hi

I have had the same problem. I'm using Weblogic 10.3.3, Hibernate-core 3.3.2 and Hibernate-entitymanger 3.4.0, and I've already tried to use weblogic.xml and weblogic-application.xml unsuccessfully. Did you get any solution for this issue?

Thank you

Gleber


Top
 Profile  
 
 Post subject: Re: Errors in named query while deploying ear in weblogic 10.3
PostPosted: Thu Jul 01, 2010 5:13 am 
Newbie

Joined: Wed Jun 09, 2010 10:10 pm
Posts: 2
Hi gleber,

Change startWebLogic.cmd in the bin directory by adding:


set PRE_CLASSPATH=INSTALLATION_HOME_DIRECTORY\user_projects\domains\DOMAIN_NAME\lib\antlr-2.7.5H3.jar

set CLASSPATH=%PRE_CLASSPATH%;%SAVE_CLASSPATH%


This solved my problem. Hope it helps you.


Top
 Profile  
 
 Post subject: Re: Errors in named query while deploying ear in weblogic 10.3
PostPosted: Wed Jul 07, 2010 10:23 am 
Newbie

Joined: Wed Jun 30, 2010 10:23 am
Posts: 2
Hi!

Your solution worked for me too. I found another solution using weblogic-application.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application>
   <prefer-application-packages>
      <package-name>org.hibernate.*</package-name>
      <package-name>org.apache.*</package-name>
      <package-name>antlr.*</package-name>
    </prefer-application-packages>
</weblogic-application>

With this file inside WEB-INF directory my application worked fine.
But the fact that the Hibernate depends on an older version of the antlr lib bother me. I have used 2.7.6 version, but Weblogic 11g already has a 2.7.7 version. That's the problem. Could it be a bug??

Thanks

Gleber


Top
 Profile  
 
 Post subject: Re: Errors in named query while deploying ear in weblogic 10.3
PostPosted: Fri Sep 17, 2010 9:53 am 
Newbie

Joined: Fri Sep 17, 2010 8:50 am
Posts: 1
We've hit the same hibernate/antlr/weblogic 10 issue and believe it is a bug (of sorts) in WebLogic. You may be interested in detail below - this was what we sent on to Oracle support.

Regards,

Adrian

-------------------

We've taken a closer look at the class loading issue we are hitting with Hibernate and Antlr The problem seemed to be that hibernate was invoking an Antlr method and passing a reference to a Hibernate class. Antlr then tried to load this Hibernate class but couldn't, because Antlr had been loaded by the system class loader, whereas the Hibernate libraries were packaged with the application. As the system classloader had no visibility of classes loaded by the applicaiton classloader, the Hibernate class could not be loaded by the Antlr code.

This makes some sense, however we were puzzled as to why this issue had not occurred in WebLogic 9.2, which also packages a version of Antlr. We took a look at the code for Antlr 2.7.7 from the Antlr site, and noted the code actually has a mechanism built in to address issue described above - checking thread classloaders and using appropriate class loader to get classes (Antlr class antlr.CharScanner, method public "void setTokenObjectClass(String s)", calls method "Utils.loadClass(s)" to get class). So this issue should not be occurring with Antlr 2.7.7, which is the version supposodly shipped with WebLogic 10.3.3.

Using a Java decompiler, we then examined the code for this Antlr class in both WLS 923 and WLS 1033. The WLS 923 code is the same as the above, hence we do not see this issue using that WebLogic version. However, the WLS 1033 Antlr packaged in "com.bea.core.antlr.runtime_2.7.7.jar" is different - the method mentioned above uses "Class.forName(s)" to load the class. This is older Antlr code - e.g. the 2.7.3 code behaves in this way. It looks like these issues were previously found and addressed in Antlr. As this method in the library supplied with WLS10 does not include this fix, we have an issue with WLS 1033. So, while the weblogic version of Antlr appears to be 2.7.7, it is actually an older version - for this class at least - and in fact is older than the version which was previously included with WLS 923.

Replacing the verison of Antlr supplied with WebLogic with the official 2.7.7 Antlr JAR appears to resolve our Antlr issues.Is replacing the Antlr JAR file in this way a supported configuration?


Top
 Profile  
 
 Post subject: Re: Errors in named query while deploying ear in weblogic 10.3
PostPosted: Wed Jul 13, 2011 5:28 am 
Newbie

Joined: Wed Jul 13, 2011 4:51 am
Posts: 1
Hi siva3446,
You saved my day! Thank you very much for posting this!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 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.