Skip to content

Instantly share code, notes, and snippets.

@beminee
Last active March 29, 2021 03:45
Show Gist options
  • Save beminee/e1670f449d82c96bac55107c9c37da00 to your computer and use it in GitHub Desktop.
Save beminee/e1670f449d82c96bac55107c9c37da00 to your computer and use it in GitHub Desktop.

Ubuntu 16.04 Installation:

Installing prerequisites

sudo su
apt-get update
apt-get install default-jdk

Downloading the source and getting it ready

git clone https://github.com/ajanata/PretendYoureXyzzy.git
cd PretendYoureXyzzy
mv "build.properties.example" "build.properties"

now you might want to edit build.properties a bit;

nano build.properties

on line 13; you might want to add your own IP adress in order to be able to reach admin.jsp.

pyx.admin_addrs=ADD.YOUR.IP.ADRESS,127.0.0.1,0:0:0:0:0:0:0:1

you need to uncomment line 61 to 63 and comment 65 to 68. Also change

hibernate.url=jdbc:postgresql://localhost/pyx to hibernate.url=jdbc:postgresql://localhost/cah

60 # for production use, use postgres
61 hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
62 hibernate.driver_class=org.postgresql.Driver
63 hibernate.url=jdbc:postgresql://localhost/cah
64
65 # for local use, you can also use sqlite
66 # hibernate.dialect=net.socialgamer.cah.hibernate.SqliteDialect
67 # hibernate.driver_class=org.sqlite.JDBC
68 # hibernate.url=jdbc:sqlite:pyx.sqlite

then you need to set your password on line 72

# these likely need specified even with sqlite, even though they don't matter
hibernate.username=pyx
hibernate.password=PASSWORDHERE

Setting up the Tomcat Server

apt-get install tomcat7 tomcat7-admin

once all the installations have finished you will need to stop the tomcat service

service tomcat7 stop

next, you have to edit users file in order to add yourself an administrator account

sudo nano /etc/tomcat7/tomcat-users.xml

there, you might see tomcat-users tag. You need to add the following line inside of that tag, obviously replacing username and password with something you are comfortable with.

<user username="admin" password="password" roles="manager-gui,admin-gui"/>

Setting up the PostgreSQL

now we need to install PostgreSQL for our database.

apt-get install postgresql

switch to postgres user

sudo -i -u postgres

Then run the following by order, don't forget to replace information (username and password in build.properties should match these ones)

createdb cah
psql template1
CREATE USER pyx WITH PASSWORD 'PASSWORDHERE';
GRANT ALL PRIVILEGES ON DATABASE "cah" to pyx;
\q
exit

now, you finally can import .sql file

psql -h localhost -d cah -U pyx -f cah_cards.sql

Building and running the source

you need to install Maven package in order to build the source code

apt-get install maven

after the installation is done, it's time to build and run it

mvn clean package war:war -Dmaven.buildNumber.doCheck=false -Dmaven.buildNumber.doUpdate=false

you will get a file called ZY.war inside of the target file.

at this point, you need to start tomcat service back up

service tomcat7 start

afterwards, you need to go to: http://localhost:8080/manager/html/

login with information you set when you were editing the tomcat-users.xml file.

Then deploy the ZY.war

last thing to do is restarting the tomcat service:

service tomcat7 restart

then all you have to do is, go:

tomcat: http://localhost:8080/ZY/game.jsp

@AstralBlader
Copy link

@RevenantPrime Looks like I got both databases running (pyx and cah with the same database) ... and yes it is infact connecting to the database named pyx and not cah with the githubs url ...

@beminee
Copy link
Author

beminee commented Jul 22, 2018

@AstralBlader weird, I haven't gave superuser to it at all and it works.
@JGriffin34432 most likely, yeah.

Anyways, just recorded a video of me following the whole guide step by step on test AWS EC2. I will edit that comment with the link when uploading is done.

Link: https://youtu.be/738gkC8TtyY

@AstralBlader
Copy link

AstralBlader commented Jul 22, 2018

okay you are getting the same errors like me without the superuser .... then my problem was that hibernate's url was set to the database pyx and not cah xD but hey, your guide hadn't covered that in it's first version ^^
Edit: @beminee correct in your guide the following from:
"you need to uncomment line 61 to 63 and comment 65 to 68."
to
"you need to uncomment line 61 to 63 and comment 65 to 68 and modify line 63 to look like this:"

or

change: "createdb cah" to "createdb pyx" +
"psql -h localhost -d cah -U pyx -f cah_cards.sql" to
"psql -h localhost -d pyx -U pyx -f cah_cards.sql"
because the githubs version points hibernate to pyx

@kiska3
Copy link

kiska3 commented Jul 22, 2018

The issue is the outdated postgres driver that is included with the github version.

To change this edit the pom.xml file to replace

 <dependency>
      <groupId>postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <version>8.4-702.jdbc3</version>
  </dependency>

to

    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <version>42.2.4</version>
    </dependency>

And it should work
Also this is my config

# for production use, use postgres
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
hibernate.driver_class=org.postgresql.Driver
hibernate.url=jdbc:postgresql://localhost:5432/cah

# for local use, you can also use sqlite
#hibernate.dialect=net.socialgamer.cah.hibernate.SqliteDialect
#hibernate.driver_class=org.sqlite.JDBC
#hibernate.url=jdbc:sqlite:pyx.sqlite

# these likely need specified even with sqlite, even though they don't matter
hibernate.username=pyx
hibernate.password=INSERTPASSWORD

@SmolAsta
Copy link

Deleted and went through the guide from scratch and now everything seems to work and the cards appear as intended

@RobertABT
Copy link

I'm also at this point, but configuring from a remote machine (so the previous suggestion of just upload the file doesn't work), not sure how to set the context path?

2018-07-23 01_00_54-_manager

@AstralBlader
Copy link

AstralBlader commented Jul 23, 2018

@RobertABT you can move the war to the directory it needs to go manualy ...

sudo su
service tomcat7 stop
cd PretendYoureXyzzy/target
mv ZY.war var/lib/tomcat7/webapps/
service tomcat7 start

by default tomcat extracts and deploys the .war files in that folder automaticly ... check in manager if you got a new site after this and if it isn't deployed, you can deploy from there

@AstralBlader
Copy link

btw I made my site public so you don't have to go through this hassle for playing 1 round with your friends ... you can access it via http://www.astrals-cah.com

@WyattParker
Copy link

I've opened mine up as well. www.sugaming.net

@yugimutou92
Copy link

WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release [INFO] Scanning for projects... Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/exec-maven-plugin/1.1/exec-maven-plugin-1.1.pom [WARNING] Failed to retrieve plugin descriptor for org.codehaus.mojo:exec-maven-plugin:1.1: Plugin org.codehaus.mojo:exec-maven-plugin:1.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:exec-maven-plugin:jar:1.1 Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.1/maven-compiler-plugin-3.1.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-compiler-plugin:3.1: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-enforcer-plugin/1.3.1/maven-enforcer-plugin-1.3.1.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-enforcer-plugin:1.3.1: Plugin org.apache.maven.plugins:maven-enforcer-plugin:1.3.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-enforcer-plugin:jar:1.3.1 Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/properties-maven-plugin/1.0-alpha-2/properties-maven-plugin-1.0-alpha-2.pom [WARNING] Failed to retrieve plugin descriptor for org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2: Plugin org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:properties-maven-plugin:jar:1.0-alpha-2 Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-war-plugin/2.4/maven-war-plugin-2.4.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-war-plugin:2.4: Plugin org.apache.maven.plugins:maven-war-plugin:2.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-war-plugin:jar:2.4 Downloading from central: https://repo.maven.apache.org/maven2/org/eclipse/jetty/jetty-maven-plugin/9.3.0.v20150612/jetty-maven-plugin-9.3.0.v20150612.pom [WARNING] Failed to retrieve plugin descriptor for org.eclipse.jetty:jetty-maven-plugin:9.3.0.v20150612: Plugin org.eclipse.jetty:jetty-maven-plugin:9.3.0.v20150612 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.eclipse.jetty:jetty-maven-plugin:jar:9.3.0.v20150612 Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/buildnumber-maven-plugin/1.4/buildnumber-maven-plugin-1.4.pom [WARNING] Failed to retrieve plugin descriptor for org.codehaus.mojo:buildnumber-maven-plugin:1.4: Plugin org.codehaus.mojo:buildnumber-maven-plugin:1.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:buildnumber-maven-plugin:jar:1.4 Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.5: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5 Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-resources-plugin:2.6: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6 Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.4/maven-jar-plugin-2.4.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-jar-plugin:2.4: Plugin org.apache.maven.plugins:maven-jar-plugin:2.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-jar-plugin:jar:2.4 Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.12.4/maven-surefire-plugin-2.12.4.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-surefire-plugin:2.12.4: Plugin org.apache.maven.plugins:maven-surefire-plugin:2.12.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-surefire-plugin:jar:2.12.4 Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-install-plugin:2.4: Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-install-plugin:jar:2.4 Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-deploy-plugin/2.7/maven-deploy-plugin-2.7.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-deploy-plugin:2.7: Plugin org.apache.maven.plugins:maven-deploy-plugin:2.7 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-deploy-plugin:jar:2.7 Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-site-plugin/3.3/maven-site-plugin-3.3.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-site-plugin:3.3: Plugin org.apache.maven.plugins:maven-site-plugin:3.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-site-plugin:jar:3.3 Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-antrun-plugin/1.3/maven-antrun-plugin-1.3.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-antrun-plugin:1.3: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-antrun-plugin:jar:1.3 Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-5/maven-assembly-plugin-2.2-beta-5.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5: Plugin org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-beta-5 Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-dependency-plugin:2.8: Plugin org.apache.maven.plugins:maven-dependency-plugin:2.8 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-dependency-plugin:jar:2.8 Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-release-plugin/2.3.2/maven-release-plugin-2.3.2.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-release-plugin:2.3.2: Plugin org.apache.maven.plugins:maven-release-plugin:2.3.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-release-plugin:jar:2.3.2 Downloading from central: https://repo.maven.apache.org/maven2/org/eclipse/m2e/lifecycle-mapping/1.0.0/lifecycle-mapping-1.0.0.pom [WARNING] Failed to retrieve plugin descriptor for org.eclipse.m2e:lifecycle-mapping:1.0.0: Plugin org.eclipse.m2e:lifecycle-mapping:1.0.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml [WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty [WARNING] Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty [WARNING] Failure to transfer org.apache.maven.plugins/maven-metadata.xml from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty [WARNING] Failure to transfer org.codehaus.mojo/maven-metadata.xml from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.883 s [INFO] Finished at: 2018-07-26T10:11:35+03:00 [INFO] Final Memory: 8M/37M [INFO] ------------------------------------------------------------------------ [ERROR] No plugin found for prefix 'war' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/yugi/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException
no experience with maven at all. any ideas?

@SudosFTW
Copy link

@yugimutou92 you're going to have to search the central maven repository for the errored files and inject them into the proper ~/.m2/repository/ directories. it's a bit of a pain but it's worth it.

Copy link

ghost commented Jul 28, 2018

@SudosFTW, I am so new to this making of war, I am use to deploying them but everytime I run the mvn error I get the same issue yugi gets, how does one inject the proper repository because I see war in there but not sure how to add it

@drewc5131
Copy link

Everytime i login using the usr / pass i set in the tomcat-users, the login window just pops back up, like i got it incorrect.

@Eden-Mor
Copy link

How would I go about adding/ editing card sets? Im assuming I edit cah_cards.sql?
also do I change anything that mentions pyx in that file to my user?

What program edits .sql files nicely :)

Thanks! Amazing release.

@MrKich
Copy link

MrKich commented Jul 30, 2018

I had issues in that a lot of the maven files required for build are using old googlecode URLs. I spent half the night manually downloading the poms and jars from the maven central repo into their proper respective directories in the local ~/.m2/repository repo.

if you could elaborate on any troubles with this, it may help, since I was having it happen on multiple machines. this even happened with a clean local repo. there was no way around it. the time spent was merciless but the fruits of my labor are glorious.

This fixes errors during jars download:

https://stackoverflow.com/questions/6784463/error-trustanchors-parameter-must-be-non-empty

@yugimutou92
Copy link

@vamtrok ca-certificates-java, linux mint just updated it and my problem is gone. weird.

@Yotus
Copy link

Yotus commented Jul 31, 2018

I've gotten my install working correctly, everything is fine over local network, but through my domain logging in isn't possible;

https://pyx.jess.pw/game.jsp I'm a bit stumped, has anyone else run into this?

@Koyyle
Copy link

Koyyle commented Aug 1, 2018

I always get this when I try to install tomcat7, when i press tab it goes straight to tomcat8, Could I have some help? (I'm new to linux and ubuntu.)
image

@NicoWde
Copy link

NicoWde commented Aug 2, 2018

@Koyyle are you using ubuntu 16.04?

@Yotus have you set up a reverse-proxy right to e.g. http://localhost/ZY ?

@Koyyle
Copy link

Koyyle commented Aug 3, 2018

No I'm using 18, Should I use 16.04?

@Seikatsuuna
Copy link

So do these instructions even work on windows, and if so how. I'm not the smartest when it comes to this stuff and I've been having a few issues, thanks in advance for any help.

@beminee
Copy link
Author

beminee commented Aug 4, 2018

@SeikatsuChan should work but you might need to improvise a bit (i.e install windows version of Tomcat & PostgreSQL & Maven)

@Toiwing
Copy link

Toiwing commented Aug 5, 2018

If I want to edit the game.jsp page to include my own Twitter feed and a few lines of text of my own like some of you have, where do I do that? @AstralBlader

@hory-portier
Copy link

hory-portier commented Aug 5, 2018

After doing everything with the only change in the port of Tomcat from 8080 to 8088. I opened Tomcat Web Application Manager and deployed ZY.war but it seems like there's some problem with it as I'm getting message "FAIL - Application at context path /ZY could not be started" while trying to start it.
Any ideas what could it be?

Added few days later: I'm still waiting for help. Anyone?

@ZVNexus
Copy link

ZVNexus commented Aug 8, 2018

Heyo! Having a bit of a problem where I can't connect to the server using my public IP.

I have port 8080 open but when I enter my public IP+ its port it fails to connect. From what I understand Cox is not blocking it, so what could it be?

@LordGoldfish
Copy link

LordGoldfish commented Aug 13, 2018

This guide works great even thru ubuntu in windows 10, but I can't get it to run outside och the host PC.
I can connect using:
localhost:8080/ZY/
127.0.0.1:8080/ZY/
LAN_IP_HERE:8080/ZY/
on the host PC, but when I try: LAN_IP_HERE:8080/ZY/ on another PC in my network I get a "connection timed out" message.
I've added both my LAN and WAN IP in build.properties
Is there anything I should do with Tomcat?

Edit:
I did done goof up. ('-_-)
It was all due to me forgetting a simple thing such as a firewall setting.

Thanks for this detailed guide!

@SudosFTW
Copy link

@Koyyle it will run on tomcat8 just fine on modern Ubuntu.

@darkpegasus333
Copy link

darkpegasus333 commented Sep 4, 2018

I absolutely cannot get Tomcat to run on my system. It can't find java

Edit: Nevermind, got that working. Now the cards won't load...not sure where I screwed up.

@TehJawknee
Copy link

Is there a certain setting I can change if I want to set my blank card limit higher? With thousands of cards added to the cardcast stack, my games rarely get blank cards in them.

@dheimerl
Copy link

the src/main/java/net/socialgamer/cah/data/GameOptions.java has this line
public static final int MAX_BLANK_CARD_LIMIT = 30;

Change that to what you want the limit to be for blank cards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment