This post was updated on .
Thank you so much for your valuable input Ludovic :)
I no longer get the error. However I have ran into another problem now.
1. Data is not getting persisted.
2. Upon using em.persist(user), we don't see the SQL query on the console
3. I see "0 enlisted resource" even if it was able to read "1 resource(s) [jdbc/testDS]" on Line:220 (as below)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/ssubudhi/.m2/repository/org/slf4j/slf4j-simple/1.6.4/slf4j-simple-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/ssubudhi/.m2/repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
70 [main] INFO bitronix.tm.BitronixTransactionManager - Bitronix Transaction Manager version 2.1.4
70 [main] WARN bitronix.tm.Configuration - cannot get this JVM unique ID. Make sure it is configured and you only use ASCII characters. Will use IP address instead (unsafe for production usage!).
80 [main] INFO bitronix.tm.Configuration - JVM unique ID: <10.10.5.207>
210 [main] INFO bitronix.tm.recovery.Recoverer - recovery committed 0 dangling transaction(s) and rolled back 0 aborted transaction(s) on 1 resource(s) [jdbc/testDS] (restricted to serverId '10.10.5.207')
log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Hibernate: drop table if exists Patient cascade
Hibernate: create table Patient (userId serial not null, userName varchar(255), primary key (userId))
1621 [main] WARN bitronix.tm.twopc.Preparer - executing transaction with 0 enlisted resource
1621 [main] INFO bitronix.tm.BitronixTransactionManager - shutting down Bitronix Transaction Manager
Please find the modified file attached with this email.
Thanks a lot,
From: Ludovic Orban-2 [via Bitronix Transaction Manager] [mailto:firstname.lastname@example.org]
Sent: Wednesday, April 15, 2015 11:51 PM
To: Subudhi, Suchi
Subject: Re: javax.naming.NoInitialContextException -Standalone program
I couldn't run your sample until the end as it expects a postgres
database to be up and running, but I nevertheless found a few problems
that are easy to fix:
1) jndi.properties must be in src/main/resources and not in src/main.
That's the way maven works.
2) Your datasource(s) and transaction manager *must* be initialized
before hibernate. Simply make sure that you create your
PoolingDataSource and call init on it and call
TransactionManagerServices.getTransactionManager() before you call
Persistence.createEntityManagerFactory() otherwise hibernate will try
to initialize the transaction manager itself and will complain about
missing datasources and such.
3) There is no need to bind the datasources in JNDI yourself: *all*
the initialized PoolingDataSource's *automatically* are available via
the BitronixInitialContext as soon as they are initialized and are
removed from the latter when they get closed. Keep in mind that the
bitronix JNDI is not a full JNDI provider, it merely is a read-only,
partial implementation that allows you (and 3rd party libs) to lookup
objects that are managed by BTM.
Hopefully this should help you getting started.
On Thu, Apr 16, 2015 at 1:29 AM, suchi <[hidden email]</user/SendEmail.jtp?type=node&node=1711&i=0>> wrote:
> I'm trying to make JPA and JTA to work together via Hibernate and Bitronix
> Transaction Manager.
> Please see the attached "sampleJTA.zip" attachment for details.
> I keep running into javax.naming.NoInitialContextException inspite of
> defining jndi.properties and pooling datasource.
> View this message in context: http://bitronix-transaction-manager.10986.n7.nabble.com/javax-naming-NoInitialContextException-Standalone-program-tp1709p1710.html
> Sent from the Bitronix Transaction Manager mailing list archive at Nabble.com.
> To unsubscribe from this list, please visit:
To unsubscribe from this list, please visit:
If you reply to this email, your message will be added to the discussion below:
To unsubscribe from javax.naming.NoInitialContextException -Standalone program, click here<http://bitronix-transaction-manager.10986.n7.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1709&code=c3N1YnVkaGlAd2VzdGVjaG1lZC5jb218MTcwOXwtMjE0NjM2OTYxMQ==>.
SimpleBTM.zip (28K) <http://bitronix-transaction-manager.10986.n7.nabble.com/attachment/1713/0/SimpleBTM.zip>
|Free forum by Nabble||Edit this page|