[JBoss JIRA] Created: (JBLOGGING-6) DatasourceAppender
by Luca Stancapiano (JIRA)
DatasourceAppender
------------------
Key: JBLOGGING-6
URL: https://jira.jboss.org/jira/browse/JBLOGGING-6
Project: JBoss Logging
Issue Type: Feature Request
Security Level: Public (Everyone can see)
Components: jboss-logging-log4j
Affects Versions: 1.0.0.GA-slf4j-jboss-logging, 2.0.6.GA-spi
Reporter: Luca Stancapiano
Assignee: Dimitris Andreadis
Fix For: 2.0.6.GA-spi, 1.0.0.GA-slf4j-jboss-logging
hi.... what do you think about a DatasourceAppender? This is very simple. It overrides getConnection and closeConnection methods of org.apache.log4j.jdbc.JDBCAppender class and it is configurable by a *-log4j.xml file. Here there is an example of xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="DATABASE" class="org.jboss.logging.appender.DatasourceAppender">
<param name="Threshold" value="INFO"/>
<param name="datasource" value="java:/PortalDS"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value=
"INSERT INTO JBP_LOGGING_SAMPLES_USERS (log_date, log_type, log_user, operation) VALUES ( '%d{yyyy-MM-dd HH:mm:ss.SSS}','%p', '%C;%L', '%C;%L')"/>
</layout>
</appender>
<category name="org.jboss.portal.core.identity.UsersActivityStatsServiceImpl">
<appender-ref ref="DATABASE"/>
</category>
</log4j:configuration>
it is the same configuration for JDBCAppender but there is a 'datasource' parameter so you can specify the datasource location. Below there is the whole class:
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.logging.appender;
import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
/**
* An extension of the default Log4j JDBCAppender which will use a datasource to
* handle datas into database.
*
* @version <tt>$Revision: 1958 $</tt>
* @author <a href="mailto:jedim@vige.it">Luca Stancapiano</a>
*/
public class DatasourceAppender extends org.apache.log4j.jdbc.JDBCAppender {
/**
* URL of the DB for default connection handling
*/
protected String datasource = "java:/DefaultDS";
protected DataSource ds;
public void setDatasource(final String datasource) {
this.datasource = datasource;
}
/**
* I override this method to get a connection from datasource.
*/
protected Connection getConnection() throws SQLException {
if (connection == null || connection.isClosed()) {
if (ds == null)
try {
InitialContext ic = new InitialContext();
ds = (DataSource) ic.lookup(datasource);
} catch (NamingException e) {
e.printStackTrace();
}
connection = ds.getConnection();
}
return connection;
}
protected void closeConnection(Connection con) {
try {
connection.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 11 months
[JBoss JIRA] Created: (JBLOGGING-55) NPE in FileAppender$Helper
by Ondrej Zizka (JIRA)
NPE in FileAppender$Helper
--------------------------
Key: JBLOGGING-55
URL: https://issues.jboss.org/browse/JBLOGGING-55
Project: JBoss Logging
Issue Type: Bug
Security Level: Public (Everyone can see)
Reporter: Ondrej Zizka
Assignee: David Lloyd
When you set the file="..." to just a file, i.e. file="foobar.log",
then you get a NPE at line
if (!dir.exists()) {
probably because
dir = new File(filename.trim()).getParentFile();
returns null.
I'd expect the appender to write to a file in new File( new File(System.getProperty("user.dir")), filename.trim() ).
package org.jboss.logging.appender;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.log4j.helpers.LogLog;
public class FileAppender$Helper
{
public static void makePath(String filename)
{
File dir;
try
{
URL url = new URL(filename.trim());
dir = new File(url.getFile()).getParentFile();
}
catch (MalformedURLException e) {
dir = new File(filename.trim()).getParentFile();
}
if (!dir.exists()) {
boolean success = dir.mkdirs();
if (!success)
LogLog.error("Failed to create directory structure: " + dir);
}
}
}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 11 months
[JBoss JIRA] Created: (JBMESSAGING-1826) Removing a reference and deleting a message in DB should be wrapped in a single transaction in JDBCPersistenceManager
by Yong Hao Gao (JIRA)
Removing a reference and deleting a message in DB should be wrapped in a single transaction in JDBCPersistenceManager
----------------------------------------------------------------------------------------------------------------------
Key: JBMESSAGING-1826
URL: https://jira.jboss.org/browse/JBMESSAGING-1826
Project: JBoss Messaging
Issue Type: Bug
Components: Messaging Core Persistence
Affects Versions: 1.4.7.GA, 1.4.0.SP3.CP10
Reporter: Yong Hao Gao
Assignee: Yong Hao Gao
Fix For: 1.4.0.SP3.CP11, 1.4.8.GA
In JDBCPersistenceManager, when a message is delivered and completed, the message is removed from DB. It includes two deletes in the DB - the reference in JBM_MSG_REF and the message in JBM_MSG. The two deletes are currently done in two separate local transactions as in removeReference() method:
...
new RemoveReferenceRunner().executeWithRetry();
deleteMessage(ref.getMessage().getMessageID());
...
If a server crashes between the two operations, it will leave the tables in an inconsistent state, i.e. ref removed but the message still there. This may result in message stuck, as in this case:
1. A server is crashing when a client_ack comes in, the clienk_ack will cause the message to be cleared from the server. If the client_ack processing goes as far as that the removing of reference succeeds but failed to delete the message due to the crashing, the message is left in JBM_MSG table but the corresponding entry in JBM_MSG_REF is gone.
2. Eventually the jms client will get ack failure exception. It then expects the messages to be re-delivered after server start-up. But that will never happen. When the server starts up it loads references in JBM_MSG_REF for delivery, but this message's ref is gone.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 11 months
[JBoss JIRA] Created: (HIBERNATE-54) problems w/ column names beginning with '_' (underscore) w/ apache derby database
by bugra uytun (JIRA)
problems w/ column names beginning with '_' (underscore) w/ apache derby database
---------------------------------------------------------------------------------
Key: HIBERNATE-54
URL: http://jira.jboss.com/jira/browse/HIBERNATE-54
Project: Hibernate
Issue Type: Bug
Environment: windows xp, java 1.5.0_09, eclispe 3.2.1, hibernate 3.2.1, derby 10.2.2.0, hibernate tools 3.2 beta8
Reporter: bugra uytun
Assigned To: Steve Ebersole
derby has problems with column names beginning with underscore, see also http://db.apache.org/derby/docs/10.1/ref/crefsqlj1003454.html
therefore such column names should be between double quotation marks (notice that double quotation marks also sets the case sensitivity on column names.)
but hibernate translates a HQL statement like this "from table1 t where t.id = '1'" to something like:
select table1_.id as id4, table1_._colname1 as column27_4_ schema1.table1 table1_ where table1_.id = '1'
but because of the columns that are beginning with an underscore the translation should be:
select table1_."id" as id4, table1_."_colname1" as column27_4_ schema1."table1" table1_ where table1_."id" = '1'
the errors i got are:
DEBUG [JDBCExceptionReporter]: could not execute query [<translated sql statement>]
ERROR 42X01: Syntax error: Encountered "_" at line 1, column 987.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.<init>(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.<init>(Unknown Source)
at org.apache.derby.jdbc.Driver30.newEmbedPreparedStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:497)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:415)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1538)
at org.hibernate.loader.Loader.doQuery(Loader.java:661)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2211)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)
at org.hibernate.loader.Loader.list(Loader.java:2090)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:388)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at <mypackage>.MyHibernate.main(MyHibernate.java:13)
WARN main org.hibernate.util.JDBCExceptionReporter - SQL Error: 20000, SQLState: 42X01
ERROR main org.hibernate.util.JDBCExceptionReporter - Syntax error: Encountered "_" at line 1, column 987.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 11 months
[JBoss JIRA] (JBRULES-3275) MVEL Dialect: BigDecimal does not show the correct value
by Alessandro Lazarotti (Created) (JIRA)
MVEL Dialect: BigDecimal does not show the correct value
--------------------------------------------------------
Key: JBRULES-3275
URL: https://issues.jboss.org/browse/JBRULES-3275
Project: Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: drools-core
Affects Versions: 5.3.0.Final, 5.2.0.Final
Environment: Fedora 15, JDK Oracle 1.6
Reporter: Alessandro Lazarotti
Assignee: Mario Fusco
MVEL does not show the correct value for BigDecimal instances, like:
BigDecimal ale = 500.01B;
System.out.println(ale);
The result is: 500
BigDecimal should invoke toString, like any Java instance to show values of variables instead of .intValue().
The same happens to show result of arithmetic operations btw BigDecimals:
BigDecimal test = new BigDecimal("50000");
System.out.println(test / new BigDecimal("1.13"));
The result is:
44247
... instead of 44247.78761061946902654867256637168.
Anyway, the internal representation is correct, only the method invoked to show the values is wrong.
The result for:
System.out.println( (test / new BigDecimal("1.13")) == 44247.78761061946902654867256637168B)
is true.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 11 months