[JBoss Seam] - Re: Explicit conversation id problem
by raffaele.camanzo
Hi Gavin,
I added the issue and the test case, you can find them here:
http://jira.jboss.com/jira/browse/JBSEAM-976
I'm also trying to create a test case for the forum post:
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=102935
in order to understand if I can better explain what happens in my application, but, please can you have a glance at that, maybe I misunderstood something...
Thank you.
Hi Lle,
the problem is this one: in the documentation (6.6) there's a description of the Seam behaviour when multiple calls are made on the @Begin method of a conversation with a given ID; the behaviour expected is to avoid to call more than once the @Begin method, i.e. the first request which needs the creation of a conversation with a given ID causes the @Begin method call, further requests on that ID should skip the execution of such method; but this seems not to happen (at least to me).
the solution is straightforward: even if the @Begin method is called more than once Seam retrieves the correct conversation with it's status, then:
|
| private boolean passed = false;
|
| @Begin(join=true, id="<whateveryouneed>")
| public String startConversation() {
| if(! passed) {
| passed = true;
| // initialization here
| }
| }
|
Regards,
Raffaele Camanzo
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024643#4024643
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024643
17Â years, 11Â months
[JBossWS] - Re: JbossWS 1.2.0
by matienzar
I've solve it with this code:
public class HibernateWS extends GenericSOAPHandler {
@Override
public boolean handleFault(MessageContext msgContext) {
UserTransaction _tx = null;
try {
if (msgContext.containsKey("hibernateTrx")){
_tx = (UserTransaction)msgContext.get("hibernateTrx");
_tx.rollback();
}
} catch (Exception e) {
Log.error("No se ha podido hacer el rollback", e);
throw new RuntimeException(e);
}
return super.handleFault(msgContext);
}
@Override
protected boolean handleInbound(MessageContext msgContext) {
try {
HibernateUtil.openSession();
UserTransaction _tx = (UserTransaction) new InitialContext()
.lookup("java:comp/UserTransaction");
_tx.begin();
msgContext.put("hibernateTrx", _tx);
} catch (Exception e) {
Log.error("Cogiendo la transacción.", e);
}
return true;
}
@Override
protected boolean handleOutbound(MessageContext msgContext) {
UserTransaction _tx = null;
try {
if (msgContext.containsKey("hibernateTrx")){
_tx = (UserTransaction)msgContext.get("hibernateTrx");
_tx.commit();
}
} catch (Exception e) {
Log.error("Haciendo el commit", e);
try {
if(_tx != null)
_tx.rollback();
} catch (Exception e2) {
Log.error("Haciendo el rollback", e2);
}
throw new RuntimeException(e);
}
return true;
}
}
I use Jboss 4.0.5
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024642#4024642
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024642
17Â years, 11Â months
[Clustering/JBoss] - Re: JNDI vs. HA-JNDI lookups
by bstansberryï¼ jboss.com
Possibilities include:
1) Don't mark the bean as clustered if you don't want it clustered. The only clustering behavior an SLSB has is failover and loadbalancing; if you don't want that then there is no point making the bean clustered.
2) Only deploy the bean on the server you want, or deploy it in deploy-hasingleton so it's only active on one server.
3) Use FirstAvailable or FirstAvailableIdenticalAllProxies as your load balance policy. These will give varying degrees of server affinity, although the server they initially pick is still random, and each client will independently pick.
4) Some custom load balance policy, perhaps along with a custom interceptor that tells the policy which server to target.
The solution depends on what you want; i.e. why load balancing is bad and what server you want the call to go to.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024641#4024641
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024641
17Â years, 11Â months
[EJB 3.0] - there is a very simple entity bean generator for mysql
by johnhollon
| package com.jdi.dbport.utils;
| import java.sql.*;
| import java.io.*;
|
| /**
| * Create Entity Bean (byte code) from existing tables in database.
| * This generator can only generate basic code for programming, so
| * you should optimize the generated code.
| * before you use this tool, be sure that there is a folder called
| * "001_JDI_Generate_EntityBean_TEMP" in the root of C hard driver.
| * @author CHR
| *
| */
|
| public class GenerateEntityBeans {
| private static String packageName = "com.jdi.persistence";
| private static String directory = "C:\\001_JDI_Generate_EntityBean_TEMP\\";
|
| StringBuffer start = new StringBuffer()
| .append("/** Generated Entity Bean - YOU SHOULD OPTIMIZE IT - Copyright (C) ??? */\n");
|
| StringBuffer packagingAndImporting = new StringBuffer()
| .append("package " + packageName + ";" + "\n" +
| "import javax.persistence.*; \n" +
| "import java.util.*; \n" +
| "import java.sql.*; \n" +
| "import java.math.*;\n\n");
|
| private StringBuffer doGenerateClassName(String tablename,String classname){
| String classdeclaring =
| "@Entity \n " +
| "@Table(name=\"" + tablename + "\") \n " +
| "public class " + classname +"{\n";
| StringBuffer mainclasstext = new StringBuffer().append(start).append(packagingAndImporting);
| mainclasstext.append(classdeclaring);
| return mainclasstext;
| }
|
| private StringBuffer doGenerateProperties(String columnname, String datatype, String keytype,
| String nullable, String defaultvalue){
| String useddatatype;
| String compareString = datatype.concat("111111111");
| //Integer,Int,Mediumint,tinyint,smallint as int
| if(compareString.substring(0,7).equalsIgnoreCase("Integer")||compareString.substring(0,3).equalsIgnoreCase("Int")||
| compareString.substring(0,9).equalsIgnoreCase("MEDIUMINT")||compareString.substring(0,8).equalsIgnoreCase("SMALLINT")||
| compareString.substring(0,7).equalsIgnoreCase("TINYINT"))
| useddatatype = "int";
| //bigint as long
| else if(compareString.substring(0,6).equalsIgnoreCase("BIGINT"))
| useddatatype = "long";
| //float,double,decimal,real,numeric as double
| else if(compareString.substring(0,5).equalsIgnoreCase("FLOAT")||compareString.substring(0,6).equalsIgnoreCase("DOUBLE")||
| compareString.substring(0,7).equalsIgnoreCase("DECIMAL")||compareString.substring(0,4).equalsIgnoreCase("REAL")||
| compareString.substring(0,7).equalsIgnoreCase("NUMERIC"))
| useddatatype = "double";
| //char, varchar, date, datetime, timestamp as String
| else if(compareString.substring(0,4).equalsIgnoreCase("CHAR")||compareString.substring(0,7).equalsIgnoreCase("VARCHAR")||
| compareString.substring(0,4).equalsIgnoreCase("DATE") ||compareString.substring(0,8).equalsIgnoreCase("DATETIME") ||
| compareString.substring(0,9).equalsIgnoreCase("TIMESTAMP"))
| useddatatype = "String";
| else useddatatype = "String";
| String propertiesclaring1 = "\tprivate " + useddatatype + " " + columnname + ";\n";
| String propertiesclaring2 = "\t@Column(name=\""+ columnname +"\")\n";
| String propertiesgetter = "\tpublic " + useddatatype + " get" + columnname + "(){\n\t\treturn " + columnname +";\n\t}\n";
| String propertiessetter = "\tpublic void " + "set" + columnname + "(" + useddatatype + " " + columnname + "){\n\t\tthis." + columnname + " = " + columnname + ";\n\t}\n\n";
| String propertiesID = "\t@Id\n\t@GeneratedValue\n";
| StringBuffer propertiesText = new StringBuffer().append(propertiesclaring1);
| if(keytype!=null && keytype.equalsIgnoreCase("PRI"))
| propertiesText.append(propertiesID);
| propertiesText.append(propertiesclaring2).append(propertiesgetter).append(propertiessetter);
| return propertiesText;
| }
|
| private StringBuffer doGenerateJavaCode(Connection conn, String tablename,String classname){
| StringBuffer javaCode = new StringBuffer();
| javaCode.append(doGenerateClassName(tablename,classname));
| String querycolumns = "show columns from " + tablename;
| try{
| Statement stmt = conn.createStatement();
| ResultSet rs = stmt.executeQuery(querycolumns);
| while(rs.next()){
| javaCode.append(doGenerateProperties(rs.getString("Field"),rs.getString("Type"),
| rs.getString("Key"),rs.getString("Null"),rs.getString("Default")));
| }
| rs.close();
| stmt.close();
| javaCode.append("\n}");
|
| }catch(Exception e){
| System.out.println(e.getMessage());
| }
| return javaCode;
| }
|
| private void writeToFile(StringBuffer sb, String filename){
| try{
| File out = new File(filename);
| FileWriter fw = new FileWriter(out);
| for (int i = 0; i < sb.length(); i++){
| char c = sb.charAt(i);
| fw.write(c);
| }
| fw.flush();
| fw.close();
| }catch(Exception e){
| System.out.println(e.getMessage());
| }
| }
| public GenerateEntityBeans (Connection conn, String tablename, String classname, String directory){
| writeToFile(doGenerateJavaCode(conn,tablename,classname),directory);
| }
| public static void main(String args[]){
| try{
| Class.forName("com.mysql.jdbc.Driver").newInstance();
| Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/jdi","jdi","jdi");
| String query1 = "show tables";
| Statement stmt = conn.createStatement();
| ResultSet rs = stmt.executeQuery(query1);
| while(rs.next()){
| String tablename = rs.getString(1);
| String classname = tablename + "EntityBean";
| new GenerateEntityBeans(conn,tablename,classname,directory + classname + ".java");
| }
| stmt.close();
| rs.close();
| conn.close();
| }catch(Exception e){
| System.out.print(e.toString());
| }finally{
| ;
| }
|
| }
| }
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024640#4024640
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024640
17Â years, 11Â months