I've been using jboss for some time now, and think it's a great
EJB-container. Thanks for helping us not having to use weblogic. :-)
Okay, in BETA-PROD01 (BP01), pooling connections to postgresql worked
fine. However, when I download and use BP02 or later versions, I can't
get the pooling to work. It seems that my code breaks in the
lookup("java:comp/env/Postgresql")-statement inside the beans.
Here's what I do:
jboss.conf:
<MLET CODE="org.jboss.jdbc.XADataSourceLoader" ARCHIVE="jboss.jar,pgsql.jar"
CODEBASE="../lib/ext/">
<ARG TYPE="java.lang.String" VALUE="Postgresql">
<ARG TYPE="java.lang.String" VALUE="org.jboss.minerva.xa.XADataSourceImpl">
</MLET>
jboss.jcml:
<mbean name="DefaultDomain:service=XADataSource,name=Postgresql">
<attribute name="TimestampUsed">false</attribute>
<attribute name="Password">root</attribute>
<attribute name="MaxSize">0</attribute>
<attribute name="InvalidateOnError">false</attribute>
<attribute name="IdleTimeout">1800000</attribute>
<attribute name="GCInterval">120000</attribute>
<attribute name="Blocking">true</attribute>
<attribute name="LoggingEnabled">false</attribute>
<attribute name="IdleTimeoutEnabled">false</attribute>
<attribute name="GCEnabled">false</attribute>
<attribute name="URL">jdbc:postgresql:webucation</attribute>
<attribute name="Properties"></attribute>
<attribute name="MinSize">0</attribute>
<attribute name="MaxIdleTimeoutPercent">1.0</attribute>
<attribute name="JDBCUser">root</attribute>
<attribute name="GCMinIdleTime">1200000</attribute>
</mbean>
in jboss.xml for the beans:
<?xml version="1.0"?>
<jboss>
<resource-managers>
<resource-manager res-class="org.jboss.ejb.deployment.JDBCResource">
<res-name>Postgresql</res-name>
<res-jndi-name>Postgresql</res-jndi-name>
</resource-manager>
</resource-managers>
<enterprise-beans>
<entity>
<ejb-name>LogonBean</ejb-name>
<jndi-name>ejb/Logon</jndi-name>
<resource-ref>
<res-ref-name>Postgresql</res-ref-name>
<resource-name>Postgresql</resource-name>
</resource-ref>
</entity>
</enterprise-beans>
</jboss>
in the ejb-jar.xml for the bean:
<entity>
<ejb-name>LogonBean</ejb-name>
<home>lms.system.LogonHome</home>
<remote>lms.system.Logon</remote>
<ejb-class>lms.system.LogonBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>lms.system.LogonPK</prim-key-class>
<reentrant>False</reentrant>
<transaction>Required</transaction>
<resource-ref>
<description>Test Database</description>
<res-ref-name>Postgresql</res-ref-name>
<resource-name>Postgresql</resource-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>
(The <resource-name>-tag was added in desperation this evening. :-)
And here's the code crash.
public class LogonBean .... {
...
protected Connection getConnection() throws SQLException {
try {
Context naming = new InitialContext();
DataSource ds = (DataSource)naming.lookup("java:comp/env/Postgresql");
// DataSource ds = (DataSource)naming.lookup("Postgresql");
return ds.getConnection();
}
catch (NamingException ne) {
System.out.println("Exception in UserBean.getConnection():\n " + ne);
throw new EJBException(ne);
}
}
}
It just dies. No exception, except (heh) for one related to not
getting any data from Postgresql, and thus no LogonPK returned
etc. Here's what I get:
ogonBean] EnterpriseContext.lock() 1235810177 1
[LogonBean] Debug: Username: roar
[LogonBean] Erron in closing resultset: java.lang.NullPointerException
[LogonBean] EnterpriseContext.unlock() 1235810177 0
[LogonBean] TxCapsule.setRollbackOnly(): Entered, status=STATUS_ACTIVE
[LogonBean] TxCapsule.rollback(): Entered, status=STATUS_MARKED_ROLLBACK
[LogonBean] TRANSACTION ROLLBACK EXCEPTION:id may not be null; nested exception is:
java.lang.Error: id may not be null
[LogonBean] java.lang.Error: id may not be null
[LogonBean] at java.lang.Throwable.<init>(Throwable.java:96)
[LogonBean] at java.lang.Error.<init>(Error.java:52)
[LogonBean] at org.jboss.ejb.CacheKey.<init>(CacheKey.java:45)
[LogonBean] at
org.jboss.ejb.plugins.NoPassivationEntityInstanceCache.createCacheKey(NoPassivationEntityInstanceCache.java:90)
[LogonBean] at
org.jboss.ejb.plugins.BMPPersistenceManager.findEntity(BMPPersistenceManager.java:198)
[LogonBean] at org.jboss.ejb.EntityContainer.find(EntityContainer.java:405)
[LogonBean] at java.lang.reflect.Method.invoke(Native Method)
[LogonBean] at
org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:585)
[LogonBean] at
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:171)
[LogonBean] at
org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:85)
[LogonBean] at
org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:135)
[LogonBean] at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:263)
[LogonBean] at
org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:86)
[LogonBean] at
org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:122)
[LogonBean] at
org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:106)
[LogonBean] at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:309)
[LogonBean] at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRMPContainerInvoker.java:207)
[LogonBean] at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRMPContainerInvoker.java:153)
[LogonBean] at java.lang.reflect.Method.invoke(Native Method)
[LogonBean] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:242)
[LogonBean] at sun.rmi.transport.Transport$1.run(Transport.java:155)
[LogonBean] at java.security.AccessController.doPrivileged(Native Method)
[LogonBean] at sun.rmi.transport.Transport.serviceCall(Transport.java:152)
[LogonBean] at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:462)
[LogonBean] at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:662)
[LogonBean] at java.lang.Thread.run(Thread.java:498)
Anybody who has experienced the same? The strange thing is that the
code perfect on PROD-01, but not on PROD-02+.
Regards,
Lars
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]