• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Context and root different

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm back with my question since I installed the new JForum version (and found time to do it).

But now, I have a question, more technical.

I want this :

CONTEXT_ROOT/WEB-INF/
CONTEXT_ROOT/forum/images/
CONTEXT_ROOT/forum/install/
CONTEXT_ROOT/forum/template/
...
CONTEXT_ROOT/forum/index.html

So, I want, in my current personal context (web site) only one dir named forum (or whatever I want) for all the "non-system" files/dir but I want to still use the existed WEB-INF/classes and WEB-INF/lib.

In the source I found you get the AppPath using the context :



Because appPath is used to refer to WEB-INF and /install, /template, ... dir, I cannot just modify the value without breaking the code.

Is there a simple solution to do that in the code or not?

I started to add a property in SystemGlobals.properties


But now I have to modify the code to use it. I was able to load the object SystemGlobals with the root.path but because I don't know the impact, I don't want to replace something in the wrong way.

Is it simply possible?

Thanks Raf.
[originally posted on jforum.net by Blackwings]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a patch sent by another user to do this, but I didn't applied it so far, as the patch needs some improvement. I'm not sure If I'll include it in version 2.1.5, but I'll try at least.

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Blackwings wrote:Hi,
...
I want this :

CONTEXT_ROOT/WEB-INF/
CONTEXT_ROOT/forum/images/
CONTEXT_ROOT/forum/install/
CONTEXT_ROOT/forum/template/
...
CONTEXT_ROOT/forum/index.html

So, I want, in my current personal context (web site) only one dir named forum (or whatever I want) for all the "non-system" files/dir but I want to still use the existed WEB-INF/classes and WEB-INF/lib.
...



That means that if you mix two applications that use the same libraries with conflicting versions you will run quite easily into trouble. You will also have to tweak the one-and-only web.xml file for all your applications by hand, mixing the contents from all of the apps into one.

I understand the rationale behind that decission, just so you know you have to be extra-careful and that it does not scale too well


[originally posted on jforum.net by GreenEyed]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Rafael, I understand why it's not possible in the current version but I think that a forum should be a part of an existing website and not a web site itself. But sometime a forum is really the website itself. It's why I suggested to allow user to have the choice about the integration.

I know also that if I want to use the forum independently from my own website, I will just need to create a new context and make a link to the forum homepage... but since hosting a java website is not so easy than hosting a php website, because of the number of provider and the price, it's less expansive to have it in the same context without interfer with the existing context, if I don't want ot use my personal PC as a server.

I will try to adapt the code like that :
1- appPath will be hardcoded with a level more appPath + "/forum" for example.
2- All hardcoded path pointing to WEB-INF will be hardcoded to "/../WEB-INF".

I don't know if it will work... If yes, it will be in 3 files but it will not be "clean". Rought solution but faster than review the model completely.

Do you have somewhere a analysis or a design of the JForum project in UML? It will be easier to understand well how it works, especially when we want to modify thnkgs like I want to do ;)

@GreenEyed : It's not difficult to merge 2 web.xml especially when they have their own servlet name and mapping extension. We just have to copy-paste the forum block into the web.xml file and add comment to be able to retrieve them in case we want to delete the forum.

For WEB-INF/lib, it's easier because you just have to put .jar and the only problem will append if you use different version of the same api. By default, it's better to stay up-to-date with the API version ;-)


[originally posted on jforum.net by Blackwings]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Blackwings wrote:@GreenEyed : It's not difficult to merge 2 web.xml especially when they have their own servlet name and mapping extension. We just have to copy-paste the forum block into the web.xml file and add comment to be able to retrieve them in case we want to delete the forum.



Hey, don't get me wrong ;) I did not say it cannot be done. I just say that it is not scalable, which is not, and that it can lead to subtle problems later on when modifications are added.

Blackwings wrote:For WEB-INF/lib, it's easier because you just have to put .jar and the only problem will append if you use different version of the same api. By default, it's better to stay up-to-date with the API version ;-)



Well, that's precisely the not-so-easy part. You just need to have 2 applications that use different and incompatible versions of log4j or commons-logging, to name some popular ones, and you are screwed. Conflicting XML parsers are usually also a major headache of compatibility problems.
And upgrading to the latest version is not that easy, specially if you are not the author or the author simply has better things to do than keep up-to-date with all the libraries that are there.

But again, not that it cannot be done. But it does not scale well when having more than a few applications.

In my case, my hosting provider gives me a main context but it also allows me to create subcontexts through the tomcat admin panel, so you can create special contexts for conflicting applications. It eats up more space, as jar files are usually the big files, but it's the way to go when you have unsolvable incompatibilities. :roll:


PD: BTW, not only will you have to modify web.xml and add libraries in WEB-INF/lib, but you will also have to merge all configuration files that are present in more than one application and are loaded through the classpath, like log4j do, or hibernate, or proxool... That, or modify the source code of each application and modify the loading mechanism.
[originally posted on jforum.net by GreenEyed]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the current version of jforum, it's very very complex to modify access to all the other dir ;)
You have to touch many many things and you will not be able to be sure that it'll not fail one day for specific action...
For WEB-INF, I just have to touch 4 files, it's ugly because I put a /../ in front ops: the WEB-INF hardocded String.

I had another problem to launch normally the install so I was not able to test my modification for now.

Anyway, in my case, I'm on webappcabaret.net and I have one domain and 3 or 5 sub-domain... but they share the same WEB-INF because it's the same context... no other context for me
I always thought a subdomain is another entrey point of the same context.

I cannot have, I think :
http://forum.mysite.com pointing on http://www.mysite.com/forum with a /forum/WEB-INF/ directory inside and have at the same time antoher WEB-INF directory in the root... :?:


[originally posted on jforum.net by Blackwings]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
LOL

Ok, I had the confirmation and we can have in the same structure /site/WEB-INF and /site/forum/WEB-INF and have 1 context on /site and another context or sub-context on /site/forum....

I learn something, thanks a lot

I don't have any problem anymore because I will be able to create my /forum dir in me /site dir and setup a second context ;)
[originally posted on jforum.net by Blackwings]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great news!

That will be easier to do.
[originally posted on jforum.net by GreenEyed]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perfect ... thanks for the helpful post. I'm reading up on virtual hosts now!

It's been a bit of a bear at times with Apache + Tomcat. I'm thinking of just using straight Tomcat as I don't believe I really need Apache.

Mark
[originally posted on jforum.net by conquest]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you guys give the details on multiple contexts? I'd love to just copy the jforum install under my existing webapp. That would make maintenance easier.

Perhaps an example of the necessary xml file changes.

Thanks!


[originally posted on jforum.net by conquest]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to add JForum to an existing context, just copy the files to the root directory, and merge the WEB-INF/web.xml file.
That's all

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I approach integrating jforum into existing app by simply creating a virtual host in tomcat with multiple contexts. I don't use the tomcat webapp folder - just install the /manager app context in the virtual host:
1. your app at context /
2. forum at context /forum
3. manager at context /manager (only allow LAN access)

then I use SSO for sign-on if required by the 'root' application. I find this approach very flexible and easy to manage.

JForum rocks!


[originally posted on jforum.net by MrNice]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rafael,

I was just trying to avoid the merging and copying of files. Currently my deploy ant script is pretty clean and it would be nice to just have jforum installed in another context as I continually redeploy. I'm currently still in a bit of a development phase.

Also I assume that the virtual host allows me to share the http session among webapps.

I'll show my integration here soon.

Thanks!
Mark
[originally posted on jforum.net by conquest]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stick with MrNice's suggestions - that's the way J2EE containers are supposed to do it (rtfm).
[originally posted on jforum.net by Anonymous]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi conquest,

each context will have its own session. There are a couple of ways to access session data from different contexts. Have a google.

I find that, for most of my requirements at least, setting up the datasources at the virtual host level (i.e. not context) allows simple cross-context database access.

your mileage may vary

-Mark.


[originally posted on jforum.net by Anonymous]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
^^^ that was me btw

-Mark.
[originally posted on jforum.net by MrNice]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
agree - i would drop apache if I wasn't using lots of url rewriting, but for now I just pump all requests straight through mod_jk.

Perfect ... thanks for the helpful post. I'm reading up on virtual hosts now!


So when do I get my karma then :P

-Mark.
[originally posted on jforum.net by Anonymous]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I considered integrating JForum into my webapp and finally concluded that it was not a good choice for many reasons.

Instead, I opted for a loose coupling of the two webapps. I disabled registration and login and logout in JForum. My webapp handles the jforum_users insertion inside my own registration code. Further, my webapp's login code automatically logs the user into the JForum webapp. See my posting here: https://coderanch.com/t/575679 The source code is included about half way down the posting.

With my code handling the user registration, login and logout, JForum appears to be an integral part of my webapp to the user (except for the entirely different layout and style, which I mitigate with a few well placed logos).

I have found this solution to be very solid.

[originally posted on jforum.net by time]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I can see "integrating" jforum into any app is basically SSO, and jforum has easy to do SSO (create one class).

I think the auto-login is cool though - you use the admin control panel to see who's logged from where etc - save writing your own usere monitor
[originally posted on jforum.net by Anonymous]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anonymous wrote:

So when do I get my karma then :P

-Mark.



Dude ... you're anonymous :-) Ok kidding this is Mr Nice??

Ok so it looks like I can just use SSOUtils.register() when a user registers in my webapp.

I don't know why I'm having a hard time with this ... but when I implement authenticateUser() is it to look something like this:

public String authenticateUser(ActionServletRequest request)
{

SSOUtils.userExists(username, password);
User user = SSOUtils.getUser();
return user.getUsername();
}

I don't see how JForum identifies this person and will show their name, etc on posts.

Would I also need to set these attributes as part of the login as well?

session.setAttribute("sso.password.attribute", "a secret");
session.setAttribute("sso.email.attribute", "user@email.com");


[originally posted on jforum.net by conquest]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
should mention that when authentication.type=sso all jforum user login/register/password retreival stuff disappears automatically.

logging into the forum automatically when logging into my app

should read logging in at same time.

the way it works with SSO enabled is that a user will only be registered once when they first visit the forum and just logged in thereafter.

-Mark.



[originally posted on jforum.net by Anonymous]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
first off, if you use JAAS (or similar) the user generally does HTTP authentication in your app (like tomcat mannager/admin apps) and so the default authenticator net.jforum.sso.RemoteUserSSO.java will work fine and you wont have to code anything. However, in the forum logs you wlil see a log message every time you make a request, something like "INFO: session has been removed". this needs to be fixed by changing the last return statement to return true.

In my case, cos I couldn't find an easy way to do auto-login via cookie with HTTP authentication and had already written my own stuff, I created net.forum.sso.MyUserSSO.java (implenting SSO of course).

i imported my apps database and security classes, which i jar'd up and stuck in JForum classpath (WEB-INF/lib).

my authenticateUser() checks for a cookie, if it exists i then create a user object based on cookie value. by importing your own database/security library coding is simple. cos i use email for login name i returned my screenname for the username.


isSessionValid() will also need to be altered, i did cookie and user stuff like above then

then do the session state checks as per net.jforum.sso.RemoteUserSSO.java (not forgetting to return true at end).

the SSOUtils are helpers for net.jforum.ControllerUtils.java - checkSSO() does the email/password session attributes passing and jforum user auto-regististration.

in net.jforum.view.forum.common.ViewCommon.java update the contextToLogin() method if needed - the redirect is for when un-authenticated users try to access restricted jforum page. i added an error message and URLencoded the return page cos request parameters were going missing. i also dropped the getContext() guff cos i run my app and jforum on different contexts..



make sure the related stuff is sane in SystemGlobals.properties
authentication.type=sso
sso.implementation = net.jforum.sso.MyUserSSO
sso.password.attribute = password
sso.email.attribute = email
sso.redirect = http://mysite.com/login.jsp

and bob continues to be my uncle. I'm gonna have a closer look a Time's solution though cos I like the idea of logging into the forum automatically when logging into my app, and you probably wouldn't wan't to do this on a very large site cos of the database lookup overhead during isSessionValid() method, although using tomcat connection pool I don't see any impact so far.

now about that last star.... :lol:
[originally posted on jforum.net by MrNice]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mr Nice .... great stuff thanks so much! I'm actually using SecurityFilter because JAAS doesn't give me enough control. Especially if I want to register a user then auto log them in.

I'm still trying to wrap my head around this so bare with me ...

My concern is (as with Time) is that I want the user logged in from the first page they hit.

I do see that checkSSO(UserSession userSession) will do an automatic registration and log the user in based on the sso username/password. But apparently this isn't enough due to the way sessions work especially if I'm cross-context like he is. Plus it should work in all containers.

I think I'll be adding his code to my webapp here shortly .... I'll keep everyone posted!


[originally posted on jforum.net by conquest]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i agree with the login at same time as host site - i would like it too, but the way i've done here is from what i read up on the wiki and i wasn't too fussed about my users joining fourm. but, now think prehaps its more important and i also like to use the admin panel for poor-mans user monitoring

-Mark.




[originally posted on jforum.net by Anonymuos]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok - i just put the following in my site footer


ta da... it's so easy man!


[originally posted on jforum.net by Anonymous]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
^^^ tis bollox - too many open browsers blah blah blah ops:

i'll have a nap.
[originally posted on jforum.net by Anonymous]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic