[Persistence, JBoss/CMP, Hibernate, Database] - Closing a result set you left open!, MySQL
by MarcusDidiusFalco
Hi, I am just beginning to experiment with JPA.
I have jboss-4.2.1.GA and MySQL 5.0.45 community installed and I am using mysql-connector-java-5.0.6 as JDBC driver.
With
@Stateless
| public class TestBean implements TestRemote {
|
| @PersistenceContext(unitName="ejbbuch")
| EntityManager entityManager;
|
|
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| public Product addProduct(Product product) {
| entityManager.persist(product);
| return product;
| }
|
| .....
| ---------------------------------------------------------------------------------
| @Entity
| public class Product implements Serializable {
|
| @Id
| @GeneratedValue(strategy=GenerationType.IDENTITY)
| private long id;
| ........
|
| -------------------------------------------------------------------------------
| <?xml version="1.0" encoding="UTF-8"?>
| <persistence>
| <persistence-unit name="ejbbuch">
| <jta-data-source>java:/MySqlDS</jta-data-source>
| </persistence-unit>
| </persistence>
|
| ---------------------------------------------------------------------------------
| <datasources>
| <local-tx-datasource>
| <jndi-name>MySqlDS</jndi-name>
| <connection-url>jdbc:mysql://localhost:3306/jbossdb</connection-url>
| <driver-class>com.mysql.jdbc.Driver</driver-class>
| <user-name>root</user-name>
| <password>ritak1</password>
| <min-pool-size>6</min-pool-size>
| <max-pool-size>20</max-pool-size>
| <blocking-timeout-millis>5000</blocking-timeout-millis>
| <idle-timeout-minutes>0</idle-timeout-minutes>
| <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
| <!-- should only be used on drivers after 3.22.1 with "ping" support
| -->
| <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
| <new-connection-sql>SELECT count(*) FROM product</new-connection-sql>
| <check-valid-connection-sql>SELECT count(*) FROM product</check-valid-connection-sql>
| <share-prepared-statements>true</share-prepared-statements>
| <prepared-statement-cache-size>10</prepared-statement-cache-size>
| <track-statements>true</track-statements>
| <metadata>
| <type-mapping>mySQL</type-mapping>
| </metadata>
| </local-tx-datasource>
| </datasources>
|
|
|
I get the following exceptions in the log file:
| 2007-09-28 13:41:04,265 WARN [org.jboss.resource.adapter.jdbc.WrappedConnection] Closing a result set you left open! Please close it yourself.
| java.lang.Throwable: STACKTRACE
| at org.jboss.resource.adapter.jdbc.WrappedStatement.registerResultSet(WrappedStatement.java:617)
| at org.jboss.resource.adapter.jdbc.WrappedStatement.getGeneratedKeys(WrappedStatement.java:533)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
When I switch back to the DefaultDS (HSQL) this disappears.
Otherwise the code works as expected with the MySQL database. But of course in a production environment you would not want to force JBoss to handle unclosed statements or resultsets.
Is this some problem with the JDBC driver or do I have some bug in my code?
Thanks,
Hans
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4089683#4089683
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4089683
18 years, 6 months
[JBoss Seam] - Re: #{conversationList} appears to be empty
by djfjboss
Interesting is one word for this; I can think of others!
Thanks for your suggestions: using the @In(value= generates an exception: javax.ejb.EJBTransactionRolledbackException: could not set field value: personAction.org.jboss.seam.core.conversationList; using #{org.jboss.seam.core.conversationList} makes no difference.
#{!empty(conversationList)} when called within a JSF page appears to be false (ie the list is empty) but code in my action handler indicates the opposite and the debug page shows a new conversation each time I open up a new instance of the application in a new tab.
This behaviour does not make a lot of sense to me - Seam seems to either work really nicely or leave you scratching your head. I'm clutching at straws now. Is there any arcane configuration I need to do or annotations I need to add other than @Begin, @End? I'm running Seam 2.0.0CR1 on JBoss 4.2.0.GA.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4089680#4089680
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4089680
18 years, 6 months
[EJB/JBoss] - transaction problem
by Sukar1205
I am testing a session bean class.
and when I run my client .. I keep getting this exception
| xception in thread "main" javax.ejb.EJBTransactionRolledbackException: EntityManager must be access within a transaction
| at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
| at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
| at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor
| .java:62)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.jav
| a:77)
| at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationIntercepto
| r.java:106)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:1
| 06)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
| at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
| at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandl
| er.java:82)
| at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:734)
| at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:560)
|
| at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:369)
| at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)
| Caused by: javax.persistence.TransactionRequiredException: EntityManager must be access within a tra
| nsaction
| at org.jboss.ejb3.entity.ManagedEntityManagerFactory.verifyInTx(ManagedEntityManagerFactory.
| java:150)
|
|
this is my client class... all I want to do is add an object in the table
| public class KBClient {
|
| public static void main(String[] args) {
|
| KBClient c = new KBClient();
| ClassificationRemote r = c.lookupNewClassificationBean();
| KnowledgeBase first = new KnowledgeBase();
| first.setKnowledgeID(200);
| first.setKnowledgeName("AmerDemo");
| first.setKnowledgeCategory("Classification");
| first.setProjectID(new Project(88));
| first.setDeleted(0);
| r.addKnowledgeBase(first); //Exception occurs
| }
|
| private ClassificationRemote lookupNewClassificationBean() {
| try {
| Hashtable props = new Hashtable();
| props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
| props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
| props.put("java.naming.provider.url", "localhost");
| Context c = new InitialContext(props);
| return (ClassificationRemote) c.lookup("ClassificationBeanFinal/remote");
| }
| catch(NamingException ne) {
| Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught" ,ne);
| throw new RuntimeException(ne);
| }
| }
| }
|
This is the function in the session bean
| @PersistenceContext private EntityManager em;
|
| public void addKnowledgeBase(KnowledgeBase kb){
| System.out.println("YAAAHOOOOOOO");
| em.persist(kb);
| }
|
a little bit of help would be appreicated.
Thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4089677#4089677
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4089677
18 years, 6 months