-
Nov 9th, 2005, 10:39 AM
#11
Thanks.. I am going to extend the AbstractStatelessSessionBean class and see where things go.
Can I use hibernate with Spring with applicationContext.xml kept in META-INF?
I am gonna try to...but if you know something I don't know regards using hibernate from applicationContext.xml (within the ejb-side META-INF), please howl. Begs the question...can I pretty much do the same things(other than presentation-side manipulations) on ejb-side of things with applicationContext.xml in META-INF as I am able to do with WEB-INF/applicationContext.xml
-
Nov 10th, 2005, 12:53 AM
#12
I'm not sure I understand what your connection between hibernate and the application context is in this question. But surely you can use hibernate with spring and you can do your initialization of the SessionFactory in the application context.
From a conceptual point of view there is no difference between an application context used on the ejb layer and one used for web applications. It is realized by the same means anyway.
Regards,
Andreas
-
Nov 10th, 2005, 10:44 AM
#13
Trouble getting this to work
Hi
I am having a little difficulty getting the business/service pojo implementation to inject into the interface declared in the SLSB.
I have followed the advice in the manual and this thread but am getting a null pointer exception at runtime when I make a call to the SLSB business method which attempts to access the pojo instance.
Here is a snippet from my SLSB:
<slsb>
* @ejb.interface local-extends="javax.ejb.EJBLocalObject,uk.co.mycom.cbs. ejb.CBSJCTestBI" extends="javax.ejb.EJBObject"
* @ejb.home local-extends="javax.ejb.EJBLocalHome" extends="javax.ejb.EJBHome"
*
* @ejb:env-entry name="ejb/BeanFactoryPath" type="java.lang.String" value="applicationContextBE.xml"
* @ejb:bean name="CBSJCTest"
* display-name="CBS JCTest session Bean"
* type="Stateless"
* transaction-type="Container"
* view-type="both"
* jndi-name="ejb/cbs/Remote/CBSJCTest"
* local-jndi-name="ejb/cbs/CBSJCTest"
* @ejb.permission unchecked="True"
* @ejb:transaction type="Required"
*
*/
public abstract class CBSJCTestEJB extends AbstractStatelessSessionBean implements
CBSJCTestBI{
CBSJCTestBI bizPojo;
protected void onEjbCreate() throws CreateException {
bizPojo = (CBSJCTestBI) getBeanFactory().getBean("testBizPojo");
}
/**
* @ejb:interface-method view-type="both"
*/
public String testGetSomething() throws BasicException {
return bizPojo.testGetSomething(); //"test string returned from ejb!";
}
</slsb>
And my applicationContextBE.xml:
<quote>
<bean id="testBizPojo" class="uk.co.mycom.cbs.ejb.JCTestPojo" singleton="false"/>
</quote>
I have put my applicationContextBE.xml file in the cbs-ejb.jar root. The ejb jar file is deployed as part of an ear file (not sure if that would affect things).
The exception stack trace is as follows:
16:23:13,393 INFO [Server] JBoss (MX MicroKernel) [3.2.6 (build: CVSTag=JBoss_3_2_6 date=200410140106)] Started in 1m:8s:953
ms
16:23:24,518 WARN [SessionImpl] unclosed connection
16:23:33,299 INFO [TilesRequestProcessor] Tiles definition factory found for request processor ''.
16:23:33,424 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.taglib.bean.LocalStrings ', returnNull=t
rue
16:23:33,471 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true
16:23:33,471 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings ', returnNull=t
rue
16:23:33,471 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings ', returnNull=t
rue
16:23:35,487 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.actions.LocalStrings', returnNull=true
16:23:35,549 ERROR [LogInterceptor] RuntimeException in method: public abstract java.lang.String uk.co.mycom.cbs.ejb.CBSJC
TestLocal.testGetSomething() throws uk.co.mycom.cbs.common.BasicException
java.lang.NullPointerException
at uk.co.mycom.cbs.ejb.CBSJCTestEJB.testGetSomething( CBSJCTestEJB.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.ejb.StatelessSessionContainer$ContainerI nterceptor.invoke(StatelessSessionContainer.java:6 83)
at org.jboss.resource.connectionmanager.CachedConnect ionInterceptor.invoke(CachedConnectionInterceptor. java:186)
at org.jboss.ejb.plugins.StatelessSessionInstanceInte rceptor.invoke(StatelessSessionInstanceInterceptor .java:72)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invoke Next(AbstractTxInterceptor.java:84)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTran sactions(TxInterceptorCMT.java:315)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxIn terceptorCMT.java:148)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(S ecurityInterceptor.java:111)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInt erceptor.java:191)
at org.jboss.ejb.plugins.ProxyFactoryFinderIntercepto r.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.StatelessSessionContainer.internalIn voke(StatelessSessionContainer.java:331)
at org.jboss.ejb.Container.invoke(Container.java:709)
at org.jboss.ejb.plugins.local.BaseLocalProxyFactory. invoke(BaseLocalProxyFactory.java:419)
at org.jboss.ejb.plugins.local.StatelessSessionProxy. invoke(StatelessSessionProxy.java:83)
at $Proxy125.testGetSomething(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
Any help is much appreciated.
Jim
-
Nov 11th, 2005, 01:12 AM
#14
At first glance I see no problem here. However, I'm noticing that you use XDoclet. I remember a similar case where by using XDoclet somehow an empty ejbCreate()-Method has been created. This, in fact, overrides the method provided by Spring, which causes your onEjbCreateMethod() to never being invoked.
Maybe you can check this out?
Regards,
Andreas
-
Nov 11th, 2005, 06:54 AM
#15
A thousand 'thank-you's! That fixed my problem.
For anyone else experiencing the same problem here's the original post of the 'similar case' Andreas is referring to:
http://forum.springframework.org/sho...eate+XDocl et
(Not too sure, tho', where the ejbCreate method is being generated because it doesn't appear to be in either of my EJB implementation classes.
Jim
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules