[EJB 3.0] - Re: Re: ant failed.
by PeterJ
I thought you wanted to compile the test directory, not the Struts action directory. To compile only the test directory use:
<javac srcdir="${tst-dir}"
| verbose="${TALK}"
| includes="com/ip6networks/calling_card_registration/test/*.java"
| >
| <classpath refid="classpath.test"/>
| </javac>
You could even do this instead:
<javac srcdir="${tst-dir}"
| verbose="${TALK}"
| includes="**/test/*.java"
| >
| <classpath refid="classpath.test"/>
| </javac>
I notice that you have a ${TALK} attribute - I hope you are setting that to true because then the javac task will show you which java source files it is compiling. That can help you verify that the includes directive is correct set of files.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4244473#4244473
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4244473
17 years
[Security & JAAS/JBoss] - JAAS Form Authentication always failing
by mgibson77
I have a small web application (just a tutorial) that I want to secure with JAAS on Jboss but it seems I haÃÂve missed something some where so the authentication is always failing sending me to the login-error.jsp page I have created and mapped. See cod below.
My environment:
Jboss 5.0.0GA, Eclipse Ganymede, MySql 5.1.30-community, Windows Vista
A. The Code
1. database
Principals table:
CREATE TABLE Principals (
PrincipalID VARCHAR (64) PRIMARY KEY,
Password VARCHAR (64)
)
Roles Table:
CREATE TABLE Roles (
PrincipalId varchar(255) NOT NULL default '',
Role varchar(255) NOT NULL default '',
RoleGroup varchar(255) NOT NULL default '',
PRIMARY KEY(PrincipalId)
)
2. login-config.xml
<application-policy name="formbasedPolicyDomainDb">
<login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule"
flag="required">
<module-option name="dsJndiName">java:/mysqlDs</module-option>
<module-option name="principalsQuery">
select Password from Principals where PrincipalID=?</module-option>
<module-option name="rolesQuery">
select Role 'Roles', RoleGroup 'RoleGroups' from Roles where PrincipalId=?</module-option>
</login-module>
</application-policy>
3. jboss-web.xml
<jboss-web>
<security-domain>java:/jaas/formbasedPolicyDomainDb</security-domain>
<resource-ref>
<res-ref-name>jdbc/mysqlDs</res-ref-name>
<jndi-name>java:/jdbc/mysqlDs</jndi-name>
</resource-ref>
</jboss-web>
4. web.xml
<resource-ref>
Mysql Datasource mapping
<res-ref-name>jdbc/mysqlDs</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<security-constraint>
<web-resource-collection>
<web-resource-name>Restricted to Secure role</web-resource-name>
Declarative security
<url-pattern>/admin/*</url-pattern>
<http-method>HEAD</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>Admin</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Restricted to Secure role</web-resource-name>
Declarative security
<url-pattern>/client/*</url-pattern>
<http-method>HEAD</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>Client</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>Admin</role-name>
</security-role>
<security-role>
<role-name>User</role-name>
</security-role>
<security-role>
<role-name>Client</role-name>
</security-role>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/login-error.jsp</form-error-page>
</form-login-config>
</login-config>
Note that I have the data source with jndi name jdbc/mysqlDs mapped in Mysql-ds.xml deployed in Jboss_home/../deploy directory
5. Index.jsp
('<' intentionally removed from a href to display the code rather than an actual link)
a href="<%= request.getContextPath() %>/admin/admin.jsp">Admin Page
a href="<%= request.getContextPath() %>/client/client.jsp">Client Page
a href="<%= request.getContextPath() %>/logout.jsp">Log out
When user try to go to either admin.jsp or client.jsp, they are correctly redirected to login.jsp if they are not logged in.
6. Login.jsp
(close and opened tags intentionally removed to display the code rather than the actual html page)
html
head title login page title head
body
form method="POST" action="j_security_check"
Username: input type="text" name="j_username"
Password: <input type="password" name="j_password"
input type="submit" value="Login"
form
body
html
The issue:
The authentication does not work, it always sends me to login-error.jsp mapped in web.xml
I dont know what j_security_check is and I cant seem to tie it in with my login module DatabaseServerLoginModule defined in login-config.xml
I have seen elsewhere that I may need to write a call back handler but how do I tie it in with j_security_check and my login module?
Please help:
Here is an output from my Jboss log I have enabled security logging so I can see the username being authenticated. user3 below in the log has the role called Client in the Roles table and this Client role is maped correctly in web.xml
if you wish to see my war file, please email me at dooze77 at gmail dot com
2009-07-18 06:57:07,180 DEBUG [org.apache.catalina.realm.RealmBase] (http-127.0.0.1-8080-1) Checking constraint 'SecurityConstraint[Restricted to Secure role]' against GET /client/client.jsp --> false
2009-07-18 06:57:07,180 DEBUG [org.apache.catalina.realm.RealmBase] (http-127.0.0.1-8080-1) Checking constraint 'SecurityConstraint[Restricted to Secure role]' against GET /client/client.jsp --> true
2009-07-18 06:57:07,180 DEBUG [org.apache.catalina.realm.RealmBase] (http-127.0.0.1-8080-1) Checking constraint 'SecurityConstraint[Restricted to Secure role]' against GET /client/client.jsp --> false
2009-07-18 06:57:07,181 DEBUG [org.apache.catalina.realm.RealmBase] (http-127.0.0.1-8080-1) Checking constraint 'SecurityConstraint[Restricted to Secure role]' against GET /client/client.jsp --> true
2009-07-18 06:57:07,181 DEBUG [org.apache.catalina.authenticator.AuthenticatorBase] (http-127.0.0.1-8080-1) Calling hasUserDataPermission()
2009-07-18 06:57:07,181 DEBUG [org.apache.catalina.realm.RealmBase] (http-127.0.0.1-8080-1) User data constraint has no restrictions
2009-07-18 06:57:07,184 DEBUG [org.apache.catalina.authenticator.AuthenticatorBase] (http-127.0.0.1-8080-1) Calling authenticate()
2009-07-18 06:57:07,184 DEBUG [org.apache.catalina.authenticator.FormAuthenticator] (http-127.0.0.1-8080-1) Save request in session '1A8034E59C5FF30260B6699B53356B69'
2009-07-18 06:57:07,205 DEBUG [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/JAASFormAuth].[jsp]] (http-127.0.0.1-8080-1) Disabling the response for futher output
2009-07-18 06:57:07,205 DEBUG [org.apache.catalina.authenticator.AuthenticatorBase] (http-127.0.0.1-8080-1) Failed authenticate() test
2009-07-18 06:57:16,864 DEBUG [org.apache.catalina.connector.CoyoteAdapter] (http-127.0.0.1-8080-1) Requested cookie session id is 1A8034E59C5FF30260B6699B53356B69
2009-07-18 06:57:16,865 DEBUG [org.apache.catalina.authenticator.AuthenticatorBase] (http-127.0.0.1-8080-1) Security checking request POST /JAASFormAuth/client/j_security_check
2009-07-18 06:57:16,866 DEBUG [org.apache.catalina.authenticator.FormAuthenticator] (http-127.0.0.1-8080-1) Authenticating username 'user3'
2009-07-18 06:57:16,873 DEBUG [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/JAASFormAuth].[jsp]] (http-127.0.0.1-8080-1) Disabling the response for futher output
2009-07-18 06:57:16,873 DEBUG [org.apache.catalina.authenticator.AuthenticatorBase] (http-127.0.0.1-8080-1) Failed authenticate() test ??/JAASFormAuth/client/j_security_check
2009-07-18 06:57:49,443 DEBUG [org.apache.catalina.session.ManagerBase] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Start expire sessions StandardManager at 1247925469443 sessioncount 0
2009-07-18 06:57:49,443 DEBUG [org.apache.catalina.session.ManagerBase] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) End expire sessions StandardManager processingTime 0 expired sessions: 0
2009-07-18 06:57:49,443 DEBUG [org.apache.catalina.session.ManagerBase] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Start expire sessions StandardManager at 1247925469443 sessioncount 0
2009-07-18 06:57:49,443 DEBUG [org.apache.catalina.session.ManagerBase] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) End expire sessions StandardManager processingTime 0 expired sessions: 0
2009-07-18 06:57:49,443 DEBUG [org.apache.catalina.session.ManagerBase] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Start expire sessions StandardManager at 1247925469443 sessioncount 0
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4244472#4244472
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4244472
17 years
[EJB 3.0] - Re: ant failed.
by samwan809
I read through Ant Documentation, and come up wtih the followoing solution:
| <target name="compile-test">
| <javac srcdir="${tst-dir}"
| verbose="${TALK}"
| includes="/usr/liferay-portal-5.2.3/dev/portlets/calling_card_reg/docroot/WEB-INF/src/com/ip6networks/calling_card_registration/struts/action/*.java"
| >
| <classpath refid="classpath.test"/>
| </javac>
| </target>
|
| <target name="test" depends="compile-test">
| <junit>
| <classpath refid="classpath.test" />
| <formatter type="brief" usefile="false" />
| <test name="com.ip6networks.calling_card_registration.test.Client" />
| </junit>
| </target>
|
| <target name="clean-compile-test">
| <delete verbose="${TALK}">
| <fileset dir="${tst-dir}" includes="**/*.class" />
| </delete>
| </target>
| <target name="clean-test" depends="clean-compile-test" />
|
But I got the following error again:
| calling_card_reg # ant test
| Buildfile: build.xml
|
| compile-test:
|
| test:
| [junit] Testsuite: com.ip6networks.calling_card_registration.test.Client
| [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
| [junit]
| [junit] Null Test: Caused an ERROR
| [junit] com.ip6networks.calling_card_registration.test.Client
| [junit] java.lang.ClassNotFoundException: com.ip6networks.calling_card_registration.test.Client
| [junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
| [junit] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
| [junit] at java.lang.Class.forName0(Native Method)
| [junit] at java.lang.Class.forName(Class.java:247)
| [junit]
| [junit]
| [junit] Test com.ip6networks.calling_card_registration.test.Client FAILED
|
| BUILD SUCCESSFUL
| Total time: 1 second
|
|
Thanks
Sam,
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4244471#4244471
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4244471
17 years
[EJB 3.0] - Transaction drives me crazy
by mamato
Hi,
let me explain my problem.
I've a little sample application with a servlet, calling a stateless session bean on jboss 5.0.1
The method on the session bean just tryes to persist an entity bean into the DB (mySQL)
All that i wanna do is to be able to manage the transaction by myself.
I mean if something happens the transaction has to be committed, else, rolled back.
I've tryed everithing but the results are:
- if I join the transaction the record is written in any case
- if I don't join the record is not written also il I commit the transaction
I've read a lot around and the code is:
@Stateless(name="WebFacadeBean")
@TransactionManagement(TransactionManagementType.BEAN)
public class WebFacadeBean implements WebFacadeBeanRemote, WebFacadeBeanLocal {
private EntityManager manager;
// BMT idiom
@Resource public UserTransaction userTransaction;
@PersistenceUnit public EntityManagerFactory entityManagerFactory;
public void method() {
try {
manager = entityManagerFactory.createEntityManager();
userTransaction.begin();
manager.joinTransaction();
Ricarica ricarica = new Ricarica();
manager.merge(ricarica);
boolean doTheJob = true
if(!doTheJob)
throw new Exception("Do rollback");
manager.flush();
userTransaction.commit();
} catch (Exception e) {
try {
userTransaction.rollback();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// TODO Auto-generated catch block
e.printStackTrace();
}
....
PLEASE HELP !!
Thanks a lot.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4244470#4244470
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4244470
17 years
[Installation, Configuration & DEPLOYMENT] - Re: Unauthenticated caller null N sqlException
by ravirachannavar
Hi Peter
Hey........it worked....:-)
No error messages.....Only I made changes in the db2-ds.xml(bold letters). This is my xml file
-------------------
<?xml version="1.0" encoding="UTF-8"?>
<!-- ===================================================================== -->
<!-- -->
<!-- JBoss Server Configuration -->
<!-- -->
<!-- ===================================================================== -->
<!-- See http://www.jboss.org/community/wiki/Multiple1PC for information about local-tx-datasource -->
<!-- $Id: db2-ds.xml 88948 2009-05-15 14:09:08Z jesper.pedersen $ -->
<local-tx-datasource>
<jndi-name>V320MCLDEV</jndi-name>
<connection-url>jdbc:db2://172.20.1.196:50000:V320MCLDEV</connection-url>
<!-- DB2 Universal Driver Note connection URL is in form of
jdbc:db2://host:port:dbname
Default port for Type 4 driver is 50000
Note, host and port must be specified if using Type 4 driver. And be forewarned, no native
XA support is provided with Type 4; you must set a DB property calling for Type 2 to get XA
<driver-class>com.ibm.db2.jcc.DB2Driver</driver-class>
<connection-url>jdbc:db2://[hostname]:[port]/databasename"</connection-url>
Please see http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0512kokkat/
or the DB2 JDBC application developers manual.
-->
<driver-class>com.ibm.db2.jcc.DB2Driver</driver-class>
<user-name>Mydb2username</user-name>
Password
<min-pool-size>0</min-pool-size>
<!-- New org.jboss.resource.adapter.jdbc.vendor.DB2ExceptionSorter
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.DB2ExceptionSorter</exception-sorter-class-name>
-->
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
-->
<!-- sql to call on an existing pooled connection when it is obtained from pool
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
-->
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<type-mapping>DB2</type-mapping>
</local-tx-datasource>
----------------------------------------------------------
and I want to check for the deployment...I have deploy.ear folder in the server/default/deploy/ which has ear(jar+war).
1. shall I place one jsp file in ear and restart the server ?and I should get it wen I give the appropriate url. Is it how I should check for the deployment..?
2. changes in the db2.ds.xml are enough to connect to db2 database
or any other changes have to be done..?
Peter...Please help...
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4244469#4244469
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4244469
17 years
[JBoss Messaging] - Re:
by timfox
It's very difficult for us to give a recommendation since we're not familiar with your business or architecture, and there's rarely a "one size fits all" solution.
But I'll try to give some pointers, if you're sending messages from web requests into an application in the same app server instance then using the JCA managed connection factory is the recommended approach (java:/JmsXA) and will give you the pooling you need. The overhead of this shouldn't be too high for sending messages.
Do you need MDBs? Well that really depends on whether you also need to persist the row to a database in the same transaction. Doing this in an MDB allows you to use JTA to do the message delivery and insert of row in the same global transaction. Of course this comes at an overhead.
If you can design out the insert into the DB that will give you your biggest performance boost, since then you can just use a standard JMS consumer and you can avoid JTA too. But as we've discussed before I'm not sure that's possible for you.
To demonstrate the overhead of all this stuff, try creating a simple program that uses raw JMS to send and consume from a queue. No JTA, MDB, JCA, Spring or anything else. And compare the performance.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4244463#4244463
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4244463
17 years