[Persistence, JBoss/CMP, Hibernate, Database] - relationships in jbosscmp-jdbc.xml
by paoletto
so, i have this doubt about sematics of fields in jbosscmp-jdbc.
example taken from a working project:
| <ejb-relation>
| <ejb-relation-name>Students-Groups</ejb-relation-name>
|
| <foreign-key-mapping/>
|
| <ejb-relationship-role>
| <ejb-relationship-role-name>Student-belongs-to-group</ejb-relationship-role-name>
| <key-fields/>
|
| </ejb-relationship-role>
| <ejb-relationship-role>
| <ejb-relationship-role-name>Group-has-students</ejb-relationship-role-name>
| <key-fields>
| <key-field>
| <field-name>id</field-name>
| <column-name>refGroup</column-name>
| </key-field>
| </key-fields>
|
| </ejb-relationship-role>
| </ejb-relation>
|
ok. i had a look in the code and id is a CMP field of entity "group" and "refGroup" is a field of entity and table students.
now what i was wondering:
ok, i desume that this key-field block is used to express a foreign key, where field name is the local cmp field mapped above in the file, and column name is the foreign column in the other table, stated this time in ejb-jar.xml relations block.
is this correct? i ask because in the .dtd file it is not explained well, and it seems that usually <column-name> is the actual column name in the db of <field-name>, so it's not so obvious that things are how im figuring out
thanks for any explaination
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4052476#4052476
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4052476
18Â years, 10Â months
[JBossWS] - Problem with exceptions
by sashaxiv
i am running jboss 4.2 with jbossws. I have two service methods. they work fine if i don't declare the exceptions throwed by them.
if i add exceptions to the methods, when i execute the client side it askes my
for the the exceptions throwed but with the sufix "bean" and it crashes because the client can't find the classes with that prefix.
What can i do?
| Exception in thread "Thread-39" class: com.satdatatelecom.satdataweb.model.session.session.jaxws.PalabraProhibidaExceptionBean could not be found
| at com.sun.xml.internal.ws.modeler.RuntimeModeler.getClass(Unknown Source)
| at com.sun.xml.internal.ws.modeler.RuntimeModeler.processExceptions(Unknown Source)
| at com.sun.xml.internal.ws.modeler.RuntimeModeler.processRpcMethod(Unknown Source)
| at com.sun.xml.internal.ws.modeler.RuntimeModeler.processMethod(Unknown Source)
| at com.sun.xml.internal.ws.modeler.RuntimeModeler.processClass(Unknown Source)
| at com.sun.xml.internal.ws.modeler.RuntimeModeler.buildRuntimeModel(Unknown Source)
| at com.sun.xml.internal.ws.client.ServiceContextBuilder.processAnnotations(Unknown Source)
| at com.sun.xml.internal.ws.client.ServiceContextBuilder.completeServiceContext(Unknown Source)
| at com.sun.xml.internal.ws.client.WSServiceDelegate.processServiceContext(Unknown Source)
| at com.sun.xml.internal.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(Unknown Source)
| at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(Unknown Source)
| at javax.xml.ws.Service.getPort(Unknown Source)
| at com.satdatatelecom.satdataweb.gui.login.DoLogin.doLogin(DoLogin.java:212)
| at com.satdatatelecom.satdataweb.gui.login.thread.LoginThread.run(LoginThread.java:90)
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4052475#4052475
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4052475
18Â years, 10Â months
[JBoss Portal] - Custom Login Module Issues.
by rob_blake
Hi folks,
I've been trying to add a custom login module for Jboss Portal so that we can authenticate our users against a datasource accessible via a web service. I'm having a few issues getting this to work and any pointers would be helpful
Firstly:
Portal 2.6
Jboss AS 4.05 GA
The approach I have taken is to extend the IdentityLoginModule and override the initialize(), getRoleSets() and validatePasswords() method.
The relevant code sections are included below:
public void initialize(Subject subject,CallbackHandler handler,Map sharedState,Map options)
{
super.initialize(subject,handler,sharedState,options);
this.additionalRole = (String)options.get("additionalRole");
this.hashAlgorithm = (String)options.get("hashAlgorithm");
this.hashEncoding = (String)options.get("hashEncoding");
this.hashCharset = (String)options.get("hashCharset");
this.userModuleJNDIName = (String)options.get("userModuleJNDIName");
this.roleModuleJNDIName = (String)options.get("roleModuleJNDIName");
this.userProfileModuleJNDIName = (String)options.get("userProfileModuleJNDIName");
this.membershipModuleJNDIName = (String)options.get("membershipModuleJNDIName");
if(options.containsKey("ignorePasswordCase"))
{
this.ignorePasswordCase = ((String)options.get("ignorePasswordCase")).equalsIgnoreCase("true");
}
this.endpoint = (String)options.get("serviceEndPoint");
this.wsdlLocation = (String)options.get("serviceWSDL");
this.namespace = (String)options.get("serviceNamespace");
}
The initialize method calls the super.initialize(), and then simply stores values of our jndi services for Portal User/Role/Membership creation and also the endpoints of of WS.
protected Group[] getRoleSets() throws LoginException
{
Group rolesGroup = new SimpleGroup("Roles");
rolesGroup.addMember(createIdentity("Authenticated"));
rolesGroup.addMember(createIdentity("Users"));
return new Group[]{rolesGroup};
}
public Principal createIdentity(String username)
{
return new UserPrincipal(username);
}
The getRoleSets() method is hardcoded to return the roles of Users and Authenticated which is fine for our needs.
Finally I have the overridden validatePassword() method. At the minute the password verification simply returns true so that I can get this thing working (it will of course verify the given password against that returned by the WS call). The user is then added to the portal user database by making use of UserModule, RoleModule and MembershipModule respectively if they do not already have a portal db presence.
protected boolean validatePassword(String password,String expectedPassword)
{
if(!this.checkPassword(password, expectedPassword))
return false;
// If the user is present in the portal DB, we simply return.
if(this.getUserStatus(password) == UserStatus.OK)
{
return true;
}
try
{
this.addUserToPortalDB(getIdentity().getName(),password);
}
catch(IdentityException e)
{
logger.debug(cn + ".validatePassword() - Cannot add User to Portal Database: " + e.getMessage());
e.printStackTrace();
return false;
}
return true;
}
private boolean checkPassword(String password,String expectedPassword) {
return true;
}
private User addUserToPortalDB(final String username,final String userPass) throws IdentityException
{
try
{
TransactionManager tm = this.getTransactionManager();
return (User)Transactions.required(tm,new Transactions.Runnable()
{
public Object run() throws Exception
{
User user = getUserModule().createUser(username,userPass);
Set roleSet = new HashSet();
if(user.getUserName().equalsIgnoreCase("admin"))
{
roleSet.add(getRoleModule().findRoleByName("Admin"));
}
roleSet.add(getRoleModule().findRoleByName("User"));
getMembershipModule().assignRoles(user,roleSet);
getUserProfileModule().setProperty(user,User.INFO_USER_ENABLED,new Boolean(true));
return user;
}
});
}
catch(NamingException e)
{
logger.info(cn + ".addUserToPortalDB() - NamingException Looking Up UserModule");
throw new IdentityException(e);
}
catch(Exception e)
{
logger.info(cn + ".addUserToPortalDB() - Exception during Transaction");
throw new IdentityException(e);
}
}
I have altered my jboss-portal.sar/conf/login-config.xml to include the following
<login-module code="com.restfurl.portal.jaas.authentication.TraderLoginModule" flag="requisite">
<module-option name="userModuleJNDIName">java:/portal/UserModule</module-option>
<module-option name="roleModuleJNDIName">java:/portal/RoleModule</module-option>
<module-option name="userProfileModuleJNDIName">java:/portal/UserProfileModule</module-option>
<module-option name="membershipModuleJNDIName">java:/portal/MembershipModule</module-option>
<module-option name="additionalRole">Authenticated</module-option>
<module-option name="serviceEndPoint">http://localhost:8080/analystServices/analyst</module-option>
<module-option name="serviceWSDL">http://localhost:8080/analystServices/analyst?wsdl</module-option>
<module-option name="serviceNamespace">com.restfurl.portal.services.namespaces</module-option>
<module-option name="ignorePasswordCase">true</module-option>
<module-option name="password-stacking">useFirstPass</module-option>
</login-module>
<login-module code="org.jboss.portal.identity.auth.IdentityLoginModule" flag="required">
<module-option name="unauthenticatedIdentity">guest</module-option>
<module-option name="userModuleJNDIName">java:/portal/UserModule</module-option>
<module-option name="roleModuleJNDIName">java:/portal/RoleModule</module-option>
<module-option name="userProfileModuleJNDIName">java:/portal/UserProfileModule</module-option>
<module-option name="membershipModuleJNDIName">java:/portal/MembershipModule</module-option>
<module-option name="additionalRole">Authenticated</module-option>
<module-option name="password-stacking">useFirstPass</module-option>
</login-module>
The code for my LoginModule is packaged as a .jar file and I have this included in jboss-portal.sar/lib. Is this the correct place for the .jar?
When attempting to use my LoginModule, the only output I receive on the login.jsp is "null". I do not seem to get any errors on system output or any exceptions.
If anyone can offer any suggestions, it would be mighty appreciated.
cheers
Rob
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4052473#4052473
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4052473
18Â years, 10Â months
[JBoss Seam] - Timer not starting from method with @Create annotation.
by maniappan
I try to start a timer with one minute interval using @Asynchronous annotation. when I schedule this timer from within any method in my application it seems to work properly. However when I try to invoke it from a @Create annotated method during startup the timer is not getting set, I see this error in the log.
| 2007-06-08 14:36:26,756 ERROR [org.jboss.ejb.txtimer.TimerImpl] Error invoking ejbTimeout: javax.ejb.EJBException: java.lang.NullPointerException:
| 2007-06-08 14:36:26,756 DEBUG [org.jboss.ejb.txtimer.TimerImpl] Timer was not registered with Tx, resetting state: [id=4,target=[target=jboss.j2ee:service=EJB3,ear=myapp.ear,jar=jboss-seam.jar,name=Dispatcher],remaining=-1048568,periode=60000,in_timeout]
|
Here is the code snippet where I invoke the timer..
| @Startup
| @Entity
| @Local
| @Table(name="myapp_schedule")
| @Stateful
| @Scope(ScopeType.APPLICATION)
| @Name("myappSchedule")
| public class MyappSchedule
| implements Serializable, MyappScheduleInterface
| {
| -- Setters/Getters for all fields in the table..
| @Create
| public void startScheduler() {
| log.info("Entering create now to start the schdeuler");
| try{Thread t = new Thread();
| t.sleep(10000);}
| catch(Exception e){}
| try {
| MyappScheduleController ysh = (MyappScheduleController) Component.getInstance("myappScheduleHome");
| ysh.saveAndSchedule();
| } catch (Exception e) {
| System.out.println("Got the exception while starting time "+e.toString());
| }
| }
|
| @Destroy @Remove
| public void dummy() {}
| }
|
When I invoke the saveAndSchedule() from any other method from application it works properly, not in the case above..
Any ideas on where could be the issue?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4052463#4052463
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4052463
18Â years, 10Â months