Appfuse在jboss上的配置
2008-01-05 18:35:58 来源:WEB开发网主要是安全配置和日志问题,安全配置涉及到login-config.xml、web.xml、jboss-web.xml这几个文件,日志涉及到log4j.xml文件,配置方法如下:
1. 修改\server\default\cof\login-config.xml文件,为appfuse添加登录策略。
<application-policy name = "appfuse">
<authentication>
<login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule"
flag = "required">
<module-option name = "dsJndiName">jdbc/MySQL</module-option><!—假如是jboss4.0,名字为java:/ jdbc/mysql-->
<module-option name = "PRincipalsQuery">
select passWord from app_user where username=?
</module-option>
<module-option name = "rolesQuery">
select role_name, 'Roles' from user_role where username=?
</module-option>
</login-module>
</authentication>
</application-policy>
2. 创建数据源文件,比如文件名为mysql-ds.xml,将这个文件放入\server\default\ deploy目录中,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/mysql</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/mysql</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password></password>
</local-tx-datasource>
</datasources>
3. 创建jboss-web.xml文件,定义jdbc资源和该app使用的是login-config.xml文件配置的哪一个安全策略。内容如下:
<?xml version="1.0" encoding="UTF-8" ?>
<jboss-web>
<context-root>/appfuse</context-root>
<resource-ref>
<res-ref-name>jdbc/mysql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>java:jdbc/mysql</jndi-name>
</resource-ref>
<security-domain>java:/jaas/appfuse</security-domain>
</jboss-web>
4. 修改web.xml文件:要害是资源的定义,如下:
<resource-ref>
<description>DB Connection</description>
<res-ref-name> jdbc/mysql </res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
5. web应用部署在jboss中时log4j的配置必须在\server\default\conf\log4j.xml中进行配置,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!-- ===================================================================== -->
<!-- -->
<!-- Log4j Configuration -->
<!-- -->
<!-- ===================================================================== -->
<!-- $Id: log4j.xml,v
<!--
For more configuration infromation and examples see the Jakarta Log4j
owebsite: http://jakarta.apache.org/log4j
-->
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<!-- ================================= -->
<!-- Preserve messages in a local file -->
<!-- ================================= -->
<!-- A time/date based rolling appender -->
<appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="${jboss.server.home.dir}/log/server.log"/>
<param name="Append" value="false"/>
<!-- Rollover at midnight each day -->
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<!-- Rollover at the top of each hour
<param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
-->
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
<!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
<param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
-->
</layout>
</appender>
<appender name="LOG" class="org.jboss.logging.appender.DailyRollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="${jboss.server.home.dir}/log/app.log"/>
<param name="Append" value="false"/>
<!-- Rollover at midnight each day -->
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<!-- Rollover at the top of each hour
<param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
-->
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="[%5p] %d{mm:ss} (%F:%M:%L)%n%m%n%n"/>
<!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
<param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
-->
</layout>
</appender>
<!-- ============================== -->
<!-- Append messages to the console -->
<!-- ============================== -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="Target" value="System.out"/>
<param name="Threshold" value="ERROR"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
</layout>
</appender>
<category name="org" >
<priority value="WARN"/>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</category>
<category name="com" >
<priority value="WARN"/>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</category>
<category name="net.sf.hibernate" >
<priority value="WARN"/>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</category>
<category name="net.sf" >
<priority value="WARN"/>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</category>
<!-- Limit the org.apache.commons category to INFO as its DEBUG is verbose -->
<category name="org.apache" >
<priority value="WARN"/>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</category>
<!-- Limit JBoss categories to INFO -->
<category name="org.jboss">
<priority value="WARN"/>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</category>
<category name="org.apache.struts.action">
<priority value="WARN"/>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</category>
<category name="org.appfuse">
<priority value="INFO"/>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</category>
<category name="org.appfuse.struts">
<priority value="INFO"/>
<appender-ref ref="LOG"/>
</category>
<category name="org.appfuse.webapp.listener">
<priority value="INFO"/>
<appender-ref ref="LOG"/>
</category>
<category name="org.appfuse.mdb">
<priority value="INFO"/>
<appender-ref ref="LOG"/>
</category>
<category name="org.appfuse.common.jms">
<priority value="WARN"/>
<appender-ref ref="LOG"/>
</category>
<category name="org.appfuse">
<priority value="WARN"/>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</category>
<root>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
</log4j:configuration>
- ››配置MySQL出错The service could not be started....
- ››配置apache虚拟主机
- ››配置远程客户机使用命名管道协议访问SQL服务器
- ››配置SQL Server2005以允许远程访问
- ››配置ISA Server以创建站点到站点VPN 连接之一
- ››配置ISA Server以创建站点到站点VPN 连接之二
- ››配置ISA Server以创建站点到站点VPN 连接之三 启用...
- ››配置VPN服务器中的L2TP/IPSEC:ISA2006系列之二十...
- ››配置单网卡的ISA缓存服务器:ISA2006系列之二十七...
- ››配置Win2008作为远程访问SSL-VPN服务器之一
- ››配置Win2008作为远程访问SSL-VPN服务器之二
- ››配置Win2008作为远程访问SSL-VPN服务器之三
更多精彩
赞助商链接