关于JBOSS中配置JAAS(相当着急)

08-10-11 yongbuyanbai
我前不久配过一次利用FORM验证,而且成功了,但是今天再配置的时候出现问题,总报异常
环境JBOSS 4.2.3GA mysql4.1
页面:<form method="POST" action="j_security_check">
用户名: <input type="text" name="j_username"/>
<br />
密码: <input type="password" name="j_password"/>
<br />
<input type="submit" value="登录"/>
</form>
在JBOSS中配置了MYSQL数据源,并且也设置了安全域
如下:
JBOSS-WEB.XML
<jboss-web>
<security-domain>mySecurity</security-domain>
</jboss-web>
安全域
<application-policy name = "mySecurity">
<authentication>
<login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule"
flag = "required">
<module-option name = "unauthenticatedIdentity">AnonymousUser</module-option>
<module-option name = "dsJndiName">java:/MySqlDS</module-option>
<module-option name = "principalsQuery">SELECT PASSWD FROM JMS_USERS WHERE USERID=?</module-option>
<module-option name = "rolesQuery">SELECT ROLEID, 'Roles' FROM JMS_ROLES WHERE USERID=?</module-option>
</login-module>
</authentication>
</application-policy>
数据源配置:
<local-tx-datasource>
<jndi-name>MySqlDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/jbossdb</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>x</user-name>
<password>y</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<!-- should only be used on drivers after 3.22.1 with "ping" support
<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
-->
<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
-->
<new-connection-sql>select * from jbossdb</new-connection-sql>
<!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
-->

<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
对应的表也设置正确.
但是在输入用户密码验证的时候报错
14:19:56,054 ERROR [JBossSecurityMgrRealm] Error during authenticate
javax.naming.NamingException: Could not dereference object [Root exception is ja
vax.naming.CommunicationException: Receive timed out [Root exception is java.net
.SocketTimeoutException: Receive timed out]]
at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1215)

at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:758)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.authenticate(JBos
sSecurityMgrRealm.java:488)
at org.apache.catalina.authenticator.FormAuthenticator.authenticate(Form
Authenticator.java:257)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:416)
我也不知道为什么,以前都没有出现,着急,请BANQ和高手解决下!!!!!!!!!!先谢谢了!

banq
2008-10-12 10:52
javax.naming.NamingException: Could not dereference object

JNDI方面的问题,有可能和MySQLDs有关,确诊数据库是否能够连接等。

yongbuyanbai
2008-10-12 11:15
我在安装JBOSS服务器的时候使用的是jboss-4.2.3.GA-jdk6,JDK6已经引入并配置环境变量,但是在启动的时候总报错
Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/system/serv
er/NoAnnotationURLClassLoader
at org.jboss.system.server.ServerLoader.load(ServerLoader.java:263)
at org.jboss.Main.boot(Main.java:194)
at org.jboss.Main$1.run(Main.java:508)
at java.lang.Thread.run(Thread.java:619)
请按任意键继续. . .

但是换4.0.4GA就没有问题,用了5.0也是报错,不知道为什么?

freebox
2008-10-12 13:49
jboss官方站上似乎有段说明,表明4.2.x不支持jdk6,对应用服务器最好查看配置文档,选择恰当的版本,某些时候应该牺牲新的特性和功能选择降级版本。再说也不是版本越高越好

yongbuyanbai
2008-10-12 15:19
上次的问题不报错误了!但是当通过WEB的表单验证的时候,报下面的错误
java.net.SocketTimeoutException: Receive timed out
at java.net.PlainDatagramSocketImpl.receive0(Native Method)
at java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:136)
at java.net.DatagramSocket.receive(DatagramSocket.java:712)
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1435)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1594)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.apache.jsp.anon.anonymousPage_jsp._jspService(anonymousPage_jsp.java:61)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
不知道为什么,以前都好用,最近不知道为什么不好用了,请BANQ和道友帮忙解决下,真的很着急!!!!