• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in calling Enity Bean from Stateless Bean (ejb3.0)

 
Amit Chauhan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All ,

I am facing problem in calling a entity Bean from a Stateless Bean .The call flow goes like this:
Jsp Page --> Servlet --> Stateless Bean --> Persisting the Data obtained from jsp page into entity bean .

The jsp page & Servlet are deployed as a separate .war file on the Jboss server while the Stateless bean and the persistence unit is deployed as .ear file on the same Server . When I make a call to persist the values then it throws up an error at the runtime :

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

Exception Description: Cannot acquire data source [java:/system].
Internal Exception: javax.naming.InvalidNameException: Not a compound name: system
12:19:00,984 ERROR [STDERR] at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:220)
12:19:00,984 ERROR [STDERR] at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:78)
12:19:00,984 ERROR [STDERR] at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:111)
12:19:00,984 ERROR [STDERR] at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:105)
12:19:00,984 ERROR [STDERR] at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:76)
12:19:00,984 ERROR [STDERR] at src.FirstSessionBean.sayHello(FirstSessionBean.java:23)
12:19:00,984 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
12:19:00,984 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
12:19:00,984 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
12:19:00,984 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
12:19:00,984 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
12:19:00,984 ERROR [STDERR] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
12:19:00,984 ERROR [STDERR] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
12:19:00,984 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
12:19:00,984 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
12:19:00,984 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
12:19:01,000 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)Exception Description: Cannot acquire data source [java:/system].
Internal Exception: javax.naming.InvalidNameException: Not a compound name: system
12:19:00,984 ERROR [STDERR] at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:220)
12:19:00,984 ERROR [STDERR] at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:78)
12:19:00,984 ERROR [STDERR] at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:111)
12:19:00,984 ERROR [STDERR] at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:105)
12:19:00,984 ERROR [STDERR] at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:76)
12:19:00,984 ERROR [STDERR] at src.FirstSessionBean.sayHello(FirstSessionBean.java:23)
12:19:00,984 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
12:19:00,984 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
12:19:00,984 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
12:19:00,984 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
12:19:00,984 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
12:19:00,984 ERROR [STDERR] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
12:19:00,984 ERROR [STDERR] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
12:19:00,984 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
12:19:00,984 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
12:19:00,984 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
12:19:01,000 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)

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


The stateless bean call is working fine but the call from stateless bean to the entity bean throws up this error . The name of my data source is "system" and I have my persistence.xml file as this :

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

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="testApp" transaction-type="JTA">
<provider> oracle.toplink.essentials.PersistenceProvider</provider>
<jta-data-source>java:/system</jta-data-source>
<properties>

<property name="toplink.jdbc.driver" value="oracle.jdbc.OracleDriver"/> <!-- update to match database-->
<property name="toplink.jdbc.url" value="jdbc racle:thin:@localhost:1521:XE"/> <!-- update to match database-->
<property name="toplink.jdbc.password" value="kjhu"/> <!-- update to match database-->
<property name="toplink.jdbc.user" value="system"/> <!-- update to match database-->
</properties>
</persistence-unit>

</persistence>

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


Please provide me some help to figure out the problem .

Regards
Amit
 
Mukhtiar Ahmed
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
first create oracle-ds.xml look like following file

<?xml version="1.0" encoding="UTF-8"?>

<!-- ===================================================================== -->
<!-- -->
<!-- JBoss Server Configuration -->
<!-- -->
<!-- ===================================================================== -->

<!-- $Id: oracle-ds-template.xml,v 1.6 2007/01/24 18:40:34 dave Exp $ -->
<!-- ==================================================================== -->
<!-- Datasource config for Oracle originally from Steven Coy -->
<!-- ==================================================================== -->


<local-tx-datasource>
<jndi-name>system</jndi-name>
<connection-url>jdbc racle:thin:@localhost:1521:XE</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>username</user-name>
<password>password</password>

<min-pool-size>20</min-pool-size>
<max-pool-size>100</max-pool-size>
<blocking-timeout-millis>5000</blocking-timeout-millis>
<idle-timeout-minutes>1</idle-timeout-minutes>
<type-mapping>Oracle9i</type-mapping>
<local-tx-datasource>


then create persistance.xml file like following

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="testApp" transaction-type="JTA">
<provider> oracle.toplink.essentials.PersistenceProvider</provider>
<jta-data-source>java:/system</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
</persistence-unit>

</persistence>
 
Amit Chauhan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I am facing a problem after I deploy my datasource.xml file in the deploy directory . Then if I try to list the jndo tree from the server's web console then I face this error:





18:50:34,953 ERROR [JNDIView] JNDIView.getHAJndiAttributes() failed
java.lang.NullPointerException: name cannot be null
at javax.management.ObjectName.construct(Unknown Source)
at javax.management.ObjectName.(Unknown Source)
at org.jboss.naming.JNDIView.getHAJndiAttributes(JNDIView.java:836)
at org.jboss.naming.JNDIView.getHAUrl(JNDIView.java:811)
at org.jboss.naming.JNDIView.listXML(JNDIView.java:327)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
er.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
or.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
BeanOperationInterceptor.java:142)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.jmx.adaptor.control.Server.invokeOpByName(Server.java:258)
at org.jboss.jmx.adaptor.control.Server.invokeOp(Server.java:223)
at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOp(HtmlAdaptorSer
vlet.java:262)
at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdap
torServlet.java:100)
at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServl
et.java:82)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
lter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:175)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
e.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
rocessConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
kerThread.java:112)
at java.lang.Thread.run(Unknown Source)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic