EJB 3.0 (MDB) CMT does partial Tx commit in hibernate

Seems like CMT (MDB) does partial commit.+
A secnario like this: we are using EJB3.0 combination with Hibernate
1. Some message sent to queue.
2. MDB listner who listen the queue its onMessage method is invoked. See below for MDB configurations.
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
3. Some Handler is called from MDB say ResponseHandler.
4. We called 2 update operation from this handler.
ResponseHandler#updateTable1() with below set of execution
|__ em.merg(table1Entity);
|__ em.flush()
ResponseHandler#updateTable2() with below set of execution
|__ em.merg(table2Entity);
|__ em.flush()
Problem:+
I can see only one table1 is get updated. Table2 is not updated with latest value though MDB class is container managed...
Hibernate query logs: In logs i can see update operation for both the tables
Hibernate: update table1...
Hibernate: update table2...
PS: We can't see this problem in case we put debug breakpoint on first line of onMessage() method of MDB
class ResponseListner implements MessageListener
public void onMessage(final Message message)
Logger.info("ResponseListner.onMessage() : Entered"); //breakpoint line (breakpoint is here)
Weblogic transaction logs+
####<Apr 4, 2012 4:49:09 PM IST> <Debug> <JTAXA> <inlinapplication001> <applicationServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <api.user1> <> <> <1333538349228> <BEA-000000> <BEA1-0012DE77F7FE1343F773: null: XA.prepare(rm=WLStore_application_cluster_domain2_applicationServerJDBCStore, xar=WLStore_application_cluster_domain2_applicationServerJDBCStore234212480>
####<Apr 4, 2012 4:49:09 PM IST> <Debug> <JTAXA> <inlinapplication001> <applicationServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <api.user1> <> <> <1333538349228> <BEA-000000> <startResourceUse, Number of active requests:1, last alive time:0 ms ago.>
####<Apr 4, 2012 4:49:09 PM IST> <Debug> <JTAXA> <inlinapplication001> <applicationServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <api.user1> <BEA1-0012DE77F7FE1343F773> <> <1333538349233> <BEA-000000> <BEA1-0012DE77F7FE1343F773: null: XA.prepare DONE:ok>
####<Apr 4, 2012 4:49:09 PM IST> <Debug> <JTAXA> <inlinapplication001> <applicationServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <api.user1> <BEA1-0012DE77F7FE1343F773> <> <1333538349233> <BEA-000000> <endResourceUse, Number of active requests:0>
####<Apr 4, 2012 4:49:09 PM IST> <Debug> <JTAJDBC> <inlinapplication001> <applicationServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <api.user1> <BEA1-0012DE77F7FE1343F773> <> <1333538349233> <BEA-000000> <JDBC LLR pool='com.application.ds' xid='BEA1-0012DE77F7FE1343F773' tbl='WL_LLR_applicationSERVER': begin write XA record table=WL_LLR_applicationSERVER recLen=529>
####<Apr 4, 2012 4:49:09 PM IST> <Debug> <JTAJDBC> <inlinapplication001> <applicationServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <api.user1> <BEA1-0012DE77F7FE1343F773> <> <1333538349234> <BEA-000000> <JDBC LLR pool='com.application.ds' xid='BEA1-0012DE77F7FE1343F773' tbl='WL_LLR_applicationSERVER': after write XA record>
####<Apr 4, 2012 4:49:09 PM IST> <Debug> <JTAJDBC> <inlinapplication001> <applicationServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <api.user1> <BEA1-0012DE77F7FE1343F773> <> <1333538349234> <BEA-000000> <JDBC LLR pool='com.application.ds' xid='BEA1-0012DE77F7FE1343F773' tbl='WL_LLR_applicationSERVER': commit one-phase=false>
####<Apr 4, 2012 4:49:09 PM IST> <Debug> <JTAJDBC> <inlinapplication001> <applicationServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <api.user1> <BEA1-0012DE77F7FE1343F773> <> <1333538349239> <BEA-000000> <JDBC LLR pool='com.application.ds' xid='BEA1-0012DE77F7FE1343F773' tbl='WL_LLR_applicationSERVER': commit complete>
####<Apr 4, 2012 4:49:09 PM IST> <Debug> <JTAXA> <inlinapplication001> <applicationServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <api.user1> <> <> <1333538349240> <BEA-000000> <startResourceUse, Number of active requests:1, last alive time:0 ms ago.>
####<Apr 4, 2012 4:49:09 PM IST> <Debug> <JTAXA> <inlinapplication001> <applicationServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <api.user1> <BEA1-0012DE77F7FE1343F773> <> <1333538349243> <BEA-000000> <BEA1-0012DE77F7FE1343F773: null: XA.commit DONE (rm=WLStore_application_cluster_domain2_applicationServerJDBCStore, xar=WLStore_application_cluster_domain2_applicationServerJDBCStore234212480>
####<Apr 4, 2012 4:49:09 PM IST> <Debug> <JTAXA> <inlinapplication001> <applicationServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <api.user1> <BEA1-0012DE77F7FE1343F773> <> <1333538349243> <BEA-000000> <endResourceUse, Number of active requests:0>
####<Apr 4, 2012 4:49:10 PM IST> <Info> <Health> <inlinapplication001> <applicationServer> <weblogic.GCMonitor> <<anonymous>> <> <> <1333538350589> <BEA-310002> <39% of the total memory in the server is free>
####<Apr 4, 2012 4:49:26 PM IST> <Debug> <JTAXA> <inlinapplication001> <applicationServer> <[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <BEA1-0014DE77F7FE1343F773> <> <1333538366645> <BEA-000000> <ResourceDescriptor[WLStore_application_cluster_domain2__WLS_applicationServer]: getOrCreate gets rd: name = WLStore_application_cluster_domain2__WLS_applicationServer
resourceType = 2
registered = true
scUrls = applicationServer+10.19.216.10:5003+application_cluster_domain2+t3+
xar = WLStore_application_cluster_domain2__WLS_applicationServer1926833320
healthy = true
lastAliveTimeMillis = 1333538336966
numActiveRequests = 0
>

You have to add the property toplink.ddl-generation.output-mode to your persistence.xml file, for example:
<?xml version="1.0" encoding="windows-1252" ?>
<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" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="model">
<jta-data-source>jdbc/jdm-akoDS</jta-data-source>
<properties>
<property name="toplink.logging.level" value="INFO"/>
<property name="toplink.target-database" value="Oracle"/>
<property name="toplink.ddl-generation" value="drop-and-create-tables"/>
<property name="toplink.ddl-generation.output-mode" value="database"/>
</properties>
</persistence-unit>
</persistence>

Similar Messages

  • Very simple EJB 3.0 MDB but I get NullPointerException

    I tried to create a very simple EJB 3.0 Message Driven Bean in JDeveloper 10.1.3.2 as follows:
    Message Driven Bean Class:
    import javax.ejb.MessageDriven;
    import javax.jms.Message;
    import javax.jms.MessageListener;
    @MessageDriven(mappedName="MDBQueue")
    public class MDB implements MessageListener {
    public void onMessage(Message message) {
    System.out.println("Got message!");
    Application Client:
    import javax.annotation.Resource;
    import javax.jms.*;
    public class MDBAppClient {
    @Resource(mappedName="MDBQueueConnectionFactory")
    private static QueueConnectionFactory queueCF;
    @Resource(mappedName="MDBQueue")
    private static Queue mdbQueue;
    public static void main(String args[]) {
    try {
    QueueConnection queueCon = queueCF.createQueueConnection();
    QueueSession queueSession = queueCon.createQueueSession
    (false, Session.AUTO_ACKNOWLEDGE);
    QueueSender queueSender = queueSession.createSender(null);
    TextMessage msg = queueSession.createTextMessage("hello");
    queueSender.send(mdbQueue, msg);
    System.out.println("Sent message to MDB");
    queueCon.close();
    } catch(Exception e) {
    e.printStackTrace();
    But I get the following error:
    java.lang.NullPointerException
         at model.MDBAppClient.main(MDBAppClient.java:17)
    I read similar problem in the this thread:
    Re: message driven bean on ejb 3.0 does not work
    some one said that the version in ejb-jar.xml must be changed from 2.1 to 3.0
    but in this case there is no ejb-jar.xml.
    ( I have other cases with ejb-jar.xml file but I can't change the version in ejb-jar.xml)
    the version in web.xml is 2.4 but it not accept any value except 2.4 and an error occur when I tried to change it to 3.0
    please can you tell me why I get NullPointerException and how can I allow EJB 3.0 MDB and JMS to work in JDeveloper

    Note that you can't run MDBs in the embedded OC4J in JDeveloper - try deploying to a stand-alone install of OC4J and see if it works there.

  • Auto WT creation while doing partial GR in inbound delivery

    Hi All,
    We need auto WT creation once GR got completed. It is working fine using PPF if entire item GR got completed. But if we are doing partial GR , WT is not getting created.
    We do GR partially with HU and WT need to create for that HU only.
    Please help me if you have any idea about this.
    Thanks,
    Srikanth.A

    Hi experts,
    I have the same problem.
    We have deliveries with several items and we are using Tx /SCWM/GR for the partial GR (for each item).
    The partial posting to the ERP works fine.
    After the posting we want to create the putaway warehouse task only for the item for which we posted the GR. Unfortunatley the creation only starts (by PPF) if the GR is posted for whole delivery and for all items.
    Is there a way (by PPF) to initiate the creation of the WT only for the item for which the GR is posted?
    Thanks
    Ralf 

  • UoM error while doing partial loading in O4G1- TD Transport

    Hi experts,
    while doing partial loading error pops up which says UoM not set in customizing..
    Have checked all settings for Uom its ok..
    what else could be the issue..pls help.
    regards,
    VP

    Hi,
    Data records for package 39 selected in PSA - 2 error(s). Record 5129 :No SID found for value 'EMN ' of characteristic 0BASE_UOM . Record 5132 :No SID found for value 'EMN ' of characteristic 0BASE_UOM
    The issue with record no. 5129 and 5132.
    In PSA check errorneous records and it will display only the error records, you just edit as per the require and try reloading into cube.
    Deleting single record is not possible.
    Let us know if you still have any issues.
    Reg
    Pra

  • Why is there the error "The requested protocol does not exist comm:0" ?

    Hi all,
    I want to read data from a USB serial port of the mobile phone ( Alcatel OT-806D ). The cable connects the phone and the computer. The system running in the PC is Windows XP. I launch a java j2se program which writes a number to the usb serial port. And in my midlet I run a j2me which will read on the usb port. The problem is that the output displayed in the item on my midlet is "The requested protocol does not exist comm:0". So why there is this error , and how to correct it ?
    Thank you very much

    only protocol required to be suppoted by a j2me mobile device is http://: some vendors to implement more protcols like socket:// but this depends on the vendor...

  • How to update Business Object,  rather than doing a final commit?

    Hello experts,
    I have the following <u>java web dynpro</u> code:
    What I am trying to do is to access a business object through my code. The business object has got a root node and a child node called 'version'. And the association is 1:n. I want to create 1 root node and corresponding to that, I want to create few child nodes. But the code dumps at the place where i do the child node navigation. Here is the code.
    IPatternTransaction transaction = IExternalITransaction.WD.cast(patternRtApi.
                     getSingleton(IPatternRtApi.TRANSACTION).getInterfaceController()).getApi();
    IServiceFacade serviceFacade =   (IServiceFacade)transaction.getConnectionFacade();
    IESRName esrName2 = ESRNameFactory.createESRName(<boName>,<namespace>);
    IBOModel model2 = getMyServiceFacade().getBOModel(esrName2);
    IQuery executeQuery2 = model2.createQuery(<node>,<query>);
    executeQuery2.execute();
    IBONode doNode = executeQuery2.getResultBONode();
    IBONodeElement ne1 = doNode.createBONodeElement();
    ne1.setAttributeValue(<attributeName>,new CctCode("E",null,null,null,null,null));
    <b>IBONode doVer = ne1.getAssociatedBONode("Version");</b>
    The last line of the code, I'm getting an error message saying that navigation is not allowed using local key. I know the reason for the error. The reason is when we just create the node element 'ne1', it doesn't create the 'UUID' for the record and record with UUID only allows to navigation to child node, say 'Version' node here. UUID gets generated only when you do an update or save. But I don't want to use the save function since i don't want a final commit on the transcation. But I want the UUID to get generated. Is there any method just to update the record in the backend Business Object and generate the UUID without doing a final commit.
    I tried functions like refresh, check, isdirty available on 'ne1' and 'doNode'; but that didn't solve the problem. I even tried flush() function provided by the service facade, which generates only a local IKey and not the UUID. But I want the UUID to be generated somehow not doing a final commit.
    Any kind of help is highly appeciated.
    NB: Mega bonus points for any helpful answers.
    Regards,
    Sudeep.

    Hello experts,
    I have the following <u>java web dynpro</u> code:
    What I am trying to do is to access a business object through my code. The business object has got a root node and a child node called 'version'. And the association is 1:n. I want to create 1 root node and corresponding to that, I want to create few child nodes. But the code dumps at the place where i do the child node navigation. Here is the code.
    IPatternTransaction transaction = IExternalITransaction.WD.cast(patternRtApi.
                     getSingleton(IPatternRtApi.TRANSACTION).getInterfaceController()).getApi();
    IServiceFacade serviceFacade =   (IServiceFacade)transaction.getConnectionFacade();
    IESRName esrName2 = ESRNameFactory.createESRName(<boName>,<namespace>);
    IBOModel model2 = getMyServiceFacade().getBOModel(esrName2);
    IQuery executeQuery2 = model2.createQuery(<node>,<query>);
    executeQuery2.execute();
    IBONode doNode = executeQuery2.getResultBONode();
    IBONodeElement ne1 = doNode.createBONodeElement();
    ne1.setAttributeValue(<attributeName>,new CctCode("E",null,null,null,null,null));
    <b>IBONode doVer = ne1.getAssociatedBONode("Version");</b>
    The last line of the code, I'm getting an error message saying that navigation is not allowed using local key. I know the reason for the error. The reason is when we just create the node element 'ne1', it doesn't create the 'UUID' for the record and record with UUID only allows to navigation to child node, say 'Version' node here. UUID gets generated only when you do an update or save. But I don't want to use the save function since i don't want a final commit on the transcation. But I want the UUID to get generated. Is there any method just to update the record in the backend Business Object and generate the UUID without doing a final commit.
    I tried functions like refresh, check, isdirty available on 'ne1' and 'doNode'; but that didn't solve the problem. I even tried flush() function provided by the service facade, which generates only a local IKey and not the UUID. But I want the UUID to be generated somehow not doing a final commit.
    Any kind of help is highly appeciated.
    NB: Mega bonus points for any helpful answers.
    Regards,
    Sudeep.

  • EJB 3.0 MDB deployment issue with weblogic 10.0

    Hi there,
    I am new to MDB EJB and right now I am using the EJB 3.0 with weblogic server 10.0. I am using Eclipse 3.4 for development.
    After developing the MDB from eclipse I export the EAR from eclipse and deploy it in weblogic. When I try to start the deployed EAR it gives me following error.
    weblogic.application.ModuleException: Exception preparing module: EJBModule(Message.jar)
    Unable to deploy EJB: MessageBean from Message.jar:
    [EJB:011113]Error: The Message Driven Bean 'MessageBean(Application: MessageEAR, EJBComponent: Message.jar)', does not have a message destination configured. The message destination must be set using a message-destination-link, destination-resource-link, destination-jndi-name or a resource-adapter-jndi-name.
         at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:399)
         at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
         at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:360)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
         at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:56)
         Truncated. see log file for complete stacktrace
    [EJB:011113]Error: The Message Driven Bean 'MessageBean(Application: MessageEAR, EJBComponent: Message.jar)', does not have a message destination configured. The message destination must be set using a message-destination-link, destination-resource-link, destination-jndi-name or a resource-adapter-jndi-name.
         at weblogic.ejb.container.deployer.MessageDrivenBeanInfoImpl.ensureMDBHasDestinationConfigured(MessageDrivenBeanInfoImpl.java:1811)
         at weblogic.ejb.container.deployer.MessageDrivenBeanInfoImpl.prepare(MessageDrivenBeanInfoImpl.java:1011)
         at weblogic.ejb.container.deployer.EJBDeployer.setupBeanInfos(EJBDeployer.java:997)
         at weblogic.ejb.container.deployer.EJBDeployer.prepare(EJBDeployer.java:1273)
         at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:372)
         Truncated. see log file for complete stacktrace
    >
    Any help really appreciated. It's too urgent.
    Thanks in advance,
    Piyush

    here is the code for my bean.
    package com.ups;
    import java.util.logging.Logger;
    import javax.ejb.ActivationConfigProperty;
    import javax.ejb.EJBException;
    import javax.ejb.MessageDriven;
    import javax.ejb.MessageDrivenContext;
    import javax.jms.JMSException;
    import javax.jms.Message;
    import javax.jms.MessageListener;
    import javax.jms.TextMessage;
    * Message-Driven Bean implementation class for: MessageBean
    @MessageDriven(
              activationConfig = { @ActivationConfigProperty(
                        propertyName = "destinationType", propertyValue = "javax.jms.Queue"
    public class MessageBean implements MessageListener {
         private MessageDrivenContext mdc;
    * Default constructor.
    public MessageBean() {
    // TODO Auto-generated constructor stub
    * @see MessageListener#onMessage(Message)
    public void onMessage(Message message) {
         TextMessage tmsg = null;
    try {
    tmsg = (TextMessage) message;
    System.out.println("MESSAGE BEAN: Message received: " + tmsg.getText( ));
    System.out.println ("The onMessage() is called");
    } catch (JMSException e) {
    e.printStackTrace( );
    mdc.setRollbackOnly( );
    catch (Throwable th) {
    th.printStackTrace();
    public void ejbRemove( )throws EJBException{
         System.out.println("ejbRemove() is executed >>>>>>>");
    I have configured my JMS Distributed queue in the Weblogic.
    If possible please provide more details so that I can get rid of this error as soon as possible.
    Thanks for reply.
    Piyush

  • EJB 3.0 MDB and transactions

    I'm trying to use an XA topic connection factory in my MDB, I was getting a "not supported in this release" error until I added this annotation to my MDB:
    @MessageDrivenDeployment(
    resourceAdapter = "myProviderInstance"
    But now my MDB is no longer dequeuing messages.
    I found the following in the docs (http://download-west.oracle.com/docs/cd/B31017_01/web.1013/b28221/undejdev010.htm#CCHGGHAE)
    --- BEGIN QUOTE FROM ORACLE DOCS ---
    If you use @MessageDrivenDeployment, you can configure message service options using nested @ActivationConfigProperty annotations or using @MessageDrivenDeployment attributes: @ActivationConfigProperty configuration overrides @MessageDrivenDeployment attributes.
    If you use @MessageDriven, you can configure message service options using nested @ActivationConfigProperty annotations only.
    If you configure using @MessageDrivenDeployment attributes, your application can only access a message service provider without a J2CA resource adapter. If later you decide to access your message service provider using a J2CA resource adapter, your application will fail to deploy. If you configure using nested @ActivationConfigProperty annotations, your application can access a message service provider with or without a J2CA resource adapter. Oracle recommends that if you configure using annotations, you should use the @ActivationConfigProperty approach.
    Example 2-6 shows both a @MessageDrivenDeployment and @MessageDriven annotation using @ActivationConfigProperty annotations for message service configuration. Note that the DestinationName activation configuration property in the @MessageDrivenDeployment annotation overrides that in the @MessageDriven annotation.
    Example 2-6 @MessageDriven and @MessageDrivenDeployment Annotation for a J2CA Message Service Provider
    import javax.ejb.MessageDriven;
    import oracle.j2ee.ejb.MessageDrivenDeployment;
    import javax.ejb.ActivationConfigProperty;
    import javax.jms.Message;
    import javax.jms.MessageListener;
    @MessageDriven(
    activationConfig = {
    @ActivationConfigProperty(
    propertyName="DestinationName", propertyValue="OracleASjms/MyQueue"
    @MessageDrivenDeployment(
    activationConfig = {
    @ActivationConfigProperty(
    propertyName="DestinationName", propertyValue="OracleASjms/DeployedQueue"
    @ActivationConfigProperty(
    propertyName="ResourceAdapter", propertyValue="OracleASjms"
    --- END QUOTE FROM ORACLE DOCS ---
    So, instead of specifying the resource adapter as I had above, I simply pasted the last bit of annotations from the docs into my MDB, and much to my surprise I learned that you can't have an activationConfig in a @MessageDrivenDeployment
    What's the solution?

    OK, I got a little further. Everything works now as such
    I'm using the XA topic connection factory, I'm using the resource adapter.
    BUT, when I set the transaction required attribute on the MDB, I no longer receive messages.
    No errors are logged anywhere. Any suggestions?

  • Deploying EJB 3.0 MDB on Weblogic 10.3

    My MDB is as follows:
    package test;
    import javax.ejb.ActivationConfigProperty;
    import javax.ejb.MessageDriven;
    import javax.jms.Message;
    import javax.jms.MessageListener;
    @MessageDriven(mappedName = "mdb01/queue01",
              activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue") })
    public class MDB implements MessageListener {
         public void onMessage(Message message) {
              System.out.println("Received Message: " + message);
    While deploying it on WebLogic 10.3 I get the below error:
    javax.naming.NameNotFoundException: While trying to lookup 'mdb01.queue01' didn't find subcontext 'mdb01'. Resolved ''; remaining name 'mdb01/queue01'
         at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
         at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)
         at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
         at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
         at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:254)
         at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:393)
         at javax.naming.InitialContext.lookup(InitialContext.java:392)
    Please advise what configurations I should do in WebLogic in order to deploy this MDB.

    on WebLogic console, go to the "general" tab of your server's page, and click on "view JNDI tree". there you can see whether your queue has been deployed to the server.
    if not there, verify that the queue has been properly targeted. it can be tricky, and I suggest you to use subdeployments.

  • JSF - EJB 3.0 Application - Data does not persist to the database

    Hi,
    I am developing a JSF - EJB application and the data that I send from JSP Page through JSF Managed Bean --> Session Bean --> Java Persistence does not persist in database.
    Here is my scenario ( Iam using JDeveloper IDE to create this application) -
    ------------------------------------------------------- SCENARIO START
    The scenario consists of two web pages, one enlisting all the users stored in the database, the other contains a form for adding a user
    1.) INDEX.JSP
    2.) ADDUSER.JSP
    Step 1: Create the USERS Table in database
    CREATE TABLE users
    user_id serial,
    username varchar(255) NOT NULL,
    first_name varchar(255),
    last_name varchar(255),
    password char(64) NOT NULL,
    CONSTRAINT pk_users PRIMARY KEY (user_id)
    Step 2: Add Database Connection To JDeveloper
    Go to Database Connection Navigator and create a New Database Connection using the Wizard
    Step 3: Create a New Application in JDeveloper and select JSF, EJB from Application Template
    Step 4: ENTITY BEAN - In the EJB Node Right Click and Select EJB � New Entites from Table (JPA/EJB3.0)
    Use The Wizard and create Entity Bean from Users Table which creates an Entity Bea POJO file as follows �
    User.java -
    package lux.domain;
    import java.io.Serializable;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.NamedQuery;
    import javax.persistence.SequenceGenerator;
    import javax.persistence.Table;
    @Entity
    @NamedQuery(name = "User.findAll", query = "select o from User o")
    @Table(name = "USERS")
    public class User implements Serializable {
    @Column(name="FIRST_NAME")
    private String firstName;
    @Column(name="LAST_NAME")
    private String lastName;
    @Column(nullable = false)
    private String password;
    @Column(nullable = false)
    private String username;
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="users_seq_generator")
    @SequenceGenerator(name="users_seq_generator", sequenceName="users_user_id_seq")
    @Column(name="USER_ID", nullable = false)
    private Long userId;
    public User() {
    public String getFirstName() {
    return firstName;
    public void setFirstName(String firstName) {
    this.firstName = firstName;
    public String getLastName() {
    return lastName;
    public void setLastName(String lastName) {
    this.lastName = lastName;
    public String getPassword() {
    return password;
    public void setPassword(String password) {
    this.password = password;
    public String getUsername() {
    return username;
    public void setUsername(String username) {
    this.username = username;
    public Long getUserId() {
    return userId;
    public void setUserId(Long userId) {
    this.userId = userId;
    Step 5: STATELESS SESSION BEAN - In the EJB Node Right Click and Select EJB � New Entites from Table (JPA/EJB3.0)
    Again Right Click on Model and create Session Bean from Wizard which creates two files �
    UserDAOBean.java � Stateless Session Bean
    UserDAO.java � Local Interface
    package lux.facade;
    import java.security.MessageDigest;
    import java.security.NoSuchAlgorithmException;
    import java.util.List;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import javax.persistence.Query;
    import lux.domain.User;
    @Stateless(name="UserDAO")
    public class UserDAOBean implements UserDAO {
    @PersistenceContext(unitName="Model")
    private EntityManager em;
    public UserDAOBean() {
    public User getUser(int UserId) {
    User u = new User();
    u = em.find(User.class, UserId);
    return u;
    public List<User> getAllUsers() {
    Query q = em.createQuery("SELECT u FROM User u");
    List<User> users = q.getResultList();
    return users;
    public void createUser(User u) {
    String hashedPw = hashPassword(u.getPassword());
    u.setPassword(hashedPw);
    em.persist(u);
    public void updateUser(User u) {
    String hashedPw = hashPassword(u.getPassword());
    u.setPassword(hashedPw);
    em.merge(u);
    public void deleteUser(User u) {
    em.remove(u);
    private String hashPassword(String password) {
    StringBuilder sb = new StringBuilder();
    try {
    MessageDigest messageDigest = MessageDigest.getInstance("SHA");
    byte[] bs;
    bs = messageDigest.digest(password.getBytes());
    for (int i = 0; i < bs.length; i++) {
    String hexVal = Integer.toHexString(0xFF & bs);
    if (hexVal.length() == 1) {
    sb.append("0");
    sb.append(hexVal);
    } catch (NoSuchAlgorithmException ex) {
    Logger.getLogger(UserDAOBean.class.getName()).log(Level.SEVERE, null, ex);
    return sb.toString();
    Step 6: Create a Deployment file in the Model and Deploy this to a JAR file
    Step 7: Now Right Click on View/Controller Node and create a Java File �
    UserController.java -
    package lux.controllers;
    import javax.ejb.EJB;
    import javax.faces.model.DataModel;
    import javax.faces.model.ListDataModel;
    import lux.domain.User;
    import lux.facade.UserDAO;
    public class UserController {
    @EJB UserDAO userDao;
    private User user;
    private DataModel model;
    public String createUser() {
    this.user = new User();
    return "create_new_user";
    public String saveUser() {
    String r = "success";
    try {
    userDao.createUser(user);
    } catch (Exception e) {
    e.printStackTrace();
    r = "failed";
    return r;
    public DataModel getUsers() {
    model = new ListDataModel(userDao.getAllUsers());
    return model;
    public User getUser() {
    return user;
    public void setUser(User user) {
    this.user = user;
    Step 8: Configure page flow in faces-config.xml
    1. Create the JSP file adduser.jsp by right-clicking View-Controller
    node and selecting New > JSP. Use the wizard to create JSF � JSP Page, fill in
    File Name adduser.jsp, click Finish. -
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>New user</title>
    </head>
    <body>
    <f:view>
    <h:form>
    <h:messages/>
    <h:panelGrid columns="2">
    <h:outputText value="Username"/>
    <h:inputText
    id="Username"
    value="#{user.user.username}"
    required="true"/>
    <h:outputText value="First name"/>
    <h:inputText
    id="FirstName"
    value="#{user.user.firstName}" />
    <h:outputText value="Last name"/>
    <h:inputText
    id="LastName"
    value="#{user.user.lastName}" />
    <h:outputText value="Password" />
    <h:inputSecret
    id="Password"
    value="#{user.user.password}"
    required="true" />
    <h:panelGroup/>
    <h:commandButton
    action="#{user.saveUser}"
    value="Save"/>
    </h:panelGrid>
    </h:form>
    </f:view>
    </body>
    </html>
    2. Repeat the previous step for another JSP file failed.jsp.
    3. On failed.jsp add the string <h2>Save failed</h2>.
    Next we configure the page flow.
    1. Open faces-config.xml.
    2. Create index.jsp -
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>User Listing</title>
    </head>
    <body>
    <f:view>
    <h:form>
    <h1><h:outputText value="User Listing"/></h1>
    <p><h:commandLink action="#{user.createUser}" value="Create a user"/></p>
    <h:dataTable value="#{user.user}"
    var="dataTableItem" border="1" cellpadding="2" cellspacing="2">
    <h:column>
    <f:facet name="header">
    <h:outputText value="Username"/>
    </f:facet>
    <h:outputText value="#{dataTableItem.username}" />
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="First name"/>
    </f:facet>
    <h:outputText value="#{dataTableItem.firstName}" />
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="Last name"/>
    </f:facet>
    <h:outputText value="#{dataTableItem.lastName}" />
    </h:column>
    </h:dataTable>
    </h:form>
    </f:view>
    </body>
    </html>
    3. Drag an arrow from index.jsp to adduser.jsp and replace the arrow�s label to create_new_user.
    4. Repeat the previous step for failed, by dragging and arrow from adduser.jsp to failed.jsp renaming the label to f
    ailed
    5. Finally repeat the step for adduser.jsp, by dragging from adduser.jsp to index.jsp renaming the label to success.
    This creates the following faces-config.xml file �
    <?xml version='1.0' encoding='UTF-8'?>
    <faces-config>
    <managed-bean>
    <managed-bean-name>user</managed-bean-name>
    <managed-bean-class>lux.controllers.UserController</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property>
    <property-name>username</property-name>
    <value>#{username}</value>
    </managed-property>
    <managed-property>
    <property-name>firstName</property-name>
    <value>#{firstName}</value>
    </managed-property>
    <managed-property>
    <property-name>lastName</property-name>
    <value>#{lastName}</value>
    </managed-property>
    <managed-property>
    <property-name>password</property-name>
    <value>#{password}</value>
    </managed-property>
    </managed-bean>
    <navigation-rule>
    <from-view-id>/index.jsp</from-view-id>
    <navigation-case>
    <from-outcome>create_new_user</from-outcome>
    <to-view-id>/adduser.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>
    <navigation-rule>
    <from-view-id>/adduser.jsp</from-view-id>
    <navigation-case>
    <from-outcome>failed</from-outcome>
    <to-view-id>/failed.jsp</to-view-id>
    </navigation-case>
    <navigation-case>
    <from-outcome>success</from-outcome>
    <to-view-id>/index.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>
    </faces-config>
    Step 9: Create a Deployment file in the View-Controller and Deploy this to a WAR file
    Step 10: Create a Deployment file in the View-Controller and create an EAR file and add Model�s JAR and View-Controller�s
    WAR files to it.
    Step 11: Run the JSP Files
    ------------------------------------------------------- SCENARIO END
    Now, When I execute Index.jsp, it does not list values from database and when I click on Create User link, it takes me to adduser.jsp page. When I fill values in this page and click Save button, it takes me to Save Failed page and data does not persist to the database.
    WHAT IS WRONG OUT HERE ???

    PLZZZZZZZZZzzzzzzzzzzz HELP ! ! !

  • Problem doing partial refresh (pull) of HTML region

    In my application, I have a page where on the left I have a list of documents and, on the right, selected document in PDF format.
    The right region is defined as HTML:
    <object id="DataPDF" data="f?p=&APP_ID.:18:&APP_SESSION.:APPLICATION_PROCESS=odp_show_doc::::" type="application/pdf"></object>The function odp_show_doc gets PDF document from a web service and returns a PDF BLOB that fills the region.
    However, to refresh the region with valid document data, I have to resubmit the page each time the user selects a new document.
    To refresh the page partially (only the PDF region), I have tried to use Carl Backstrom's example (http://apex.oracle.com/pls/otn/f?p=11933:48) to pull the PDF content from another page, but to no avail.
    I have defined another page (2) with a region that does the job. When I go directly on that page, I see the PDF region filling. But when I try to pull the same page with the code
    var gReturn;
    var get=new htmldb_Get(null,html_GetElement('pFlowId').value,null, 2);
    get.addParam('P0_NUM_DOC_GED', numDocGed);
    gReturn = get.get(null,'<htmldb:BOX_BODY>','</htmldb:BOX_BODY>'); 
    alert(gReturn);I get the following error:
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML2.0 EN">
    <html>
       <head>
          <title>404 Not Found</title>
       </head>
       <body>
          <h1>Not Found</h1>
          <p>The requested URL /pls/apex/wwv_flow.show was not found.</p>
       </body>
    <html>In this case, the odp_show_doc is never called (I have added some debug info in this ODP function).
    Has anyone an idea of what I am doing wrong and what correction should I do to make this pull work?
    Thank you.
    Igor

    Well... It seems to work directly on the machine, if I use the following URL when calling the application:
    http://localhost:8080/apex/f?p=120However, when I call the application from outside with the URL
    https://app-url/pls/apex/f?p=120, pulling the region based on on-demand-process results in:
    The requested URL /pls/apex/wwv_flow.show was not foundPulling an ordinary report is OK.
    Igor

  • Configuring toplink with EJB to transactional control "CMT"

    I try to use the EJB transaction CMT but I need to configure toplink to use a transactional control of my EJB container. some body knows how can i do this? and how can I configure the toplink to get JNDI datasource?
    Best Regards

    I dont think there is anything in Toplink you need to configure for CMT. All the transactional attributes are specified in the ejb-jar.xml file and I dont think you can edit this file using the Workbench or the Sessions Editor. With CMP the Workbench gives you an option to either overwrite this file or update but there is no way to "update" for transactional attributes. You can look at the examples for CMP (under folder advanced) that shows you how to use entity beans with Toplink in a CMP environment and you can look at the ejb-jar.xml file for more information.
    Configuring Toplink to get JNDI data source is easy-thats defined in the sessions.xml. Just open the sessions.xml using the sessions editor and click on login tab and then enter in the data source information.
    I try to use the EJB transaction CMT but I need to
    configure toplink to use a transactional control of
    my EJB container. some body knows how can i do this?
    and how can I configure the toplink to get JNDI
    datasource?
    Best Regards

  • EJB 3.0 MDB configuration for Topic w/ Group only read access

    We currently have a Topic on a weblogic server (10.3) in which the security access has been turned on to only allow certain users to read from that topic.
    The issue we are having is finding the necessary documentation to how to set which user that the MDBs will use when running on the app server.
    I've tried both of these properties, but haven't had any luck yet:
    <run-as-principal-name></run-as-principal-name>
    <create-as-principal-name></create-as-principal-name>
    Any ideas/documentation on how to configure it so the MDB can also listen to the topic. The MDB won't always be on the same server as the JMS as well.
    Thanks

    This page helps -- not sure if there are any other thoughts/comments/newer ways of doing it.
    http://stackoverflow.com/questions/4887427/weblogic-message-driven-bean-reading-from-a-secured-queue-runas-does-not-work
    Thanks.

  • HP C6150 All-In-One Will Not Print Black Text But Does Partial Test Print

    Hi.  Thanks in advance for any help anyone can proffer.
    I've read through the forum and I think there are some similar issues, but none exactly the same as ours.
    This HP C6150 does print pictures, but suddenly stopped printing black text.
    HOWEVER, the test prints will print in black with the Windows Logo, but will not print any associated text.
    Odd.  It just suddenly stopped printing.
    Variables:
    C6150 All in One - No other problems for two years.
    Using refilled ink cartridges from outside source. (not my decision)
    Ink is full.  No other changes made in last three days.
    Troubleshooting Steps:
    Uninstalled and then re-installed software in entirety.
    Put in 'new' (refilled) cartridge for black and magenta.
    Tried (not sure if successful) soft reset.
    Tried cleaning the print cartridge with 'Q-Tip' and distilled water.
    Have not yet spent money on new OEM print cartridges.  That is next step unless other suggestions merit.
    Possibilities:
    It may be the refilled cartridges, but they've worked so well in the past.
    The cartridge prior to the recent replacement was working fine and was not yet out of ink.
    The print head might be damaged.  But this should/would affect all black printing and this is not the case.
    Were the driver corrupt, the reinstall should have fixed it ... you'd think.
    So, we're looking for some suggestions prior to going out and getting a new printer.
    Thanks again, in advance, for constructive non-judgmental suggestions.
    MackNC

    The likely cause is the black ink is not printing at all.  When printing graphics (like the Windows Test Page) black is made from mixing the color ink.  I would suggest printing an internal diagnostic test page as shown in this page.  Does the black block print?  If not then clean the printheads as described here.  
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • @EJB annotation in entity bean does not work

    I just started with ejb3. I have created a couple of beans. One session bean that looks like this:
    @Stateless
    public class MySessionBean implements MySession
         @Resource(name="jdbc/mydb")
         private DataSource myDB;
    public void someMethod() {
    myDB.getConnection()
    This works great. The other bean is an entity bean, and there the resource injection doesn't work. It looks like this:
    @Entity
    public class MyEntityBean
    @Resource(name="jdbc/mydb")
         private DataSource myDB;
    public void someMethod() {
    myDB.getConnection()
    Is resource injection any different in an entity bean then in a session bean? Both beans belong to the same package and are in the same application, (ear). I have exactly the same problem with @EJB injection: it works fine in the session bean but not in the entity bean...
    Any help is appreciated...
    John

    <code>
    @Entity
    @Table(name = "assetfault")
    @NamedQueries( {@NamedQuery(name = ... )})
    public class Assetfault implements Serializable {
    @javax.ejb.EJB private com.novadent.data.assetmg.sessionbeans.AssetFacadeLocal aF;
    @javax.ejb.EJB private com.novadent.data.assetmg.sessionbeans.AssetfaultFacadeLocal afF;
    </code>
    importing javax.ejb.EJB ?

Maybe you are looking for

  • Black or blank screen with blinking cursor after entering Windows password

    This document pertains to all HP computers and tablets with Windows 7 and Windows 8 (8.1). You can also link directly to this document at this URL http://support.hp.com/us-en/document/c04572861  Use the following steps if your computer stops at a bla

  • Mail wont load new mail

    My Mail program will no bring in new messages! I can check the messages online at Mac.com but not in the actual program. I have already tried deleting the preferences and defining the accounts again, and it only loads the same old messages. I've also

  • Which iMac would you recommend?

    I'm a web developer by profession, and I've decided to add an iMac to my home office. MY CURRENT RIG: 3.0Ghz i5 12gb ram 500gb HDD + 500gb (external) NVIDIA GeForce GTX 550 Ti 1GB Windows 7 Home (64-bit) DELL 27" + DELL 22" Monitors (extended desktop

  • Changing Action Scripts outside of Photoshop CS3

    I did a search to see if anyone has figured this out, but I couldn't find anything. I have created several scripts that have been recorded on our main mac computer. They work great! But when we take and copy them to a different computer, they don't w

  • Trying to link two seperate song lists, any suggenstions???

    I currently live on my own and on my laptop is a completely sepereate list of songs that that of the list found on my desktop at home... my question is, is there a way to transfer the music from my home desktop itunes to my laptop itunes, using the i