[EJB 3.0] - Remote EJB call problem
by achalov
I have a problem accessing generated primary key for entity when call create method through remote ejb3 interface. The piece of SLSB code is
| public T persist(T entity) {
| getEntityManager().persist(entity);
| return entity;
| }
|
| public void flush() {
| getEntityManager().flush();
| }
|
, entity
| @Id
| @Column(nullable = false, name = "id")
| @SequenceGenerator(name = "CountrySequenceGenerator", sequenceName = "country_id_seq")
| @GeneratedValue(strategy = GenerationType.AUTO, generator = "CountrySequenceGenerator")
| private Long id;
|
and client call
| CountryRemote countryRemote = JBossEjbLocator.getLocator().getReference(CountryRemote.class);
| CountryLocal countryLocal = JBossEjbLocator.getLocator().getReference(CountryLocal.class);
|
| public Long createCountryLocal() {
| Country country = new Country();
| country.setName("Test Country");
| countryLocal.persist(country);
| countryLocal.flush();
| return country.getId();
| }
|
| public Long createCountryRemote() {
| Country country = new Country();
| country.setName("Test Country");
| countryRemote.persist(country);
| countryRemote.flush();
| return country.getId();
| }
|
Actually local call works fine. Generated id for country object are set when flush() called, but calls through remote interface always return null.
When I look through database records I see that records successfully added in both cases. Calling refresh() on entity gives no result.
JBoss AS version jboss5.0.1.GA, database PostgreSQL 8.3. JDBC3 driver used.
Client code is called from JSF managed bean.
What I am douing wrong? Actually, I think that there should be no difference in the way I call ejb3.
Thanks for your answers in advance.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4234373#4234373
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4234373
15 years, 9 months
[Persistence, JBoss/CMP, Hibernate, Database] - Problem Using Annotated Beans with JTA. Data is not written
by taranis
Hi,
When i try to use JPA Annotated beans with JTA, data is not saved to DB.
There are no exceptions but data is not committed to DB, it is like my bean is transient but i have annotated it with @Entity and it must not be Transient.
I have created a war file and deployed to JBoss, tested this in a simple Servlet in that war file.
JBoss version: 4.2.2.GA
Here is SessionFactory configuration:
| myConf.setProperty("hibernate.connection.driver_class", "oracle.jdbc.driver.OracleDriver");
| myConf.setProperty("hibernate.connection.url", "jdbc:oracle:thin:@47.168.58.53:5121:mcpdb");
| myConf.setProperty("hibernate.connection.username", "polguc_1");
| myConf.setProperty("hibernate.connection.password", "pwdPin_1_2pwdPin_1_2");
| myConf.setProperty("hibernate.connection.pool_size", "10");
| myConf.setProperty("hibernate.dialect", "org.hibernate.dialect.Oracle10gDialect");
| myConf.setProperty("hibernate.transaction.factory_class", "org.hibernate.transaction.JTATransactionFactory");
| myConf.setProperty("hibernate.transaction.manager_lookup_class","org.hibernate.transaction.JBossTransactionManagerLookup");
| myConf.setProperty("jta.UserTransaction","java:comp/UserTransaction");
| myConf.setProperty("hibernate.session_factory_name","hibernate/HibernateFactory");
| myConf.setProperty("hibernate.current_session_context_class", "jta");
| myConf.setProperty("hibernate.show_sql", "true");
| myConf.setProperty("hibernate.hbm2ddl.auto", "create");
| myConf.addAnnotatedClass(Flight.class);
This is the Annotated Bean:
| @Entity
| @Table(name="tbl_flight")
| public class Flight implements Serializable {
|
| Long id;
| String name;
|
| public Flight ()
| {
|
| }
|
| @Id @GeneratedValue(strategy=GenerationType.SEQUENCE)
| public Long getId() { return id; }
|
| private void setId(Long id) { this.id = id; }
|
| @Column
| public String getName() {
| return name;
| }
|
| public void setName(String name) {
| this.name = name;
| }
| }
This is the JTA Transaction and data persist code:
UserTransaction tx = null;
| try {
| Properties hibernateCfg = HibernateUtil.getConfiguration().getProperties();
| Context jndiContext =
| NamingHelper.getInitialContext( NamingHelper.getJndiProperties(hibernateCfg));
| TransactionManagerLookup tmLookup =
| TransactionManagerLookupFactory.getTransactionManagerLookup(hibernateCfg);
| javax.transaction.TransactionManager tm = tmLookup.getTransactionManager(hibernateCfg);
| String userTxName = tmLookup.getUserTransactionName();
| tx = (javax.transaction.UserTransaction) (new InitialContext()).lookup(userTxName);
|
| try {
| tx.begin();
|
| Flight entity = new Flight();
| entity.setName("flightName");
| HibernateUtil.getSessFact().getCurrentSession().persist(entity);
| HibernateUtil.getSessFact().getCurrentSession().flush();
| tx.commit();
|
|
| } catch (HibernateException e) {
| // TODO Auto-generated catch block
| tx.rollback
| e.printStackTrace();
| }
| ..........
| .....
|
Jboss logs, you can see insert statement is used at the end of the logs
anonymous wrote :
| 23:21:53,418 INFO [Server] JBoss (MX MicroKernel) [4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)] Started in 17s:906ms
| 23:22:28,433 INFO [Version] Hibernate Annotations 3.2.1.GA
| 23:22:28,558 INFO [Environment] Hibernate 3.2.4.sp1
| 23:22:28,637 INFO [Environment] hibernate.properties not found
| 23:22:28,652 INFO [Environment] Bytecode provider name : javassist
| 23:22:28,699 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
| 23:22:30,043 INFO [AnnotationBinder] Binding entity from annotated class: test.Flight
| 23:22:30,652 INFO [EntityBinder] Bind entity test.Flight on table tbl_flight
| 23:22:32,012 INFO [DriverManagerConnectionProvider] Using Hibernate built-in connection pool (not for production use!)
| 23:22:32,027 INFO [DriverManagerConnectionProvider] Hibernate connection pool size: 10
| 23:22:32,027 INFO [DriverManagerConnectionProvider] autocommit mode: false
| 23:22:32,043 INFO [DriverManagerConnectionProvider] using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@47.168.58.53:5121:mcpdb
| 23:22:32,043 INFO [DriverManagerConnectionProvider] connection properties: {user=polguc_1, password=pwdPin_1_2pwdPin_1_2}
| 23:22:32,527 INFO [SettingsFactory] RDBMS: Oracle, version: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
| With the Partitioning, OLAP, Data Mining and Real Application Testing options
| 23:22:32,527 INFO [SettingsFactory] JDBC driver: Oracle JDBC driver, version: 10.2.0.1.0
| 23:22:32,699 INFO [Dialect] Using dialect: org.hibernate.dialect.Oracle10gDialect
| 23:22:32,762 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.transaction.JTATransactionFactory
| 23:22:32,824 INFO [NamingHelper] JNDI InitialContext properties:{}
| 23:22:32,840 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
| 23:22:32,855 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
| 23:22:32,871 INFO [SettingsFactory] Automatic flush during beforeCompletion(): disabled
| 23:22:32,871 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
| 23:22:32,871 INFO [SettingsFactory] JDBC batch size: 15
| 23:22:32,871 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
| 23:22:32,871 INFO [SettingsFactory] Scrollable result sets: enabled
| 23:22:32,871 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
| 23:22:32,887 INFO [SettingsFactory] Connection release mode: auto
| 23:22:32,887 INFO [SettingsFactory] Default batch fetch size: 1
| 23:22:32,887 INFO [SettingsFactory] Generate SQL with comments: disabled
| 23:22:32,887 INFO [SettingsFactory] Order SQL updates by primary key: disabled
| 23:22:32,887 INFO [SettingsFactory] Order SQL inserts for batching: disabled
| 23:22:32,887 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
| 23:22:32,933 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
| 23:22:32,933 INFO [SettingsFactory] Query language substitutions: {}
| 23:22:32,933 INFO [SettingsFactory] JPA-QL strict compliance: disabled
| 23:22:32,933 INFO [SettingsFactory] Second-level cache: enabled
| 23:22:32,933 INFO [SettingsFactory] Query cache: disabled
| 23:22:32,933 INFO [SettingsFactory] Cache provider: org.hibernate.cache.NoCacheProvider
| 23:22:32,933 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
| 23:22:32,949 INFO [SettingsFactory] Structured second-level cache entries: disabled
| 23:22:32,996 INFO [SettingsFactory] Echoing all SQL to stdout
| 23:22:33,012 INFO [SettingsFactory] Statistics: disabled
| 23:22:33,012 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
| 23:22:33,012 INFO [SettingsFactory] Default entity-mode: pojo
| 23:22:33,012 INFO [SettingsFactory] Named query checking : enabled
| 23:22:33,246 INFO [SessionFactoryImpl] building session factory
| 23:22:34,699 INFO [SessionFactoryObjectFactory] Factory name: hibernate/HibernateFactory
| 23:22:34,699 INFO [NamingHelper] JNDI InitialContext properties:{}
| 23:22:34,715 INFO [NamingHelper] Creating subcontext: hibernate
| 23:22:34,730 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: hibernate/HibernateFactory
| 23:22:34,730 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
| 23:22:34,793 INFO [SchemaExport] Running hbm2ddl schema export
| 23:22:34,840 INFO [SchemaExport] exporting generated schema to database
| 23:22:35,215 INFO [SchemaExport] schema export complete
| 23:22:35,230 INFO [NamingHelper] JNDI InitialContext properties:{}
| 23:22:51,512 INFO [NamingHelper] JNDI InitialContext properties:{}
| 23:22:52,480 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
| 23:22:52,480 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
| 23:22:53,621 INFO [NamingHelper] JNDI InitialContext properties:{}
| 23:23:10,652 INFO [STDOUT] Hibernate: select hibernate_sequence.nextval from dual
| 23:23:12,496 INFO [STDOUT] Hibernate: insert into tbl_flight (name, id) values (?, ?)
| Listening for transport dt_socket at address: 8787
|
Do you think this is a bug? Or am i missing something? Any idea will be appreciated.. Thanks in advance.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4234371#4234371
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4234371
15 years, 9 months
[Installation, Configuration & DEPLOYMENT] - JBoss 4.2.3 EAR and Apache 2.2 virtual hosts with jk_mod ser
by jbosshog98
I have an EAR file I am trying to deploy alongside various WAR deployments on JBoss 4.2.3
The individual standalone WAR deployments are all working fine and are just a copy of the same application that is contained inside the EAR but the EAR deployment and it's included WAR(s) does not work correctly.
I am receiving a blank white page in the browser when I visit the virtual host that the jboss-web.xml is configured to associate with this EAR. The other virtual hosts associated with the standalone WAR deployments all work fine and are configured the same way.
I get no errors on startup and JBoss reports that the site was started. I have a jboss-web.xml file in the WAR's WEB-INF that ties it into a definition from server.xml. This works on every other type of configuration except the EAR. I keep getting just a white page, as if JBoss can't connect the WAR in the EAR to the host or maybe the WAR isn't starting right or I have some config wrong here.
When I fire up JBoss it creates the flex and railo directories in webwar1.war/WEB-INF as well as a railo-server directory as railo.ear/lib/railo-server but still just serves me a blank white page.
Here is where I stand...
I have a set of shared Railo JAR files are located in /JBoss/server/default/deploy/jboss-web.deployer/railojars/lib (I have told jboss-service.xml to include this as a classpath)
My site1.WAR and site2.WAR files are in the deploy folder and each contain an index.cfm and a WEB-INF with web.xml and jboss-web.xml mapped to a virtual host. They each use this shared Railo JAR instance and run perfectly. The sites I've configured in server.xml with a docPath and appPath to an outside folder use this shared JAR installation and run perfectly. Everything is good with this.
If I place a railo1.war, railo2.war, etc in the /JBoss/server/default/deploy folder (the full WAR with Railo lib folder) those sites use the Railo instance contained within the WAR. This is also great.
So, my only problem left is this:
under /JBoss/server/default/deploy I have created railo.ear
Inside railo.ear is: META-INF which contains application.xml with:
<?xml version="1.0" encoding="UTF-8"?>
| <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN" "http://java.sun.com/j2ee/dtds/application_1_2.dtd">
| <application id="RailoInstance1">
| <display-name>Railo3</display-name>
| <description>Railo3</description>
| <module id="Module1">
| <web>
| <web-uri>webwar1.war</web-uri>
| <context-root>/webwar1</context-root>
| </web>
| </module>
| </application>
It also contains webwar1.war which contains: index.cfm and WEB-INF
WEB-INF has has web.xml, lib and jboss-web.xml
jboss-web.xml looks like this:
<jboss-web>
| <context-root>/</context-root>
| <virtual-host>foo3.com</virtual-host>
| </jboss-web>
>From server.xml:
<Host name="foo3.com">
| <Alias>www.foo3.com</Alias>
| </Host>
foo3.com is using jk_mod to send to JBoss via a virtual host from Apache. The other two sites (foo1.com, foo2.com) which are mapped to WAR deployments are configured the exact same way and work fine.
The WEB-INF includes the lib folder so I would expect this webwar1.WAR instance to use the Railo JAR files contained in that lib folder. The problem is that when I start JBoss, all of my other sites configured their various ways work, but the site in webwar1.war is not coming up. I simply see a white page in the browser.
So, either the jboss-web.xml in WEB-INF in the webwar1.war file is not being connected to the defined in server.xml or something else is going wrong here. My other standalone WAR installations and the shared JARs sites all see their respective descriptors as marked in their jboss-web.xml and have the same content as this deployment.
So, I'm just trying to figure out what I need to do to get this last EAR configuration to work.
The way I am trying now seems like each WAR would try to use the JAR files it contains, but I want to have one set of shared JAR files for the whole EAR and then each WAR file in the ear use those JARS.
I want to be able to have webwar1.war, webwar2.war, etc under this one EAR configuration so I have moved the lib folder out of webwar1.war/WEB-INF/lib and into railo.ear/lib
I would love to set it up this way, but I can't even get one WAR with its own JAR files to load up right when inside the EAR. I have tried this new configuration and get the same blank white page in the browser.
Any ideas?
JBoss gives me no errors. Another odd thing is that I don't get an error from Apache like I do when I try to visit a site that is improperly configured and did not start up. And if I visit a site that is not set up as a host in JBoss and I am redirected via jk_mod to JBoss, I see the JBoss default page. I am not seeing this default page when I visit the virtual host associated with this webwar1.war in the railo.ear, so JBoss must know that it's supposed to do something with the domain / virtual host or else it would show me that default JBoss page. Instead I see a blank white one.
I should also mention that this works on JBoss 5.1. The railo.ear configured the exact same way latches onto the virtual host and works properly.
Help? Thanks!!!!
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4234363#4234363
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4234363
15 years, 9 months