Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1107933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:00:24+00:00 2026-05-17T02:00:24+00:00

I am using seam with tomcate and icefaces the problem is when I inject

  • 0

I am using seam with tomcate and icefaces the problem is when I inject entity manager in component bean it works well but if put it in generic DAO it returns null my code is like that:

this the bean

@Scope(ScopeType.PAGE)
@Name("TestBean")
public class TestBean {
 public void test(ActionEvent actionEvent) {
  Roles entity = new Roles();
  entity.setName("cons");
  RolesDao dao = new RolesDao();
  dao.emPrisit(entity);

 }
}

DAO

public class RolesDao {
 @In
 EntityManager em;

 public void emPrisit(Roles entity) {
  em.persist(entity);
 }

}

Component.xml

<persistence:entity-manager-factory name="bookingDatabase"/>

<persistence:managed-persistence-context name="em"
                           auto-create="true" 
                entity-manager-factory="#{bookingDatabase}"/>   

persistence.xml

<persistence-unit name="bookingDatabase"
  transaction-type="RESOURCE_LOCAL">
  <provider>org.hibernate.ejb.HibernatePersistence </provider>
  <jta-data-source>java:comp/env/AP</jta-data-source>
  <properties>
   <property name="transaction.flush_before_completion" value="true" />
   <property name="transaction.factory_class"
    value="org.hibernate.transaction.JDBCTransactionFactory" />

   <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
   <!--
    <property name="hibernate.transaction.manager_lookup_class"
    value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
   -->

  </properties>
 </persistence-unit>

if I inject entitymanger in bean not dao it runs well the second problem when I add this annotation before entitymanger

@In
 @PersistenceContext(type = PersistenceContextType.EXTENDED)
 EntityManager em;

it give this exception

caused by: java.lang.IllegalArgumentException: @PersistenceContext may only be used on session bean or message driven bean components: TestBean
 at org.jboss.seam.Component.checkPersistenceContextForComponentType(Component.java:901)
 at org.jboss.seam.Component.scanField(Component.java:877)
 at org.jboss.seam.Component.initMembers(Component.java:557)
 at org.jboss.seam.Component.<init>(Component.java:244)
 at org.jboss.seam.Component.<init>(Component.java:205)
 at org.jboss.seam.init.Initialization.addComponent(Initialization.java:1186)
 ... 13 more
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:00:25+00:00Added an answer on May 17, 2026 at 2:00 am

    You don’t need both @In and @PersistenceContext on your EntityManager. It is enough with one of them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having problems generating a app(using seam generate after seam create-project) With identifying
It is an application that has been built using seam 2.2 and it is
I'm trying to test my code, written using JBoss Seam and Hibernate. What I'd
I'm working on developing some web services using RESTeasy and Seam. One of the
How does Seam Framework handle composite primary keys in pages.xml using EntityHome? The usual
How can Seam be configured to use different security-constraints for different web-resource-collections? In web.xml
I am developing my first Seam + Android application and I am facing some
I face the same issue as described here Rich modalpanel closes automatically I'm using
I made a change to our cluster-deployed application to be authenticated via Oracle SSO
When I try to compile my VSTO Outlook addin, I get this error: Reference

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.