[EJB/JBoss] - Problem in calling an enity bean from the Stateless bean
by ashusri000
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">
oracle.toplink.essentials.PersistenceProvider
<jta-data-source>java:/system</jta-data-source>
<!-- update to match database-->
<!-- update to match database-->
<!-- update to match database-->
<!-- update to match database-->
</persistence-unit>
---------------------------------------------------------------------------------------------------------------------------------------
Please provide me some help to figure out the problem
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057981#4057981
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057981
18Â years, 10Â months
[JBoss Seam] - Problem with injecting EntityManager when invoking action wi
by tuxzilla
I have a list view page that pops up within page a send-to-friend form (using display block/none toggle). The send to friend form is submitted via <a:commandButton action="#{sendToFriend.send}"/>. The problem is that when the form is submitted, I always get the exception saying that the entityManager in the sendToFriend bean is null. I configured the entityManager the standard way, with auto-create and Conversation context.
| <core:managed-persistence-context name="entityManager"
| auto-create="true"
| persistence-unit-jndi-name="java:/myEntityManagerFactory"/>
|
The sendToFriendBean is of EVENT scope:
| @Name("sendToFriend")
| @Scope(ScopeType.EVENT)
| @AutoCreate
| public class SendToFriend {
| ...
| @In
| private EntityManager entityManager;
| ...
| public void send() {
| ...
| }
| }
|
I did some debugging, and found out that when BijectionInterceptor was trying to inject entityManager, there was no conversationContext alive (which was the scope of the entityManager). So no entityManager was created. How do I solve this problem? A related question is that, I have many other beans with EVENT scope and entityManager injection. How can they work, with conversation scope alive without me starting it?
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057980#4057980
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057980
18Â years, 10Â months
[JBoss Seam] - Problem with el parameter in dataTaqble
by amitev
Hi all! I have the following code:
ejb for populating the dataTable
| @Stateful
| @Name("projectSearch")
| public class ProjectSearchBean implements com.amitev.bts.ejb.ProjectSearchLocal {
|
| @PersistenceContext
| private EntityManager em;
|
| @DataModel
| private List<Project> projects;
|
| @Factory("projects")
| @SuppressWarnings("unchecked")
| public void retrieveProjects() {
| projects = em.createQuery("from Project").getResultList();
| }
| ..........
|
The web page with the dataTable:
| <h:dataTable var="proj" value="#{projects}">
| <h:column>
| <s:link value="#{proj.name}" action="#{projectBrowse.selectProject(proj)}" />
| </h:column>
| </h:dataTable>
|
And the projectBrowse bean
| @Stateful
| @Name("projectBrowse")
| public class ProjectBrowseBean implements com.amitev.bts.ejb.ProjectConversationLocal {
|
| @PersistenceContext(type=PersistenceContextType.EXTENDED)
| private EntityManager em;
|
| @In(required=false) @Out
| private Project project;
|
| private Issue issue;
|
| @Begin
| public void selectProject(Project selectedProject) {
| System.out.println("selectedProject: " + (selectedProject==null));
| }
| ....
|
But when i click on the link in the dataTable, null is passed to the selectProject method. The url looks like this:
.../project/list.jsf?actionMethod=pages%2Fproject%2Flist.xhtml%3AprojectBrowse.selectProject%28proj%29&cid=2&dataModelSelection=proj%3Aprojects%5B0%5D
Idea why null is passed to the action method. I saw this code in seam 1.2.1 booking demo so i suppose it has to work.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057978#4057978
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057978
18Â years, 10Â months