-
1. Re: help pls with bmp and mysql is there a bmp example?
steinarc Feb 17, 2003 3:27 AM (in response to btarbox)First you must set up a DataSource in order for you to connect to the database. Secondly may I recommned Monson-Haefels book which contains excellent working examples.
-
2. Re: help pls with bmp and mysql is there a bmp example?
kg1959 Mar 20, 2003 7:56 AM (in response to btarbox)steinarc,
sorry to say that your anwer is not helpful and annoying.
Could you please be more specific. Which book from Monson-Haefel, give a hint to the chapter, please !!
Did you manage to use mySQL with a BMP-EJB ?
Can you please post the ???.xml-files.
I am a newbie with JBoss in the same situation as Brian.
I made the AccountEJB-example from SUN work with the JBoss-Default-Database.
Now I want to use a 'real' Database.
I defined a symbolic database name 'jdbc/AccountDB' in the 'ejb-jar.xml' file packed with the EJB-classes in a jar-file and deployed to JBoss.
This works fine with the JBoss-Default-Database.
Now I found the 'mysql-service.xml' file; changed the database-name and copied it to the JBoss-default-deploy directory.
What I am missing is, how I can tell JBoss that all manipulation of 'jdbc/AccountDB' should be done to the mySQL-database and no longer to the JBoss-Default-Database.
Any help (pointer to previous postings, sample files, etc.) is appreciated.
My OS: RedHat-Linux 7.1
My JBoss: jboss-3.0.6-tomcat-4.1.18
Kurt
Vienna, Austria -
3. Re: help pls with bmp and mysql is there a bmp example?
rscully Apr 2, 2003 8:58 PM (in response to btarbox)Hi guys. I'm in the same position as you both. I am a newbee and am trying to run the transaction example with a MySQL database instead of the default Hypersonic SQL.
I have copied the mysql-service.xml file and made changes to the login-config.xml as you did. The only other thing I changed was in the ant.properties or build.properties file to make the type.mapping=MySQL
I not sure this is correct because when I clean and recompile and restart the server I get the following error deploying the EJBs:
2003-04-03 11:08:35,046 WARN [org.jboss.system.ServiceController] Problem starting service jboss.j2ee:jndiName=ejb/bank/Account,service=EJB
org.jboss.deployment.DeploymentException: Error in jbosscmp-jdbc.xml : datasource-mapping MySQL not found
I must be doing something wrong but I can't see what.
Bec. -
4. Re: help pls with bmp and mysql is there a bmp example?
juhalindfors Apr 4, 2003 6:15 AM (in response to btarbox)> Could you please be more specific. Which book from
> Monson-Haefel, give a hint to the chapter, please !!
He may be referring to RMH's "EJB 3rd Edition" that has an accompanying workbook specifically made for JBoss for all the examples. This was written by Bill Burke and Sacha Labourey, and there's a separate forum to discuss just this workbook. I don't know if it answers your specific question but you could go there and ask:
http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t= Now I want to use a 'real' Database.
I have no experience with mySQL but if you consider PostgreSQL a 'real' database (I prefer it over mySQL) I can send you instructions how to set up the datasource if you can't get it up (although it works pretty much out of the box with the example datasource configuration that is distributed with JBoss).
> What I am missing is, how I can tell JBoss that all
> manipulation of 'jdbc/AccountDB' should be done to
> the mySQL-database and no longer to the
> JBoss-Default-Database.
Include jbosscmp-jdbc.xml with your entity beans and declare the datasource lookup name there. The DTD for jbosscmp-jdbc.xml shows where and how to add this. -
5. Re: help pls with bmp and mysql is there a bmp example?
juhalindfors Apr 4, 2003 6:17 AM (in response to btarbox)jboss.j2ee:jndiName=ejb/bank/Account,service=EJB
> org.jboss.deployment.DeploymentException: Error in
> jbosscmp-jdbc.xml : datasource-mapping MySQL not
> found
>
> I must be doing something wrong but I can't see
> what.
Post your xml files. This looks like a simple mismatch between the jndi names in configuration files. -
6. Re: help pls with bmp and mysql is there a bmp example?
pup99 Apr 4, 2003 4:13 PM (in response to btarbox)Ok, it took me a while but I finally got MySQL to work with JBoss, I had some problems, but with a little help from people here, and some people around my work, things got to a working state. Here is what I did to get it to work
1. First I edited the mysql-service.xml and moved it to the deploy folder
2. I edited the login-config.xml (note the pwd is empty on mine, I will get back to that)
3. I edited the Transaction from the example to get it tow work namly changing the build.properties so that the type.mapping and the datasource.name are correct of the values I entered
After all this, I removed all the built files in my transaction to make sure that XDoclet remaid all of the files with the new settings from the build.xml. At this point I tried it and got a error saying it couldn't log in. So I added a user in MySQL called root@127.0.0.1 (with no password). I rebooted again and it worked. The reason for this is that in MySQL root@127.0.0.1 is not the same as root@localhost.
That is what I did to get it to work, I am attaching all three of the files that I talked about above I hope they help you out. -
7. Re: help pls with bmp and mysql is there a bmp example?
kevcpu Apr 4, 2003 7:15 PM (in response to btarbox)I really need help...... I have jboss 3.0.6 installed on a freebsd 4.6 server and I am having major issues testing my bean. I am using the mysql 3.23. database. Basically, when I try to run my bean from the test driver I created I got the following exception in the server.log file:
[org.jboss.ejb.plugins.BMPPersistenceManager] Runt
imeException:
java.lang.ArrayIndexOutOfBoundsException: 9
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:1
845)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:1
867)
at com.mysql.jdbc.PreparedStatement.setBoolean(PreparedStatement.java:34
3)
at org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement.setBoole
an(LocalPreparedStatement.java:66)
at com.ldn.ejb.entity.userentejb.UserEntEJBBean.ejbStore(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.ejb.plugins.BMPPersistenceManager.storeEntity(BMPPersistenc
eManager.java:472)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.stor
eEntity(CachedConnectionInterceptor.java:388)
at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:708)
at org.jboss.ejb.GlobalTxEntityMap.syncEntities(GlobalTxEntityMap.java:1
17)
at org.jboss.ejb.GlobalTxEntityMap$GlobalTxEntityMapCleanup.beforeComple
tion(GlobalTxEntityMap.java:185)
at org.jboss.tm.TxCapsule.doBeforeCompletion(TxCapsule.java:1394)
at org.jboss.tm.TxCapsule.commit(TxCapsule.java:364)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:73)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxIntercep
torCMT.java:251)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.ja
va:62)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIntercep
tor.java:105)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:1
29)
at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
at org.jboss.ejb.Container.invoke(Container.java:730)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:
382)
at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:701)
at java.lang.Thread.run(Thread.java:536)
2003-04-03 22:26:59,928 ERROR [org.jboss.ejb.GlobalTxEntityMap] Store failed on
entity: 20
javax.ejb.EJBException: null; CausedByException is:
9
at org.jboss.ejb.plugins.BMPPersistenceManager.storeEntity(BMPPersistenc
eManager.java:494)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.stor
eEntity(CachedConnectionInterceptor.java:388)
at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:708)
at org.jboss.ejb.GlobalTxEntityMap.syncEntities(GlobalTxEntityMap.java:1
17)
at org.jboss.ejb.GlobalTxEntityMap$GlobalTxEntityMapCleanup.beforeComple
tion(GlobalTxEntityMap.java:185)
at org.jboss.tm.TxCapsule.doBeforeCompletion(TxCapsule.java:1394)
at org.jboss.tm.TxCapsule.commit(TxCapsule.java:364)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:73)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxIntercep
torCMT.java:251)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.ja
va:62)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIntercep
tor.java:105)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:1
29)
at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
at org.jboss.ejb.Container.invoke(Container.java:730)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:
382)
at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:536)
java.lang.ArrayIndexOutOfBoundsException: 9
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:1
845)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:1
867)
at com.mysql.jdbc.PreparedStatement.setBoolean(PreparedStatement.java:34
3)
at org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement.setBoole
an(LocalPreparedStatement.java:66)
at com.ldn.ejb.entity.userentejb.UserEntEJBBean.ejbStore(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.ejb.plugins.BMPPersistenceManager.storeEntity(BMPPersistenc
eManager.java:472)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.stor
eEntity(CachedConnectionInterceptor.java:388)
at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:708)
at org.jboss.ejb.GlobalTxEntityMap.syncEntities(GlobalTxEntityMap.java:1
17)
at org.jboss.ejb.GlobalTxEntityMap$GlobalTxEntityMapCleanup.beforeComple
tion(GlobalTxEntityMap.java:185)
at org.jboss.tm.TxCapsule.doBeforeCompletion(TxCapsule.java:1394)
at org.jboss.tm.TxCapsule.commit(TxCapsule.java:364)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:73)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxIntercep
torCMT.java:251)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.ja
va:62)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIntercep
tor.java:105)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:1
29)
at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
at org.jboss.ejb.Container.invoke(Container.java:730)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:
382)
at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesva:62)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIntercep
tor.java:105)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:1
29)
at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
at org.jboss.ejb.Container.invoke(Container.java:730)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:
382)
at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:536)
and i get the following on the screen:
Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
at $Proxy0.create(Unknown Source)
at Driver.main(Driver.java:20)
Caused by: javax.transaction.RollbackException: Unable to commit, tx=XidImpl [Fo
rmatId=257, GlobalId=lodown.kemetek.com//9, BranchQual=] status=STATUS_ROLLEDBAC
K
at org.jboss.tm.TxCapsule.commit(TxCapsule.java:425)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:73)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxIntercep
torCMT.java:251)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.ja
va:62)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIntercep
tor.java:105)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:1
29)
at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
at org.jboss.ejb.Container.invoke(Container.java:730)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:
382)
at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:701)
at java.lang.Thread.run(Thread.java:536)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
RemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Sour
ce)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvo
kerProxy.java:138)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.jav
a:108)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.
java:77)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:8
0)
at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:198)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
Here is the database part of my bean class:
String query = "insert into users (username, password, first_name" + ", middle_name, last_name, city, state, zip, email, is_client") values (?,?,?,?,?,?,?,?,?,?)";
try
{
Context dsctx = new InitialContext();
ds = (DataSource)dsctx.lookup(dsn);
con = ds.getConnection();
ps = con.prepareStatement(query,Statement.RETURN_GENERATED_KEYS);
ps.setString(1, username);
ps.setString(2, password);
ps.setString(3, fname);
ps.setString(4, lname);
ps.setString(5, mname);
ps.setString(6, city);
ps.setString(7, state);
ps.setString(8, zip);
ps.setString(9, email);
ps.setBoolean(10, isclient.booleanValue());
if (ps.executeUpdate() != 1)
{
throw new CreateException("Failed to insert user into database");
}
rs = ps.getGeneratedKeys();
if (rs.next())
{
id = new Integer(rs.getInt(1));
}
return id;
Here is my ejb.jar.xml:
<!DOCTYPE ejb-jar PUBLIC
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
This bean represents a user
<ejb-name>UserEnt</ejb-name>
com.ldn.ejb.entity.userentejb.UserEntEJBHome
com.ldn.ejb.entity.userentejb.UserEntEJBRemote
<ejb-class>com.ldn.ejb.entity.userentejb.UserEntEJBBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
False
<resource-ref>
DataSource for the LoDown database
<res-ref-name>jdbc/LoDownDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</enterprise-beans>
<assembly-descriptor>
<security-role>
This role represents everyone who is allowed full access to the Ship EJ
B.
<role-name>everyone</role-name>
</security-role>
<method-permission>
<role-name>everyone</role-name>
<ejb-name>UserEnt</ejb-name>
<method-name>*</method-name>
</method-permission>
<container-transaction>
<ejb-name>UserEnt</ejb-name>
<method-name>*</method-name>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
Here is my jboss.xml:
<?xml version="1.0"?>
false
<container-configurations/>
<resource-managers>
<resource-manager>
<res-name>jdbc/LoDownDS</res-name>
<res-jndi-name>java:/LoDownDS</res-jndi-name>
</resource-manager>
</resource-managers>
<enterprise-beans>
<ejb-name>UserEnt</ejb-name>
<jndi-name>user/UserEnt</jndi-name>
</enterprise-beans>
if anyone has a clue please respond. -
8. Re: help pls with bmp and mysql is there a bmp example?
mahonys Apr 6, 2003 4:28 AM (in response to btarbox)...hi, these files certainly look help ful.
Having followed your examples and moved the necessary files into the deploy directory, I then start up the default JBoss server, but get this error on attempting to "add service" in the 'mysql-service.xml' file..
End deployment start on package: mysql-service.xml
2003-04-06 10:17:20,181 INFO [org.jboss.deployment.MainDeployer] Deployed package: file:/C:/tools/jboss-3.2.0RC2_tomcat.4.1.18/server/default/deploy/mysql-service.xml
2003-04-06 10:17:20,191 ERROR [org.jboss.deployment.scanner.URLDeploymentScanner] MBeanException: Exception in MBean operation 'checkIncompleteDeployments()'
Cause: Incomplete Deployment listing:
Packages waiting for a deployer:
Incompletely deployed packages:
MBeans waiting for classes:
MBeans waiting for other MBeans:
[ObjectName: jboss.jca:service=LocalTxCM,name=MySqlDS
state: CONFIGURED
I Depend On: jboss.jca:service=LocalTxDS,name=MySqlDS
jboss.jca:service=LocalTxPool,name=MySqlDS
jboss.jca:service=CachedConnectionManager
jboss.security:service=JaasSecurityManager
jboss.jca:service=RARDeployer
Depends On Me: , ObjectName: jboss.jca:service=LocalTxDS,name=MySqlDS
state: FAILED
I Depend On:
Depends On Me: jboss.jca:service=LocalTxCM,name=MySqlDS
org.jboss.deployment.DeploymentException: No Attribute found with name: JndiName].
any suggestions would be *greately* appreciated,
thanks
Steve M