[Persistence, JBoss/CMP, Hibernate, Database] - session.clear() effect to Proxy
by JohnDoe2
Hi,
we use the session.clear() method to avoid that the HibernateSession massive grows. With Hibernate 3.1 it works fine. After switching to Hibernate 3.2 we get the following Exception:
org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:166)
at com.xyz.hibernate.BillingItem_$$_javassist_168.getPrice(BillingItem_$$_javassist_168.java)
Is it a bug in 3.2 or is it so correct now and the 3.1 behaviour was wrong?
If i detach a persistent object from the session which effect has it to its proxys. In 3.1 it seems that the proxy will reattach automatically.
John.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4050845#4050845
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4050845
18Â years, 10Â months
[JBoss AOP] - Re: Unable start AOP services in Jboss
by DivyaMan0j
There are all my source code. Please take some to go through them and help me solve the issue.
The MetadataBean.class (Session bean):
======================
package com.presentation.beans;
public class MetadataBean implements SessionBean
{
public String insert(String aMetadataName,
String aAttributeXML,
String aSessionId)
{
?.
?
}
public void ejbCreate() throws CreateException { }
public void setSessionContext(SessionContext sessionContext) { }
public void ejbActivate() { }
public void ejbPassivate() { }
public void ejbRemove() { }
}
=====================
Here, insert is the method exposed as a webservice and I want to intercept this method.
The Interceptor interface:
============================
package com.presentation.interfaces;
import org.jboss.aop.advice.*;
import org.jboss.aop.joinpoint.Invocation;
public interface Interceptor
{
public String getName();
public Object invoke(Invocation invocation) throws Throwable;
}
==============================
The TracingInterceptor.java class
==============================
package com.presentation.interfaces;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;
import org.jboss.aop.advice.Interceptor;
import org.jboss.system.*;
public class TracingInterceptor extends org.jboss.ejb.plugins.AbstractInterceptor implements Interceptor {
public String getName() {
return "TracingInterceptor";
}
public Object invoke(Invocation invocation) throws Throwable
{
try {
MethodInvocation mi = (MethodInvocation)invocation;
System.out.println("<< Entering Method Interceptor for : "
+ mi.getMethod().toString());
return invocation.invokeNext();
}
finally {
System.out.println(">> Leaving Method Interceptor");
}
}
}
==============================
The MetadataInterface.java
=================================
package com.presentation.interfaces;
public interface MetadataInterface extends java.rmi.Remote
{
public String insert (String aMetadataName, String aAttributeXML,
String aSessionId) throws java.rmi.RemoteException;
}
=================================
Jboss-aop.xml file. I have placed this in the META-INF directory and also copy it to the server/all/deploy/jboss-aop.deployer folder (by replacing base-aop.xml in the same location with jboss-aop.xml).
===================================
<?xml version="1.0" encoding="UTF-8"><aop><bind pointcut="execution(com.presentation.interfaces.MetadataInterface->insert(String aMetadataName, String aAttributeXML, String aSessionId))"><interceptor class="com.presentation.interfaces.TracingInterceptor"/></bind></aop>
===================================
The jboss.xml file is here :
| <jboss>
| <enterprise-beans>
| <session>
| <ejb-name>Metadata</ejb-name>
| <local-jndi-name>Metadata</local-jndi-name>
| <port-component>
| <port-component-name>Metadata</port-component-name>
| <port-component-uri>/MyServices/Metadata</port-component-uri>
| </port-component>
| </session>
| <entity>
| <ejb-name>MetadataData</ejb-name>
| <local-jndi-name>MyMetadataDataBean</local-jndi-name>
| </entity>
| <container-configurations>
| <container-configuration extends="Standard Stateless SessionBean">
| <container-name>My Special Config</container-name>
| <call-logging>false</call-logging>
| <invoker-proxy-binding-name>stateless-rmi-invoker</invoker-proxy-binding-name>
| <container-interceptors>
| <interceptor>com.presentation.interfaces.TracingInterceptor</interceptor>
| <interceptor>org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor</interceptor>
| <interceptor>org.jboss.ejb.plugins.LogInterceptor</interceptor>
| <interceptor>org.jboss.ejb.plugins.SecurityInterceptor</interceptor>
| <!-- CMT -->
| <interceptor transaction="Container">org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>
| <interceptor transaction="Container">org.jboss.ejb.plugins.CallValidationInterceptor</interceptor>
| <interceptor transaction="Container">org.jboss.webservice.server.ServiceEndpointInterceptor</interceptor>
| <interceptor transaction="Container">org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor</interceptor>
| <!-- BMT -->
| <interceptor transaction="Bean">org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor</interceptor>
| <interceptor transaction="Bean">org.jboss.ejb.plugins.TxInterceptorBMT</interceptor>
| <interceptor transaction="Bean">org.jboss.ejb.plugins.CallValidationInterceptor</interceptor>
| <interceptor transaction="Bean">org.jboss.webservice.server.ServiceEndpointInterceptor</interceptor>
| <interceptor>org.jboss.resource.connectionmanager.CachedConnectionInterceptor</interceptor>
| </container-interceptors>
| </container-configuration>
| </container-configurations>
| </jboss>
I package all of them in a jar with jboss-aop.xml in the META-INF directory. The name of the binary i place in the server/all/deploy location is docman.ear, which has docman.jar with all the class files and descriptors.
Is it mandatory to package the AOP related class file in .aop file ?
Please let me know what is the issue here ?
thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4050843#4050843
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4050843
18Â years, 10Â months