Guide: SFS2X 2.9 + JSP/Jasper + JDK

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
Lapo
Site Admin
Posts: 19733
Joined: 21 Mar 2005, 09:50
Location: Italy

Guide: SFS2X 2.9 + JSP/Jasper + JDK

Postby Lapo » 01 Aug 2014, 15:43

This is a quick guide for those using SFS2X 2.9 using JSP.

The problem
The embedded Jetty 9 http server requires the full JDK to run JSP, because it's a requirement for Jasper, the JSP compiler.
SmartFoxServer 2X comes with an embedded JRE 1.7.x which is missing some of the components of the JDK (which takes 150+MB alone)

The Solution
You can install your own JDK.
If you run MacOSX you should already have installed it. Otherwise you can download the JDK from the Oracle website (Windows) or use the software management tools in your Linux distribution to get it installer.You will need the JDK 7 or higher.

For example if you are running an Ubuntu Linux box you will be able to install the JDK with a few commands in your terminal:

Code: Select all

sudo apt-get update
sudo apt-get install openjdk-7-jdk


Edit a couple of files and you're good to go
1) Take note of the JDK version. Let' say it is 1.7.0_65
- Go to the SFS2X/lib/jetty/modules/npn/
- See if a file called npn-1.7.0_65 exists (or whatever your JDK version is)
- If it doesn't duplicate an existing one an rename it to npn-1.7.0_65 (or whatever your JDK version is)

2) Move back to the SFS2X/ folder
- Edit the sfs2x-service file
- Uncomment the #INSTALL4J_JAVA_HOME_OVERRIDE line by removing the # (hash) sign
- Set it to the path of your installed JDK. In the case of our test machine (Ubuntu 14) it is

Code: Select all

INSTALL4J_JAVA_HOME_OVERRIDE="/usr/lib/jvm/java-7-openjdk-amd64/"

- Save and close

Start and Test
- Start the server
- Point your browser to http://localhost:8080/HelloServlet/

You should see the demo page loading and displaying correctly.
Lapo
--
gotoAndPlay()
...addicted to flash games
AndyMartin458
Posts: 44
Joined: 15 May 2012, 21:57

Re: Guide: SFS2X 2.9 + JSP/Jasper + JDK

Postby AndyMartin458 » 14 Aug 2014, 17:04

Can I disable JSP altogether? I'm trying to use Java 8 on Windows. It didn't work when I tried installing the newest version of Jetty on my own.
User avatar
Lapo
Site Admin
Posts: 19733
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Guide: SFS2X 2.9 + JSP/Jasper + JDK

Postby Lapo » 15 Aug 2014, 08:07

I don't understand your question very well.
In this thread we have just said that JSP doesn't work out of the box. So it's not "active". Plus if you don't use JSP pages it will never be used anyways.

It's not clear what the problem could be with Java 8.
If you're compiling Java 8 code then you will need to replace the JRE in SFS2X as it runs by default a JRE 7.

However you can still program with Java 8 and set the "compliance level" to Java 7 without any changes to SFS2X.

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
brownjay
Posts: 5
Joined: 07 Dec 2014, 08:34

Re: Guide: SFS2X 2.9 + JSP/Jasper + JDK

Postby brownjay » 03 Jan 2015, 08:05

Please help me, my OS is Windows 7

Sfs2x-service can be modified in linux ,but can't in windows

which file should be modified ?
User avatar
Lapo
Site Admin
Posts: 19733
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Guide: SFS2X 2.9 + JSP/Jasper + JDK

Postby Lapo » 03 Jan 2015, 09:23

Good point, in Windows the sfs2x-service is a binary executable so the process is a bit different.

In your main SmartFoxServer2X/ installation folder you will find a .install4j/ directory.
Inside you will find a file called --> pref_jre.cfg
Edit the file, replace the path to your JDK, and save.

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
brownjay
Posts: 5
Joined: 07 Dec 2014, 08:34

Re: Guide: SFS2X 2.9 + JSP/Jasper + JDK

Postby brownjay » 03 Jan 2015, 10:09

Hi Lapo , thank you reply so soon,

but i already edit the file but seem can't open jsp page

thows the same exception.
User avatar
Lapo
Site Admin
Posts: 19733
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Guide: SFS2X 2.9 + JSP/Jasper + JDK

Postby Lapo » 03 Jan 2015, 11:10

Sounds like an entirely different problem.
Lapo

--

gotoAndPlay()

...addicted to flash games
brownjay
Posts: 5
Joined: 07 Dec 2014, 08:34

Re: Guide: SFS2X 2.9 + JSP/Jasper + JDK

Postby brownjay » 04 Jan 2015, 01:36

Sorry could be not more information say this.

if i use SmartFoxServer_2X\SFS2X\sfs2x.bat

Code: Select all

source :
      @..\jre\bin\java.exe -cp "./;lib/*;lib/jetty/lib/*;extensions/__lib__/*" -Dfile.encoding=UTF-8 com.smartfoxserver.v2.Main %1 %2

change to my real JDB install path like this.

Code: Select all

      @ C:\Progra~1\Java\jdk1.7.0_51\bin\java.exe "./;lib/*;lib/jetty/lib/*;extensions/__lib__/*" -Dfile.encoding=UTF-8 com.smartfoxserver.v2.Main %1 %2

and then execute this sfs2x.bat , it 's can work.

i mean if i alter pre_jre.cfg and then execute \SFS2X\sfs2x-standalone.exe or \SFS2X\sfs2x-service.exe two way to start up smartfox server.

jdk path could use pre_jre.cfg file's path or i must be rebuild execution file ??
User avatar
Lapo
Site Admin
Posts: 19733
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Guide: SFS2X 2.9 + JSP/Jasper + JDK

Postby Lapo » 05 Jan 2015, 10:12

sfs2x-service.exe is not the executable that you need to run manually.
The executable is used by Windows if you are running SFS2X as a service.

If you are running the server manually, you can use sfs2x-standalone.exe. This will work in conjunction with the JRE path specified in the pre_jre.cfg file that I have mentioned in my previous post.

I tested under Windows 8, using Oracle JDK 8 and it works fine.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Bing [Bot] and 15 guests