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

  • SEARCH
  • Home
  • 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 1007609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:38:37+00:00 2026-05-16T08:38:37+00:00

I’m new to EJB 3 and the JPA. I’ve created a datasource in the

  • 0

I’m new to EJB 3 and the JPA.

I’ve created a datasource in the appserver which is jdbc/AppDataSource. The default persistence provider is left as com.ibm.websphere.persistence.PersistenceProviderImpl.
And I left the default jta data source JNDI name as AppDataSource itself.
I’m actually confused regarding JTA and non-JTA. What differentiates them?

I generated the entities and created an EntityTransaction object in the bean.
Upon calling the persist() and commit() methods, I get an error:

javax.ejb.EJBException: See nested exception; nested exception is: <openjpa-1.2.1-SNAPSHOT-r422266:686069 fatal user error> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property.
Caused by: <openjpa-1.2.1-SNAPSHOT-r422266:686069 fatal user error> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property.

How does openjpa comes into picture here?

As of now, my persistence.xml contains the entity class names only.

How can I make it use the default appserver values for data source. Or else how can I provide the details of jpa provider and datasource details in the persistence.xml?

Please provide your inputs.

  • 1 1 Answer
  • 0 Views
  • 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-16T08:38:38+00:00Added an answer on May 16, 2026 at 8:38 am

    This question actually involves many concepts and I won’t cover them all in details. For more exhaustive details, I suggest reading the whole Chapter 5 – Entity Managers and Persistence Contexts of the JPA 1.0 specification (and the other relevant sections mentioned at the end of this answer). I will rather try to describe the most common scenario in a Java EE environment.

    Within an EJB environment, one would typically use:

    • A container-managed entity manager (must be a JTA entity manager)
      • transaction-scoped in Stateless Session Beans (SLSB)
      • extended in Stateful Session Beans (SFSB)
    • JTA Transaction Management (and not resource-local transactions unless this is really what you want)

    Here is how a persistence.xml for a JTA entity manager that uses a data source with a JNDI name java:comp/env/jdbc/AppDataSource can be set up, OpenJPA being the persistence provider used by WebSphere:

    <?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"
      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
      version="1.0">
      <persistence-unit name="MyPu" transaction-type="JTA">
        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
        <jta-data-source>java:comp/env/jdbc/AppDataSource</jta-data-source>
        <class>com.acme.domain.Foo</class>
        <class>com.acme.domain.Bar</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
        <properties>
          <!-- OpenJPA specific properties -->
          <property name="openjpa.TransactionMode" value="managed"/>
          <property name="openjpa.ConnectionFactoryMode" value="managed"/>
          <property name="openjpa.jdbc.DBDictionary" value="db2"/>
        </properties>
      </persistence-unit>
    </persistence>
    

    For the OpenJPA properties, refer to the OpenJPA documentation.

    And here is how a SLSB (using Container Managed Transactions) could get a container managed Entity Manager injected:

    @Stateless
    public class EmployeeServiceBean implements EmployeeService {
        @PersistenceContext(unitName="MyPu")
        private EntityManager em;
    
        public Employee createEmployee(int id, String name, long salary) {
            Employee emp = new Employee(id);
            emp.setName(name);
            emp.setSalary(salary);
            em.persist(emp);
            return emp;
        }
        ...    
    }
    

    And that’s all. The life cycle of the entity manager is managed by the container transparently for the application (no createEM/close) and the entity manager participates in the JTA transaction managed by the container (no explicit begin/commit).

    As previously hinted, I’m just scratching the surface, my goal is somehow to put you on the right path. To go further, I suggest grabbing a book (e.g. EJB3 in Action). Meanwhile, the references below would be a good reading.

    References

    • JPA 1.0 specification
      • Section 5.2.1 “Obtaining an Entity Manager in the Java EE Environment”
      • Section 5.5 “Controlling Transactions”
      • Section 5.6 “Container-managed Persistence Contexts”
      • Section 6.2.1.2 “transaction-type”
      • Section 6.2.1.4 “provider”
      • Section 6.2.1.5 “jta-data-source, non-jta-data-source”

    Resources

    • Leveraging OpenJPA with WebSphere Application Server V6.1
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6

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.