[Beginners Corner] - Re: multiple datasource
by weston.priceï¼ jboss.com
If you simply want to use MySQL (or any other RDMBS) provider you simply need to create the datasource for that provider. Replacing the DefaultDS datasource would be necessary if you wanted to replace the persistence mechanism used interally by JBoss for JMS and other services.
So, to create a datasource the steps are usually straightforward:
1) Look in your <jboss-home/docs/examples/jca directory and see if there is a sample *-ds.xml for your database. If so, simply copy this file, replace the values with your specific values and place the file in the <jboss-home>/server/<server-config>/deploy directory. Note, any number of datasources can be specified in the *-ds.xml file so it is not limited to one file->onedatasource
2) If there is not an example, simply copy one of the example files and replace the values with those from your JDBC driver documentation.
More on JDBC configuration can be found on the JCA part of our Wiki:
http://wiki.jboss.org/wiki/Wiki.jsp?page=ConfigDataSources
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016526#4016526
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016526
19Â years, 2Â months
[JBoss Seam] - Re: f:param in h:commandLink in h:column
by lightbulb432
I can't get the request parameter to work from pages.xml. My dataTable is as follows. What should be in my myBean.myAction method - anything? Right now it's empty, like it was when I was using DataModel/DataModelSelection...
<h:dataTable id="table" value="#{myList}" var="a">
| <h:column>
| <s:link value="#{a.text}" action="#{myBean.myAction}" >
| <f:param name="theId" value="#{a.id}" />
| </s:link>
| </h:column>
| </h:dataTable>
My pages.xml looks like the following. Should the param element be in the navigation element of the initiating page, the page element of the resulting page, or either? What's the difference? (Right now I've got it commented out in the latter.) The resultPage.xhtml displays information relating to contextualBean...
<page view-id="/listpage.xhtml">
| <navigation from-action="#{myBean.myAction}">
| <begin-conversation />
| <redirect view-id="/resultPage.xhtml">
| <param name="theId" value="#{contextualBean.id}" />
| </redirect>
| </navigation>
| </page>
|
| <page view-id="/resultPage.xhtml">
| <!--
| <param name="theId" value="#{contextualBean.id}" />
| -->
| </page>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016524#4016524
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016524
19Â years, 2Â months
[Beginners Corner] - multiple datasource
by sandrocchio_0.1
Hi there,
I'm new with Jboss and I'm trying to understand how to configure multiple datasource based on different databases. I've already gone trough the jboss.com docs, but onestly it didn't help me much.
I'm now working with JBoss 4.0.5 and MySQL 5 (but I'd like implement Oracle too).
Following http://wiki.jboss.org/wiki/Wiki.jsp?page=SetUpAMysqlDatasource I've been able to run my entity bean, however I had to replace the DefaultDS hsqldb with MySQL and this is not exactly what I wanted to achieve.
So, I'm probably missing something. Would you have a look on what I did and tell me if I need further configurations?
* add the mysql driver
* replaced the hsqldb-ds.xml with the new edited mysql-ds.xml
<datasources>
| <local-tx-datasource>
| <jndi-name>DefaultDS</jndi-name>
| <connection-url>jdbc:mysql://127.0.0.2:3306/tmp</connection-url>
| <driver-class>org.gjt.mm.mysql.Driver</driver-class>
| <user-name>user</user-name>
| <password>temp</password>
| <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
| <metadata>
| <type-mapping>mySQL</type-mapping>
| </metadata>
| </local-tx-datasource>
| </datasources>
* replaced the ../jms/hsqldb-jdbc2-service.xml with ../jms/mysql-jdbc2-service.xml
<server>
| <mbean code="org.jboss.mq.server.jmx.DestinationManager" name="jboss.mq:service=DestinationManager">
| <depends optional-attribute-name="MessageCache">jboss.mq:service=MessageCache</depends>
| <depends optional-attribute-name="PersistenceManager">jboss.mq:service=PersistenceManager</depends>
| <depends optional-attribute-name="StateManager">jboss.mq:service=StateManager</depends>
| </mbean>
| <mbean code="org.jboss.mq.server.MessageCache"
| name="jboss.mq:service=MessageCache">
| <attribute name="HighMemoryMark">50</attribute>
| <attribute name="MaxMemoryMark">60</attribute>
| <attribute name="CacheStore">jboss.mq:service=PersistenceManager</attribute>
| </mbean>
| <mbean code="org.jboss.mq.pm.jdbc2.PersistenceManager"
| name="jboss.mq:service=PersistenceManager">
| <depends optional-attribute-name="ConnectionManager">jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>
| <attribute name="SqlProperties">
| ...
| ...
* modified the ejb-jar.xml in my module
<resource-ref>
| <description>jdbc:mysql://127.0.0.2:3306/tmp</description>
| <res-ref-name>jdbc/DefaultDS</res-ref-name>
| <res-type>javax.sql.DataSource</res-type>
| <res-auth>Container</res-auth>
| <res-sharing-scope>Shareable</res-sharing-scope>
| </resource-ref>
* edit the entity bean method
private javax.sql.DataSource getSavingsAccountDB() throws javax.naming.NamingException {
| javax.naming.Context c = new javax.naming.InitialContext();
| return (javax.sql.DataSource) c.lookup("java:comp/env/jdbc/DefaultDS");
| }
|
So, as I sayd the entity bean correctly works, but on JBoss startup I now get an error
anonymous wrote : 19:12:20,488 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
|
| --- MBeans waiting for other MBeans ---
| ObjectName: jboss.mq:service=InvocationLayer,type=HTTP
| State: CONFIGURED
| I Depend On:
| jboss.mq:service=Invoker
| jboss.web:service=WebServer
|
| ObjectName: jboss.mq.destination:service=Topic,name=testTopic
| State: CONFIGURED
| I Depend On:
| jboss.mq:service=DestinationManager
| jboss.mq:service=SecurityManager
|
| ObjectName: jboss.mq.destination:service=Topic,name=securedTopic
| State: CONFIGURED
| I Depend On:
| jboss.mq:service=DestinationManager
| jboss.mq:service=SecurityManager
|
| ObjectName: jboss.mq.destination:service=Topic,name=testDurableTopic
| State: CONFIGURED
| I Depend On:
| jboss.mq:service=DestinationManager
| jboss.mq:service=SecurityManager
|
| ObjectName: jboss.mq.destination:service=Queue,name=testQueue
| State: CONFIGURED
| I Depend On:
| jboss.mq:service=DestinationManager
| jboss.mq:service=SecurityManager
|
| ObjectName: jboss.mq.destination:service=Queue,name=A
| State: CONFIGURED
| I Depend On:
| jboss.mq:service=DestinationManager
|
| ObjectName: jboss.mq.destination:service=Queue,name=B
| State: CONFIGURED
| I Depend On:
| jboss.mq:service=DestinationManager
|
| ObjectName: jboss.mq.destination:service=Queue,name=C
| State: CONFIGURED
| I Depend On:
| jboss.mq:service=DestinationManager
|
| ObjectName: jboss.mq.destination:service=Queue,name=D
| State: CONFIGURED
| I Depend On:
| jboss.mq:service=DestinationManager
|
| ObjectName: jboss.mq.destination:service=Queue,name=ex
| State: CONFIGURED
| I Depend On:
| jboss.mq:service=DestinationManager
|
| ObjectName: jboss.mq:service=Invoker
| State: CONFIGURED
| I Depend On:
| jboss.mq:service=TracingInterceptor
| jboss:service=Naming
| Depends On Me:
| jboss.mq:service=InvocationLayer,type=HTTP
| jboss.mq:service=InvocationLayer,type=JVM
| jboss.mq:service=InvocationLayer,type=UIL2
|
| ObjectName: jboss.mq:service=TracingInterceptor
| State: CONFIGURED
| I Depend On:
| jboss.mq:service=SecurityManager
| Depends On Me:
| jboss.mq:service=Invoker
|
| ObjectName: jboss.mq:service=SecurityManager
| State: CONFIGURED
| I Depend On:
| jboss.mq:service=DestinationManager
| Depends On Me:
| jboss.mq.destination:service=Topic,name=testTopic
| jboss.mq.destination:service=Topic,name=securedTopic
| jboss.mq.destination:service=Topic,name=testDurableTopic
| jboss.mq.destination:service=Queue,name=testQueue
| jboss.mq:service=TracingInterceptor
| jboss.mq.destination:service=Queue,name=DLQ
|
| ObjectName: jboss.mq.destination:service=Queue,name=DLQ
| State: CONFIGURED
| I Depend On:
| jboss.mq:service=DestinationManager
| jboss.mq:service=SecurityManager
|
| ObjectName: jboss.mq:service=InvocationLayer,type=JVM
| State: CONFIGURED
| I Depend On:
| jboss.mq:service=Invoker
|
| ObjectName: jboss.mq:service=InvocationLayer,type=UIL2
| State: CONFIGURED
| I Depend On:
| jboss.mq:service=Invoker
|
| --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
| ObjectName: jboss.mq:service=DestinationManager
| State: NOTYETINSTALLED
| Depends On Me:
| jboss.mq.destination:service=Topic,name=testTopic
| jboss.mq.destination:service=Topic,name=securedTopic
| jboss.mq.destination:service=Topic,name=testDurableTopic
| jboss.mq.destination:service=Queue,name=testQueue
| jboss.mq.destination:service=Queue,name=A
| jboss.mq.destination:service=Queue,name=B
| jboss.mq.destination:service=Queue,name=C
| jboss.mq.destination:service=Queue,name=D
| jboss.mq.destination:service=Queue,name=ex
| jboss.mq:service=SecurityManager
| jboss.mq.destination:service=Queue,name=DLQ
I was not able to find the reason, but it started after I replaced the DefaultDS with MySQL.
Back to my configuration, how can I set up multiple datasource?
Thank you in advance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016520#4016520
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016520
19Â years, 2Â months
[JCA/JBoss] - Re: autocommit question
by weston.priceï¼ jboss.com
This is correct.
The <local-tx-datasource> will automatically set the auto commit value of the connection to false depending upon the context of the global transaction. Typically, there is no reason for you to use this datasource *and* set the auto commit value yourself. If you want to use this datasource outside of the context of a global transaction you can simply aquire the connection and set the value yourself. Note, this is not really the way this data source is intended for use. As a result, you have a few options:
1) Use the <no-tx-datasource>. Use of this datasource will put the responsiblity of the transaction on you. After acquiring the DataSource you will want to do the setAutoCommit(false), do your JDBC work, and then commit. This type of datasource funtions much like a non-managed datasource running outside of the application server though you still get pooling, can leverage security etc. With you particular config, you can do this simply by renaming the
| <local-tx-datasource>
|
| to
|
| <no-tx-datasource>
|
|
|
and remove the auto commit property.
2) Start a global transaction in your WebApplication via the UserTransaction object bound into JNDI to scope the work you want your JDBC connection to be enlisted in. See the JTA spec for examples.
3) Use EJB(X) and leverage CMT and declarative transaction management to do all of this for you.
More on datasource configuration can be found here:
http://wiki.jboss.org/wiki/Wiki.jsp?page=ConfigDataSources
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016513#4016513
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016513
19Â years, 2Â months
[JBoss Seam] - Re: h:commandButton and h:commandLink don't delegate convers
by nfeybesse
I think there is still a bug with <h:selectmanycheckbox> within <h:form enctype="multipart/form-data"> despite http://jira.jboss.org/jira/browse/JBSEAM-706
JBoss 4.0.5 / JSF 1.2 / Seam 1.1.6
Here is an example showing the bug and working without enctype="mulipart/form-data"
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <html xmlns="http://www.w3.org/1999/xhtml"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:f="http://java.sun.com/jsf/core">
|
| <head>
| <title>Manycheckbox and multipart error</title>
| </head>
| <body>
| <f:view>
| <div>
| <h:form enctype="multipart/form-data">
| <h:selectManyCheckbox value="#{errorAction.selectedErrors}">
| <f:selectItems value="#{errorItems}" />
| </h:selectManyCheckbox>
| <h:commandButton action="#{errorAction.save}" value="Save"/>
| <h:messages/>
| </h:form>
| </div>
| </f:view>
| </body>
| </html>
|
and POJO :
| package com.genericsystem.error;
|
| import java.io.Serializable;
| import java.util.Arrays;
| import java.util.List;
|
| import javax.faces.model.SelectItem;
|
| import org.jboss.seam.annotations.Factory;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Logger;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Out;
| import org.jboss.seam.core.FacesMessages;
| import org.jboss.seam.log.Log;
|
| @Name("errorAction")
| public class ErrorAction implements Serializable {
| private static final long serialVersionUID = 7654273335405896287L;
|
| @Logger Log log;
|
| @In(required=false) @Out(required=false)
| List<SelectItem> errorItems;
|
| private List<String> selectedErrors;
|
| public List<String> getSelectedErrors() {
| return (List<String>)Arrays.asList(new String[]{"Error1","Error2"});
| }
|
| public void setSelectedErrors(List<String> selectedErrors) {
| this.selectedErrors = selectedErrors;
| }
|
| @Factory("errorItems")
| public void findErrorItems(){
| errorItems = (List<SelectItem>)Arrays.asList(new SelectItem[]{new SelectItem("Error1","Error1"),
| new SelectItem("Error2","Error2"),new SelectItem("Error3","Error3"),new SelectItem("Error4","Error4")});
| }
|
| public String save(){
| FacesMessages.instance().add("save : ");
| for (String error : selectedErrors){
| log.info("************** selectedError : "+error+" ***************");
| FacesMessages.instance().add("selectedError : "+error);
| }
| return "/error.xhtml";
| }
|
| }
|
|
Best regards
Nicolas
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016511#4016511
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016511
19Â years, 2Â months