[JBoss Seam] - Re: Locale selector can not change the locale on Seam 2.0.0.
by jazir1979
Hi Joshua,
Sorry this isn't much help, but I can say for certain that I did not experience this when I upgraded our project to 2.0.0.GA. Also, I don't remember having to change any code to get it to work.
I'm changing it with a command button that has the localeSelector.select action.
good luck,
Daniel.
"thejavafreak" wrote : Dear all,
|
| I faced a problem on locale selector as defined in documentation. Everytime I hit the submit button, it doesn't change the locale as written in the documentantion. OTOH, it goes back to the default locale. If I wanted to be able to change the locale, I must set it up from my browser first. I didn't encounter this problem during the Seam 1.2.0.GA usage. Did anyone encounter the same problem as I did? I also could not find a samples on this too to reproduce the problem.
|
| Thanks in advance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114873#4114873
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114873
18 years, 4 months
[JCA/JBoss] - java.sql.SQLException: The statement is closed.
by paulpark
I'm getting a java.sql.SQLException: The statement is closed. error in Jboss. Do you notice any problem in the code or config file?
server.log:
2007-12-20 18:00:08,025 TRACE [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Returning connection to pool org.jboss.resource.connectionman
ager.TxConnectionManager$TxConnectionEventListener@793aac5f[state=NORMAL mc=org.jboss.resource.adapter.jdbc.local.LocalManagedConnection@7b0acf26 handles=0 l
astUse=1198191608025 permit=false trackByTx=false mcp=org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool@af917bd context=org.jboss.resou
rce.connectionmanager.InternalManagedConnectionPool@67857eeb xaResource=org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource@2a606e6 txSy
nc=null] [InUse/Available/Max]: [6/88/100]
2007-12-20 18:00:08,041 INFO [STDOUT] Exception in processReading java.sql.SQLException: The statement is closed.
2007-12-20 18:00:08,041 INFO [STDOUT] Test 6
oracle-ds.xml:
<local-tx-datasource>
<jndi-name>OracleDS</jndi-name>
<use-java-context>false</use-java-context>
<connection-url>jdbc:oracle:thin:@ldcdevl:1521:xxxx</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>xxxxx</user-name>
xxxxx
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prepared-statement-cache-size>200</prepared-statement-cache-size>
<max-idle-timeout>0</max-idle-timeout>
<blocking-timeout-millis>50000</blocking-timeout-millis>
<idle-timeout-minutes>30</idle-timeout-minutes>
<track-statements>true</track-statements>
<type-mapping>Oracle9i</type-mapping>
</local-tx-datasource>
public class BillingResponseDAO {
private DBConnection dbCon = null;
private List billingReadList = new ArrayList();
private BillingRead billingRead = null;
private com.th.commonUtil.intface.Context ctx = null;
public String premCode = null;
public String servNum = null;
public static final String billingResponseString =
"INSERT INTO UXBSRRS values (?,?,?,?,?,?,?,SYSDATE,USER)";
public static final String billingResponseDetailString =
"INSERT INTO UXRSRRS values (?,?,?,?,?)";
AppContext appCtxt = null;
public BillingResponseDAO() {
}
public BillingResponseDAO(String test) {
}
public
void init(Context ctx) {
System.out.println("Inside BillingResponseDAO 1");
try {
dbCon = ctx.getDBConMDB();
dbCon.getConnectionMDB();
} catch (Exception e) {
System.out.println("Exception in BillingResponseDAO init" + e);
}
}
public void processReading(BillingResponse bResponse) throws Exception {
PreparedStatement stmt = null;
PreparedStatement stmt1 = null;
String premCodeLocal = null;
String noData = null;
String validationStatus = null;
String status = "N";
String dateStr = null;
String dateStr1 = null;
String dateStr2 = null;
String dateStr3 = null;
try {
if (dbCon == null) {
dbCon = ctx.getDBConMDB();
dbCon.getConnectionMDB();
}
stmt =
(PreparedStatement)dbCon.getCachedStatement(billingResponseString);
stmt1 =
(PreparedStatement)dbCon.getCachedStatement(billingResponseDetailString);
if (stmt != null) {
DBUtil.setString(stmt, 1, bResponse.getTransactionID());
/** Commented on May 21 JCH *
parseSDP(bResponse.getSDP());
premCodeLocal = removeLeadingZeros(premCode);
DBUtil.setString(stmt, 2, premCodeLocal);
DBUtil.setLong(stmt, 3, Long.parseLong(servNum));
DBUtil.setString(stmt, 4, bResponse.getMeterNum());
*/
/* Added the code Below May 21**/
Long localServNum=null;
String tempSDP = null;
tempSDP = bResponse.getSDP();
System.out.println("Temp SDP ="+tempSDP);
if ( (tempSDP == null) ||
(tempSDP.equals(""))
)
{
DBUtil.setString(stmt, 2, premCode);
DBUtil.setLong(stmt, 3,localServNum);
}
else{
parseSDP(bResponse.getSDP());
premCodeLocal = removeLeadingZeros(premCode);
DBUtil.setString(stmt, 2, premCodeLocal);
DBUtil.setLong(stmt, 3, Long.parseLong(servNum));
}
/* End the code Below May 21**/
DBUtil.setString(stmt, 4, bResponse.getMeterNum());
String tempReadDate = bResponse.getReadDate();
if ( (tempReadDate ==null)||
(tempReadDate.equals(""))
)
{
DBUtil.setDate(stmt, 5,null);
}
else
{
dateStr = bResponse.getReadDate();
dateStr1 = new String(dateStr.substring(0, 10));
dateStr2 = new String(dateStr.substring(11, 19));
dateStr3 = dateStr1 + " " + dateStr2;
System.out.println("dateStr =" + dateStr3);
String testString = getDateTime(dateStr3);
SimpleDateFormat df =
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
DBUtil.setDate(stmt, 5, df.parse(testString));
}
DBUtil.setString(stmt, 6, bResponse.getReaderID());
DBUtil.setString(stmt, 7, bResponse.getErrorCode());
billingReadList = new ArrayList();
billingReadList = bResponse.getBillingRead();
System.out.println("Statement After Values are SET -1 = " + stmt);
if (billingReadList == null) {
;
}
else
{
for (int i = 0; i < billingReadList.size(); i++) {
billingRead = (BillingRead)billingReadList.get(i);
DBUtil.setString(stmt1, 1, bResponse.getTransactionID());
DBUtil.setInt(stmt1, 2, i + 1);
DBUtil.setString(stmt1, 3, billingRead.getMeausrementType());
String reading= billingRead.getReading();
/*Long reading1=null; Defect# */
Float reading1=null;
/*Code Added */
if ( (reading == null) ||
(reading.equals(""))
)
{
reading1=null;
}
else{
// reading1= Long.parseLong(reading.trim());
reading1= Float.parseFloat(reading.trim());
System.out.println("Reading= "+reading1);
}
/*DBUtil.setLong(stmt1, 4, reading1); */
DBUtil.setFloat(stmt1, 4, reading1);
validationStatus = billingRead.getValidationStatus();
noData = billingRead.getNoData();
if (bResponse.getErrorCode() == "0") {
if (noData == "false") {
if (validationStatus == "E")
status = "E";
else if (validationStatus == "I")
status = "I";
else if (validationStatus == "Ext")
status = "U";
else
status = "V";
} else
status = "N";
DBUtil.setString(stmt1, 5, status);
}
DBUtil.setString(stmt1, 5, status);
stmt1.execute();
}
}
stmt.execute();
}
} catch (Exception e) {
System.out.println("Exception in processReading " + e);
} finally {
try {
DBUtil.close(stmt);
DBUtil.close(stmt1);
dbCon.close();
} catch (Exception e) {
System.out.println("Exception in closing " + e);
}
}
}
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114865#4114865
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114865
18 years, 4 months
[JBoss Seam] - Re: Why PAGE context variable = NULL
by damnh
I want to pass variable mode (or variable with type Object) from /list.xhtml page to /register.xhtml page, I used PAGE scope to pass.
@Stateful
| @Name("listAction")
| @Scope(SESSION)
| @Restrict("#{identity.loggedIn}")
| public class ListAction implements
| IListAction {
| .........
| @In(required = false)
| @Out(required = false, scope = ScopeType.PAGE)
| private String mode;
|
| public void search() {
| mode = "searched";
| //get list to display list.xhtml
| ..................
| }
| ..........
| }
| @Stateful
| @Name("regAction")
| @Restrict("#{identity.loggedIn}")
| public class RegAction implements IRegAction {
|
| ...........
| @In(required = false)
| @Out(required = false, scope = ScopeType.PAGE)
| private String mode;
|
| public void init() {
| if ("searched".equals(mode)) {
| ....
| } else {
| ....
| }
| }
| }
|
pages.xml
| <page view-id="/list.xhtml" login-required="true">
| <navigation from-action="#{listAction.search}">
| <redirect view-id="/list.xhtml" />
| </navigation>
| <navigation from-action="#{regAction.init}">
| <begin-conversation flush-mode="manual" />
| <redirect view-id="/register.xhtml" />
| </navigation>
| </page>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114863#4114863
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114863
18 years, 4 months
[Tomcat, HTTPD, Servlets & JSP] - Re: Session is getting merge with other session
by bstansberry@jboss.com
If at the end of your application workflow, there is a natural place to do session.invalidate(), then sure, I encourage you to do that. That will save you memory.
Session ids are generated from a VM singleton, using a random generator seeded by a timestamp and the VM's free memory (which are unlikely to be duplicated across VMs in a cluster). The class follows, in case you are interested. I've never heard a case of this algorithm generating noticeable duplicate ids. I have seen reports on this forum of non-clustered webapps getting duplicate ids when more than one JBoss instance is on the same machine. But clustered session ids use a different algorithm.
Have you heard of more than 1 case of this? If you have, that would in my mind pretty much rule out a chance session id collision.
Anyway, invalidating the session if you know its done would reduce the already extremely low chance of a problem from session id collision.
Here's the SessionIDGenerator class:
| /*
| * JBoss, Home of Professional Open Source.
| * Copyright 2006, Red Hat Middleware LLC, and individual contributors
| * as indicated by the @author tags. See the copyright.txt file in the
| * distribution for a full listing of individual contributors.
| *
| * This is free software; you can redistribute it and/or modify it
| * under the terms of the GNU Lesser General Public License as
| * published by the Free Software Foundation; either version 2.1 of
| * the License, or (at your option) any later version.
| *
| * This software is distributed in the hope that it will be useful,
| * but WITHOUT ANY WARRANTY; without even the implied warranty of
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
| * Lesser General Public License for more details.
| *
| * You should have received a copy of the GNU Lesser General Public
| * License along with this software; if not, write to the Free
| * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
| * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
| */
| package org.jboss.web.tomcat.service.session;
|
| import java.util.Collection;
| import java.util.HashSet;
| import java.util.Iterator;
| import java.util.Random;
| import java.security.MessageDigest;
| import java.security.NoSuchAlgorithmException;
| import java.security.SecureRandom;
|
| import org.jboss.logging.Logger;
|
| /**
| * Unique session id generator
| *
| * @author Ben Wang
| */
| public class SessionIDGenerator
| {
| protected final static int SESSION_ID_BYTES = 16; // We want 16 Bytes for the session-id
| protected final static String SESSION_ID_HASH_ALGORITHM = "MD5";
| protected final static String SESSION_ID_RANDOM_ALGORITHM = "SHA1PRNG";
| protected final static String SESSION_ID_RANDOM_ALGORITHM_ALT = "IBMSecureRandom";
| protected Logger log = Logger.getLogger(SessionIDGenerator.class);
|
| protected MessageDigest digest = null;
| protected Random random = null;
| protected static final SessionIDGenerator s_ = new SessionIDGenerator();
|
| protected String sessionIdAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-*";
|
| public static SessionIDGenerator getInstance()
| {
| return s_;
| }
|
| /**
| * The SessionIdAlphabet is the set of characters used to create a session Id
| */
| public void setSessionIdAlphabet(String sessionIdAlphabet)
| {
| if (sessionIdAlphabet.length() != 65) {
| throw new IllegalArgumentException("SessionIdAlphabet must be exactly 65 characters long");
| }
|
| checkDuplicateChars(sessionIdAlphabet);
|
| this.sessionIdAlphabet = sessionIdAlphabet;
| }
|
| protected void checkDuplicateChars(String sessionIdAlphabet) {
| char[] alphabet = sessionIdAlphabet.toCharArray();
| for (int i=0; i < alphabet.length; i++) {
| if (!uniqueChar(alphabet, sessionIdAlphabet)) {
| throw new IllegalArgumentException("All chars in SessionIdAlphabet must be unique");
| }
| }
| }
|
| // does a character appear in the String once and only once?
| protected boolean uniqueChar(char c, String s) {
| int firstIndex = s.indexOf(c);
| if (firstIndex == -1) return false;
| return s.indexOf(c, firstIndex + 1) == -1;
| }
|
| /**
| * The SessionIdAlphabet is the set of characters used to create a session Id
| */
| public String getSessionIdAlphabet() {
| return this.sessionIdAlphabet;
| }
|
| public synchronized String getSessionId()
| {
| String id = generateSessionId();
| if (log.isDebugEnabled())
| log.debug("getSessionId called: " + id);
| return id;
| }
|
|
| /**
| * Generate a session-id that is not guessable
| *
| * @return generated session-id
| */
| protected synchronized String generateSessionId()
| {
| if (this.digest == null)
| {
| this.digest = getDigest();
| }
|
| if (this.random == null)
| {
| this.random = getRandom();
| }
|
| byte[] bytes = new byte[SESSION_ID_BYTES];
|
| // get random bytes
| this.random.nextBytes(bytes);
|
| // Hash the random bytes
| bytes = this.digest.digest(bytes);
|
| // Render the result as a String of hexadecimal digits
| return encode(bytes);
| }
|
| /**
| * Encode the bytes into a String with a slightly modified Base64-algorithm
| * This code was written by Kevin Kelley <kelley(a)ruralnet.net>
| * and adapted by Thomas Peuss <jboss(a)peuss.de>
| *
| * @param data The bytes you want to encode
| * @return the encoded String
| */
| protected String encode(byte[] data)
| {
| char[] out = new char[((data.length + 2) / 3) * 4];
| char[] alphabet = this.sessionIdAlphabet.toCharArray();
|
| //
| // 3 bytes encode to 4 chars. Output is always an even
| // multiple of 4 characters.
| //
| for (int i = 0, index = 0; i < data.length; i += 3, index += 4)
| {
| boolean quad = false;
| boolean trip = false;
|
| int val = (0xFF & (int) data);
| val <<= 8;
| if ((i + 1) < data.length)
| {
| val |= (0xFF & (int) data[i + 1]);
| trip = true;
| }
| val <<= 8;
| if ((i + 2) < data.length)
| {
| val |= (0xFF & (int) data[i + 2]);
| quad = true;
| }
| out[index + 3] = alphabet[(quad ? (val & 0x3F) : 64)];
| val >>= 6;
| out[index + 2] = alphabet[(trip ? (val & 0x3F) : 64)];
| val >>= 6;
| out[index + 1] = alphabet[val & 0x3F];
| val >>= 6;
| out[index + 0] = alphabet[val & 0x3F];
| }
| return new String(out);
| }
|
| /**
| * get a random-number generator
| *
| * @return a random-number generator
| */
| protected synchronized Random getRandom()
| {
| long seed;
| Random random = null;
|
| // Mix up the seed a bit
| seed = System.currentTimeMillis();
| seed ^= Runtime.getRuntime().freeMemory();
|
| try
| {
| random = SecureRandom.getInstance(SESSION_ID_RANDOM_ALGORITHM);
| }
| catch (NoSuchAlgorithmException e)
| {
| try
| {
| random = SecureRandom.getInstance(SESSION_ID_RANDOM_ALGORITHM_ALT);
| }
| catch (NoSuchAlgorithmException e_alt)
| {
| log.error("Could not generate SecureRandom for session-id randomness", e);
| log.error("Could not generate SecureRandom for session-id randomness", e_alt);
| return null;
| }
| }
|
| // set the generated seed for this PRNG
| random.setSeed(seed);
|
| return random;
| }
|
| /**
| * get a MessageDigest hash-generator
| *
| * @return a hash generator
| */
| protected synchronized MessageDigest getDigest()
| {
| MessageDigest digest = null;
|
| try
| {
| digest = MessageDigest.getInstance(SESSION_ID_HASH_ALGORITHM);
| }
| catch (NoSuchAlgorithmException e)
| {
| log.error("Could not generate MessageDigest for session-id hashing", e);
| return null;
| }
|
| return digest;
| }
|
| public static void main(String[] args)
| {
| SessionIDGenerator gen = SessionIDGenerator.getInstance();
|
| HashSet set = new HashSet();
| String id = null;
| for (int i = 0; i > -1; i++)
| {
| id = gen.getSessionId();
|
| if (set.add(id) == false)
| {
| System.out.println(i + " FAILED -- duplicate id " + id);
| break;
| }
|
| if (i % 1000 == 0 && i > 0)
| {
| System.out.println("Tested " + i + " session ids");
| }
| if (i % 50000 == 0 && set.size() > 450000)
| {
| System.out.println("Discarding...");
| int k = 0;
| int discarded = 0;
| for (Iterator it = set.iterator(); it.hasNext() && discarded < 50000; k++)
| {
| it.next();
| if (k % 10 == 0)
| {
| it.remove();
| discarded++;
| }
| }
| System.out.println("Discarding completed");
| }
| }
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114862#4114862
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114862
18 years, 4 months