Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JForum and the fly likes Build phpbb2JForum from source? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » JForum
Bookmark "Build phpbb2JForum from source?" Watch "Build phpbb2JForum from source?" New topic
Author

Build phpbb2JForum from source?

Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Hi,

I see there is a build.xml file for the main project, but not for the phpbb2JForum tool

How can I build phpbb2JForum from the source code?

Thanks,

R.
[originally posted on jforum.net by robinbowes]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
I've venture a guess that Raphael ever used a build file with this, just compiled it either manually or via Eclipse's build mechanism.

However, adding this to the bottom of main build.xml file should get you close to this. Warning... untested.

Make sure you have good backups of all db's involved in using this as the phpBB DB schema and/or the jforum DB schema may have changed since it was written.


[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
monroe wrote:


Thanks for this.

I've added that section to build.xml and run "ant phpbb2jforum".

I get these errors:



Any idea how to fix this?

R.
[originally posted on jforum.net by robinbowes]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
I should add that the reason I want to build from source is so that I can modify the code to work with the latest versions of phpbb and jforum as I have a client who wants to migrate to jforum from phpbb.

I could write a conversion tool using perl but I thought it would be more beneficial to the jforum community if I modified the existing tool. However, my experience in working with java tools is almost zero so there's a bit of a steep learning curve!!

Thanks,

R.
[originally posted on jforum.net by robinbowes]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Hmm, it looks like there is a missing custom version of the SystemGlobals class that was used to load the required SQL statements and other required properties. I.e., the SystemGlobals.properties and mysql_queries.properties files in the resource directory.

I've done a quick reverse engineering and re-created the modified class.

The attached zip file contains this class (and the other phpbb2jforum classes).

One thing that you might not figure out as a Java novice, the properties files are loaded from the classpath used to run the code. So, you will need to make sure the resources directory is on the classpath.

The easiest way to set up to run this is to do the following:

- Make a run directory.
- copy the phpbb2jforum.bat file from the resources into it.
- make a bin directory under the run directory
- copy the net directory from the WEB-INF\classes directory into the bin directory.
- copy the resource\phpbb2jforum directory to the bin directory.
- copy the WEB-INF\lib directory to the run directory.

The run directory should look sort of like:

phpbb2JForum.bat
bin
bin\net\jforum\*
bin\phbb2jforum\*.properties
lib\*.jar

You will need to figure out the correct settings for info in the *.properties file and make sure that JDBC drivers you need are in the lib directory.

Also, the bat file's -cp setting probably needs to be shortened to just -cp bin;lib; since the JDBC driver, etc, are in the lib directory.

Now you know all that I know about this tool...


[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
monroe wrote:Hmm, it looks like there is a missing custom version of the SystemGlobals class that was used to load the required SQL statements and other required properties. I.e., the SystemGlobals.properties and mysql_queries.properties files in the resource directory.

I've done a quick reverse engineering and re-created the modified class.

The attached zip file contains this class (and the other phpbb2jforum classes).
Thanks for that. It's now building.

- Make a run directory.

Ok
- copy the phpbb2jforum.bat file from the resources into it.

I'm on Linux so am using a shell script, but same principle. OK.
- make a bin directory under the run directory

OK
- copy the net directory from the WEB-INF\classes directory into the bin directory.

I have no net directory under the WEB-INF/classes directory.
After running "ant compile" and "any phpbb2jforum" I have the following net directories:

I copied the one in the build dir.
- copy the resource\phpbb2jforum directory to the bin directory.

Ok
- copy the WEB-INF\lib directory to the run directory.

OK

The run directory should look sort of like:

phpbb2JForum.bat
bin
bin\net\jforum\*
bin\phbb2jforum\*.properties
lib\*.jar

Yup, it does.

You will need to figure out the correct settings for info in the *.properties file and make sure that JDBC drivers you need are in the lib directory.

I've put mysql-connector-java-3.1.2-alpha-bin.jar in the lib dir.

Also, the bat file's -cp setting probably needs to be shortened to just -cp bin;lib; since the JDBC driver, etc, are in the lib directory.

This is the script I'm using to run the tool:


When I run it, I get this error:


Is this something I'm doing wrong, or is there a problem with the SystemGlobals class?

R.
[originally posted on jforum.net by robinbowes]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
The problem is mostly with my assumptions on your source layout and foggy memory on how to run stuff from the command line. (Eclipse and the web app servers make that stuff so easy...)

Ok, about what goes into the directories.

The bin directory should have the compiled java classes (both for the phpbb2jforum tool and the jforum application). These should be in the proper "package" directories. E.g., the SystemGlobals.class file is in the net.jforum.tools.common java package, so it should be in the bin\net\forum\tools\common. (Java looks down it's classpath for the compiled objects it needs).

I assumed the location you're ant script would be building them to, and was wrong. Just look for the SystemGlobals.class file and copy the net directory tree to your bin directory (most likely the build/classes directory).

As to the lib directory, looking more closely at the code (and remembering how to do command line stuff). You should really only need the JDBC driver jar in this.

To get rid of the need for the Log4j stuff, just edit the SystemGlobals.java class (in the tools/common directory) to remove these two line:

line 58: import org.apache.log4j.Logger;

line 81: private final static Logger log = Logger.getLogger(SystemGlobals.class);

FWIW, the log4j stuff is only for debug logging and not used in the code supplied. I think if we kept that in, there are a bunch of other jars that log4j depends on and the classpath starts getting complicated.

Recompile the stuff with the ant phpbb2jforum command and copy the new class file into your bin/net/... directory.

OK, now what I forgot about command line class path stuff is that you have to explicitly include each jar file in the path and can't just point to a directory of jar files.

So, your run script should go back to the way it was originally, with the -cp part looking like:

-cp bin:lib/mysql-connector-java-3.1.2-alpha-bin.jar

This should get you to a point that all the object classes are available to run the code.

For extra credit.. change the "bin" part in your run script to point to the root build directory so that you don't have to copy the class files when you change the code.

FYI - Most java developers will decide on a repository directory for the jars they commonly use (jar's are basically zipped collection of Java objects (like a zipped Perl module lib). Then they do a login script that will create a CLASSPATH variable that contains all the *.jar files in the repository directory. (and include a :. in it).

This makes it easy to do command line stuff by just making the current directory your compile output directory and just running the commands without the -cp part. Or doing a script that appends the current project's compile output directory to the CLASSPATH variable.

And of course, IDE's like Eclipse make life even easier...





[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
monroe wrote:This should get you to a point that all the object classes are available to run the code.

Indeed it does. All seems to be fine, almost...
monroe wrote:For extra credit.. change the "bin" part in your run script to point to the root build directory so that you don't have to copy the class files when you change the code.

As far as I can see, that would mean I'd have to copy the resource\phpbb2jforum directory to the bin directory each time? I've not bothered with this - I can live without the extra credit!

I've written a small shell script to run the build, copy the files and run the program:

(parameters to the run script obfuscated)

This is the output:

This seems to imply it's not loading the SytemGlobals.properties file, but I'm not sure why. Any idea?

I seem to be very nearly there with this - one last push, then I can start work on modifying the code to make the migration work!

R.
[originally posted on jforum.net by robinbowes]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
That error indicates that the code couldn't find the SystemGlobals.properties file. This could be one of two things.

The file may not be in the proper place or it's not capitalized correctly. Here's where it should be in the run directory (tested on WinDoze)



It could also be a bug in the Linux JVM you're using. I seemed to remember that the getResourceAsStream(..) method used might have issues on Linux.

If this is the case, try this modification to the Main.java code:

Change line's 46-47, e.g.



To:


Set the value for the pathToInfo variable to the full directory path of location containing the properties files.


[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
monroe wrote:That error indicates that the code couldn't find the SystemGlobals.properties file. This could be one of two things.

The file may not be in the proper place or it's not capitalized correctly.


Well, I've double checked and it seems OK:



And the contents of phpbb2jforum:



monroe wrote:
It could also be a bug in the Linux JVM you're using. I seemed to remember that the getResourceAsStream(..) method used might have issues on Linux.

If this is the case, try this modification to the Main.java code:

Change line's 46-47, e.g.



To:


Set the value for the pathToInfo variable to the full directory path of location containing the properties files.



I tried that and still get the same error:



Interestingly, if I spell the file name wrong, I get a different error:


That suggests that it is finding the file but that the contents of the file are wrong, i.e. something is missing.

This is the contents of SystemGlobals.properties:

img.replace =

database.driver = com.mysql.jdbc.Driver
database.jforum.url = jdbc:mysql://localhost
database.queries = mysql_queries.sql
dbname = test
dbhost = localhost
dbuser = root
dbpasswd = root
[/code]

This is exactly the same as the SystemGlobals.properties that is distributed with the binary build of the phpbb2jforum tool.

Any further ideas?

BTW, I sent you a PM with my IM contact details in the hope we could chat in real time about this.

Thanks for all your help so far,

R.
[originally posted on jforum.net by robinbowes]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
D'oh! (Smacks head... really looks at error message, rather than line number)...

OK, the line number given in your error message (119) pointed to the defaults.load( properties ) statement, in MY code. I jumped to the conclusion that properties was null and back tracked to it.

But looking closer at the error message, it's actually coming from a 4-5 lines above this... (You're file has some new extra lines mine didn't).

Just comment out the if statement at the top of the buildSystem method. I.e.:



There is no defaultConfig information for this tool.
[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Woohoo!! That did it.

I now get a good old data error - which is fine, as that's what I will be fixing and why I need to be able to build the tool from source!



Thanks again for all your help.

Suggestion: would it be worth fixing all this in CVS so other folk can build the tool from source?

R.
[originally posted on jforum.net by robinbowes]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Follow-up:

When I ran the migration tool, I got the following error:


I noticed that in jforum, the jforum_topics table has a field named "topic_vote_id" instead of "topic_vote".

So, I modified mysql.queries, changing the field name "topic_vote" to "topic_vote_id" in query.topics.

With this one change, the tool successfully ran to completion.

Now, I don't know if the resulting jforum database will be sane but it's a damn good start!

In particular, I suspect that "topic_vote" and "topic_vote_id" might have completely different meanings and it makes no sense at all to migrate one to the other.

Can anyone shed any light on this? Would I be better setting topic_vote_id to '0' or NULL or something?

Thanks again for all your help monroe.

R.
[originally posted on jforum.net by robinbowes]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Since there doesn't seem to be any code to deal with converting phpbb voting tables to jforum voting tables, you probably should set the topic_vote_id to 0.

FYI, the topic_vote_id is a foreign key field that ties the topic to a jforum_vote_desc record. This record is tied to the jforum_vote_results table which contains the options and running totals of each answer. Finally, the jforum_vote_voters table is used to track who has already voted.

So, for the phpbb topic_vote value to be valid, the phpbb polling/voting info would have to be translated into the correct jforum tables.

Also, things to check closely would be stuff like, do the posts show the correct author (e.g. did the user id info transfer correctly).

Do the topics listed in the forum listing match the postings .

Are the search tables up to date? I.e, does search find the correct info? You may have to run the searchIndexer tool to get this correct.

You probably want to check that various user options are correct, just in case phpbb does something like 0 for a value and jforum uses 1 for the same thing.

Also I'm not sure how avatar information will translate between the two. You may have to move some files between the phpBBs file system and jForum's.

Another thing that I don't think gets transferred are attachements. So, you may need to figure out how to deal with these.

Those are the stuff that comes to the top of my mind after a quick walk thru the queries.
[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Thanks - I'll bear all that in mind when talking to my client.

Thanks again for all your help.

R.
[originally posted on jforum.net by robinbowes]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Build phpbb2JForum from source?
 
Similar Threads
Some Questions
phpbb2jforum: how reliable?
JForum database structure compatible with PHPBB?
How to convert phpBB to JForum?
phpbb2jforum migration