Jforum Integration with a Spring and JSF WebApplication
I am working on a web application, in which forum feature has to be integrated. Jforum was chosen to integrate. Jforum is an open source forum implementation in Java (http://www.jforum.net ).
My Application is a spring / JSF application using mysql Db.Jforum has separate user tables and separate authentication mechanism. For integration it provides Single Sign on Facility and easy configuration. By turning ‘Single sign on’ facility on, the login and registration screens on Jforum will get disabled. The jforum searches for special attributes in session for logged user information and if the user is not present in its table it will automatically create one.All the authentication details will be handled by my application. Also I wanted to keep jforum tables in same db.
The initial decision to take whether to keep Jforum code in my application or to keep it as a separate application. JForum has its own front end, which is implemented using templates, different db configuration files and different style. Jforum administration also had to be accessible to our administration screens easily.
I decided to keep the forum code separate and not to make our application code clumsy. But I faced lot of problems during configuration. So I decided to integrate the code it to same application. Following are steps I followed to do so.
1. Download jforum-2.1.8 zip from http://www.jforum.net/download.jsp
2. Rename directory as JFroum and deploy it (copied it to webapp of tomcat) as a separate application initially (this is only to install database.)
3. I installed forum tables in same db as of m application. If you want to keep them separate, create desired database in mysql using sql command:
Create database db_name
4. run tomcat and access following url:
http://localhost/JForum/install.jsp
Enter following:
DataBaseType: Mysql
Installation Type: New Installation
Connection Type: JDBC – leave this default not required
Dadasource Name: <blank>
Database Server Hostname : <mysql server name>
Database Port : 3306
Database name : db name – This database should exist
Database Username:<username>
Database Password: <password>
Use Connection Pool: leave this to default –
Forum Link: link to the forum: http://localhost/JForum/
Website Link: this should point to the home page of your application. This is the only point in jforum to return to our application. Depending on this, link ‘back to homepage’ on jforum will work.
Administrator Username : <jforum admin username> – make sure this username is same as your App super admini username – it helps to load admin console.
Administrator Password : <jforum admin password>
Click next step à begin install. Tables will be created in skill guru database.
You can now access jforum at: http://localhost/skillForum/forums/list.page
5. Now you have the database table installed. It’s weird… but I did above steps only to install the db tables. Now I am going to have jforum code into my application. This gives me more control over forum.
6. Now stop tomcat.
7. copy all jars from deployed jforum/web-inf/lib to yourApp/ WEB-INF/lib directory
8. copy config directory from deployed jforum/web-inf/config to your WEB-INF/ directory (The db setting will be in Webroot/WEB-INF/config/database/mysql/mysql.properties file)
9. Copy jforum/template directory to your Webroot directory.
10. Implementing SSO:
You will have to set ‘myAppUser’ (or any other as you wish) session attribute to logged username after logging in.
Create a separate SSO class in your application.
package com.myapp.forum;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
public class MyAppSSO implements SSO{
public String authenticateUser(RequestContext request) {
String user = (String)request.getSessionContext().getAttribute(“myAppUser”);
return user;
}
public boolean isSessionValid(UserSession userSession, RequestContext request) {
if(request.getSessionContext().getAttribute(“myAppUser”) != null)
{
return true;
}else{
return false;
}
}
}
The authenticateUser method will be called when you access Jforum pages first time to get logged in user and isSessionValid will be called by Jforum to check session frequently.
The session attribute setting is important here. When SSO is on, and any page of Jforum is accessed first time for that session, the authenticateUser() method will be called to check the logged user. If it returns null, then the user will be treated as ‘Anonymous’. If it returns a username, this will be verified against the jforum_users table’s usernames. If there is no username exists, then a new row will be inserted into the jforum’s users table with username = one found in session and user will be marked as logged in.
open skillForum/WEB-INF/config/ SystemGlobals.properties
change following properties:
authentication.type = sso
sso.implementation = com.myapp.forum.MyAppSSO
12. Web.xml changes:
We’ll need to integrate web.xml file .
Make sure you have following in appropriate places in you web.xml file:
<filter>
<filter-name>clickstream-jforum</filter-name>
<filter-class>
net.jforum.util.legacy.clickstream.ClickstreamFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>clickstream-jforum</filter-name>
<url-pattern>*.page123</url-pattern>
</filter-mapping>
<listener>
<listener-class>net.jforum.ForumSessionListener</listener-class>
</listener>
<!– ******* –>
<servlet>
<servlet-name>jforum</servlet-name>
<servlet-class>net.jforum.JForum</servlet-class>
<init-param>
<param-name>development</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>jforum</servlet-name>
<url-pattern>*.page</url-pattern>
</servlet-mapping>
create a link in your application to point to the url:
http://yourApp/forums/list.page
14. undeploy old Jforum application.
Take a deep breath and restart the tomcat server.
Now you can access jforum from your application.
You can also access jforum admin console using url:
http://localhost:portno/admBase/login.page
(provided you have the super admin username and jforum admin user name same and its in session)
In next session I’ll describe how I implemented logout and made Jforum to use same db pool as spring.
Related Post :
Spring Application and Jforum Integration – Sharing same c3p pool









Any idea about integrating Junit with Struts2 application.i have done the basic steps,it lists the test forums but i cant make any new post/reply it throws
java.lang.RuntimeException: Unable to load bean org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) – [unknown location]
com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:136)
it seems struts2 upload interceptor is got called when making new posts/reply.
How to get rid of this? Any idea?
@Smitha
Hi Smitha,
Sorry I forgot to say that I did copied 3 jar files.Because of that jar files My application is not getting deployed. I am using JBOSS server 4.2 and JBOSS seam 3.1 .I am getting an classcast exception
Exception sending context initialized event to listener instance of class org.jboss.web.jsf.integration.config.JBossJSFConfigureListener
java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl cannot be cast to javax.xml.parsers.SAXParserFactory
at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:128)
at com.sun.faces.config.ConfigureListener$WebXmlProcessor.getConfiguredFactory(ConfigureListener.java:2048)
at com.sun.faces.config.ConfigureListener$WebXmlProcessor.scanForFacesServlet(ConfigureListener.java:2022)
at com.sun.faces.config.ConfigureListener$WebXmlProcessor.(ConfigureListener.java:1996)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:244)
at org.jboss.web.jsf.integration.config.JBossJSFConfigureListener.contextInitialized(JBossJSFConfigureListener.java:69)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)
at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
at org.jboss.web.WebModule.startModule(WebModule.java:83)
at org.jboss.web.WebModule.startService(WebModule.java:61)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
at $Proxy0.start(Unknown Source)..more
Those 3 jars are :-
1)xml-apis
2)xmlrpc
3)xercesImpl
Thanks & Regards,
Vamsi
@Smitha
Hi Smitha,
There is no problem in web.xml. These is occurring when i am trying to calll any action, like posting private messages to other users , updating the profile etc. I can able to login by using SSO and the users are getting created on fly. The problem is that, to the backed end the module name and action getting null when ever I call any action but links are working fine. I came to know by debugging the code.
Like in the code when ever module name is null they are sending 404 server response.
Thanks & Regards
Vamsi
Hi Guys
It all looks good apart from the fact that on most systems UserNames can be changed, UserIds cannot…
What would happen if a user changed their UserName. At some point the matching UserNames would be out of sync. A problem me thinks.
Maybe this could be done using the UserIds on both systems…
Any thoughts on this would be welcome.
Regards
Lyndon
@Vamsi
It looks like there is problem in web.xml. The .pages url is not mapped properly. Can you check it once? Also is there any error messages in log?
Hi All,
I configured JForum into my application, but i am facing problem
when ever clicking on submit button getting 404 file not found exception can any one please help me
http://localhost:portno/myapp/jforum.page not found this is the url which i am getting
thanks in advance .
Thanks & Regards,
Vamsi
Great tutorial, but you missed 1 thing – we have to copy the Web-Inf/classes folder to our Web-Inf too.
THx, helped me alot.
It is not that much good you want to improve.Try next time better luck
This is certainly the best that I read today in the Internet
Now you can get free mp3 music downloads from http://www.jagmp3.net. There are millions of songs you can download all for free!