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'm using JBoss Seam Framework, but it's seems to me isn't very popular among
I am using Seam to inject beans to my controller using @In annotation. The
I am using RestEasy to marchal entities to JSON. That works okay but somehow
Using Seam 2.1.2 and JSF 1.2 I wonder how to store the users login
I am using seam with EJB3 + JSF and I would like to add
We are using Seam 2.2.0 Java 1.6.14 Weblogic 10.3.1.0 (named 11g Doh!) I have
I created an application using seam-gen. The created operation to search the DB ends
I'm using seam to develop a simple web app. Using a4j commandButton in many
I'm using a ajax4jsf poller <a4j:poll> to check whether an entity has been updated
Using online interfaces to a version control system is a nice way to have

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.