ajanata / PretendYoureXyzzy

A web clone of the card game Cards Against Humanity.
https://pretendyoure.xyz/zy
BSD 2-Clause "Simplified" License
1.22k stars 397 forks source link

Application won't start - game.jsp errors #143

Open OlivePip opened 9 years ago

OlivePip commented 9 years ago

This topic isn't helping any - the OP didn't explain how they finally resolved the issue and none of the suggested solutions seem to be working. I also have found that building is successful in Maven but the .war files produced don't load anything at all, whereas the builds in Eclipse fail but the .war files create the below issue but at least load something.

The first page loads fine but when game.jsp is loaded this happens:

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: [15] in the generated java file: [/var/lib/openshift/555d2d134382ecbefe0000a4/jbossews/work/Catalina/localhost/CAHmave/org/apache/jsp/game_jsp.java] Only a type can be imported. net.socialgamer.cah.data.GameOptions resolves to a package

An error occurred at line: 402 in the jsp file: /game.jsp GameOptions.MIN_SCORE_LIMIT cannot be resolved to a type 399: 400: 401: <% 402: for (int i = GameOptions.MIN_SCORE_LIMIT; i <= GameOptions.MAX_SCORE_LIMIT; i++) { 403: %> 404: <option <%= i == GameOptions.DEFAULT_SCORE_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 405: <% } %>

An error occurred at line: 404 in the jsp file: /game.jsp GameOptions.DEFAULT_SCORE_LIMIT cannot be resolved to a type 401: <% 402: for (int i = GameOptions.MIN_SCORE_LIMIT; i <= GameOptions.MAX_SCORE_LIMIT; i++) { 403: %> 404: <option <%= i == GameOptions.DEFAULT_SCORE_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 405: <% } %> 406: 407:

An error occurred at line: 412 in the jsp file: /game.jsp GameOptions.MIN_PLAYER_LIMIT cannot be resolved to a type 409: <select id="player_limit_template" class="player_limit" 410: aria-label="Player limit. Having more than 10 players may cause issues both for screen readers and traditional browsers."> 411: <% 412: for (int i = GameOptions.MIN_PLAYER_LIMIT; i <= GameOptions.MAX_PLAYER_LIMIT; i++) { 413: %> 414: <option <%= i == GameOptions.DEFAULT_PLAYER_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 415: <% } %>

An error occurred at line: 412 in the jsp file: /game.jsp GameOptions.MAX_PLAYER_LIMIT cannot be resolved to a type 409: <select id="player_limit_template" class="player_limit" 410: aria-label="Player limit. Having more than 10 players may cause issues both for screen readers and traditional browsers."> 411: <% 412: for (int i = GameOptions.MIN_PLAYER_LIMIT; i <= GameOptions.MAX_PLAYER_LIMIT; i++) { 413: %> 414: <option <%= i == GameOptions.DEFAULT_PLAYER_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 415: <% } %>

An error occurred at line: 414 in the jsp file: /game.jsp GameOptions.DEFAULT_PLAYER_LIMIT cannot be resolved to a type 411: <% 412: for (int i = GameOptions.MIN_PLAYER_LIMIT; i <= GameOptions.MAX_PLAYER_LIMIT; i++) { 413: %> 414: <option <%= i == GameOptions.DEFAULT_PLAYER_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 415: <% } %> 416: 417: Having more than 10 players may get cramped!

An error occurred at line: 423 in the jsp file: /game.jsp GameOptions.MIN_SPECTATOR_LIMIT cannot be resolved to a type 420: <select id="spectator_limit_template" class="spectator_limit" 421: aria-label="Spectator limit."> 422: <% 423: for (int i = GameOptions.MIN_SPECTATOR_LIMIT; i <= GameOptions.MAX_SPECTATOR_LIMIT; i++) { 424: %> 425: <option <%= i == GameOptions.DEFAULT_SPECTATOR_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 426: <% } %>

An error occurred at line: 423 in the jsp file: /game.jsp GameOptions.MAX_SPECTATOR_LIMIT cannot be resolved to a type 420: <select id="spectator_limit_template" class="spectator_limit" 421: aria-label="Spectator limit."> 422: <% 423: for (int i = GameOptions.MIN_SPECTATOR_LIMIT; i <= GameOptions.MAX_SPECTATOR_LIMIT; i++) { 424: %> 425: <option <%= i == GameOptions.DEFAULT_SPECTATOR_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 426: <% } %>

An error occurred at line: 425 in the jsp file: /game.jsp GameOptions.DEFAULT_SPECTATOR_LIMIT cannot be resolved to a type 422: <% 423: for (int i = GameOptions.MIN_SPECTATOR_LIMIT; i <= GameOptions.MAX_SPECTATOR_LIMIT; i++) { 424: %> 425: <option <%= i == GameOptions.DEFAULT_SPECTATOR_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 426: <% } %> 427: 428: Spectators can watch and chat, but not actually play. Not even as Czar.

An error occurred at line: 447 in the jsp file: /game.jsp GameOptions.MIN_BLANK_CARD_LIMIT cannot be resolved to a type 444:

An error occurred at line: 449 in the jsp file: /game.jsp GameOptions.DEFAULT_BLANK_CARD_LIMIT cannot be resolved to a type 446: <% 447: for (int i = GameOptions.MIN_BLANK_CARD_LIMIT; i <= GameOptions.MAX_BLANK_CARD_LIMIT; i++) { 448: %> 449: <option <%= i == GameOptions.DEFAULT_BLANK_CARD_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 450: <% } %> 451: blank white cards. 452:

Stacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:481) org.apache.jasper.compiler.Compiler.compile(Compiler.java:378) org.apache.jasper.compiler.Compiler.compile(Compiler.java:353) org.apache.jasper.compiler.Compiler.compile(Compiler.java:340) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

I'm trying to launch this here and it's using Tomcat 7 so that shouldn't be the issue. I'm very much a novice when it comes to this sort of thing so it may be that I'm making a really stupid mistake somewhere but I've tried so many different things and had no joy.

Hydravolt commented 9 years ago

Me too, I can't figure out what on earth the other people all did to fix it. They all know and nobody posted exactly how.

My thingy: org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 15 in the generated java file Only a type can be imported. net.socialgamer.cah.data.GameOptions resolves to a package

An error occurred at line: 402 in the jsp file: /game.jsp GameOptions.MIN_SCORE_LIMIT cannot be resolved to a type 399: 400: 401: <% 402: for (int i = GameOptions.MIN_SCORE_LIMIT; i <= GameOptions.MAX_SCORE_LIMIT; i++) { 403: %> 404: <option <%= i == GameOptions.DEFAULT_SCORE_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 405: <% } %>

An error occurred at line: 404 in the jsp file: /game.jsp GameOptions.DEFAULT_SCORE_LIMIT cannot be resolved to a type 401: <% 402: for (int i = GameOptions.MIN_SCORE_LIMIT; i <= GameOptions.MAX_SCORE_LIMIT; i++) { 403: %> 404: <option <%= i == GameOptions.DEFAULT_SCORE_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 405: <% } %> 406: 407:

An error occurred at line: 412 in the jsp file: /game.jsp GameOptions.MIN_PLAYER_LIMIT cannot be resolved to a type 409: <select id="player_limit_template" class="player_limit" 410: aria-label="Player limit. Having more than 10 players may cause issues both for screen readers and traditional browsers."> 411: <% 412: for (int i = GameOptions.MIN_PLAYER_LIMIT; i <= GameOptions.MAX_PLAYER_LIMIT; i++) { 413: %> 414: <option <%= i == GameOptions.DEFAULT_PLAYER_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 415: <% } %>

An error occurred at line: 412 in the jsp file: /game.jsp GameOptions.MAX_PLAYER_LIMIT cannot be resolved to a type 409: <select id="player_limit_template" class="player_limit" 410: aria-label="Player limit. Having more than 10 players may cause issues both for screen readers and traditional browsers."> 411: <% 412: for (int i = GameOptions.MIN_PLAYER_LIMIT; i <= GameOptions.MAX_PLAYER_LIMIT; i++) { 413: %> 414: <option <%= i == GameOptions.DEFAULT_PLAYER_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 415: <% } %>

An error occurred at line: 414 in the jsp file: /game.jsp GameOptions.DEFAULT_PLAYER_LIMIT cannot be resolved to a type 411: <% 412: for (int i = GameOptions.MIN_PLAYER_LIMIT; i <= GameOptions.MAX_PLAYER_LIMIT; i++) { 413: %> 414: <option <%= i == GameOptions.DEFAULT_PLAYER_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 415: <% } %> 416: 417: Having more than 10 players may get cramped!

An error occurred at line: 423 in the jsp file: /game.jsp GameOptions.MIN_SPECTATOR_LIMIT cannot be resolved to a type 420: <select id="spectator_limit_template" class="spectator_limit" 421: aria-label="Spectator limit."> 422: <% 423: for (int i = GameOptions.MIN_SPECTATOR_LIMIT; i <= GameOptions.MAX_SPECTATOR_LIMIT; i++) { 424: %> 425: <option <%= i == GameOptions.DEFAULT_SPECTATOR_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 426: <% } %>

An error occurred at line: 423 in the jsp file: /game.jsp GameOptions.MAX_SPECTATOR_LIMIT cannot be resolved to a type 420: <select id="spectator_limit_template" class="spectator_limit" 421: aria-label="Spectator limit."> 422: <% 423: for (int i = GameOptions.MIN_SPECTATOR_LIMIT; i <= GameOptions.MAX_SPECTATOR_LIMIT; i++) { 424: %> 425: <option <%= i == GameOptions.DEFAULT_SPECTATOR_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 426: <% } %>

An error occurred at line: 425 in the jsp file: /game.jsp GameOptions.DEFAULT_SPECTATOR_LIMIT cannot be resolved to a type 422: <% 423: for (int i = GameOptions.MIN_SPECTATOR_LIMIT; i <= GameOptions.MAX_SPECTATOR_LIMIT; i++) { 424: %> 425: <option <%= i == GameOptions.DEFAULT_SPECTATOR_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 426: <% } %> 427: 428: Spectators can watch and chat, but not actually play. Not even as Czar.

An error occurred at line: 447 in the jsp file: /game.jsp GameOptions.MIN_BLANK_CARD_LIMIT cannot be resolved to a type 444:

An error occurred at line: 449 in the jsp file: /game.jsp GameOptions.DEFAULT_BLANK_CARD_LIMIT cannot be resolved to a type 446: <% 447: for (int i = GameOptions.MIN_BLANK_CARD_LIMIT; i <= GameOptions.MAX_BLANK_CARD_LIMIT; i++) { 448: %> 449: <option <%= i == GameOptions.DEFAULT_BLANK_CARD_LIMIT ? "selected='selected' " : "" %>value="<%= i %>"><%= i %> 450: <% } %> 451: blank white cards. 452:

Stacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457) org.apache.jasper.compiler.Compiler.compile(Compiler.java:378) org.apache.jasper.compiler.Compiler.compile(Compiler.java:353) org.apache.jasper.compiler.Compiler.compile(Compiler.java:340) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

ddugovic commented 9 years ago

Without closely looking at this (as I lack an environment in which to easily develop this), based on my experience with JSPs I'm guessing a possible workaround: If GameOptions is a package (? - at face value that doesn't make sense), use static imports to import GameOptions.MIN_SCORE_LIMIT and other constants as needed instead of importing the package.

Hydravolt commented 9 years ago

I'm not trying to develop anything or tweak anything, I'm just trying to host a private gameserver for me and my friends. I have no experience with projects like this, other people fixed it with some other build options, something to do with Maven, and I'm wondering what they did in https://github.com/ajanata/PretendYoureXyzzy/issues/140

Hydravolt commented 9 years ago

Can we please get some help here? This is gamebreaking and I can't fix it.

ddwagnz commented 9 years ago

@Hydravolt i followed https://www.reddit.com/r/pretendyourexyzzy/comments/2w4k6r/a_step_by_step_guide_on_how_to_setup_your_own/ to a point but i didnt build with eclipse and used Maven's "mvn clean package war:war" inside the cah folder i wanted to build, that should generate ROOT.war in the "target" folder (you just rename that to suit yourself as that will install to the ROOT dir of tomcat) It can be quite difficult as i tried with Eclipse myself and had issues but eventually got there with Maven

A3K commented 9 years ago

With a local maven install I use

C:\Users\user\Programs\apache-maven-3.1.1\bin\mvn.bat clean package war:exploded jetty:run To build and C:\Users\user\Programs\apache-maven-3.1.1\bin\mvn.bat jetty:run To run

Hydravolt commented 9 years ago

Thank you guys so much, i finally played my first game!

ShadeGlass commented 8 years ago

Did anyone actually find a fix for this as I still get the errors?

ByzantineFailure commented 8 years ago

The guide linked above seems to have been deleted, so here's my best attempt at trying to explain what it described.

Some context: I am running this on a local install of tomcat7 rather than directly via jetty:run in maven. I fixed this issue via building with maven and manually deploying to my tomcat instance as it seems anything I try to do with Eclipse either fucks up or is a monumental nightmare to get working right. The following steps should walk you through installing maven, building the application, and manually deploying it to tomcat. I personally run things on a Mint Linux 17.3 install but I will try to provide links for those running OSX/Windows.

If you've not installed Java7, do that now. The OpenJDK runs this just fine, so if you're a Linux user on Debian/Ubuntu variant you can just do:

sudo apt-get install openjdk-7-jdk

On Windows/OSX you will have to install Java some other way. You're probably best off using Oracle's version

If you've not set a $JAVA_HOME environment variable, you will need to do that now. On Windows these steps look about right. For linux/OSX, open or create a file ~/.profile (if you have your own one like ~/.bash_profile use that instead) and add the line:

export JAVA_HOME=(path to where you installed your jdk)

On linux with the apt-get install of the openJDK the path should be /usr/lib/jvm/java-7-openjdk-ARCHITECTURE where my a 64-bit system has amd64 as its ARCHITECTURE. On OSX you will have to find this directory for yourself.

Close and reopen any terminals/shells/command windows you have open so they have access to this new environment variable (or on OSX/Linux source your ~/.profile file if you prefer).

Install Maven if you don't have it already. Under Debian/Ubuntu-based Linux:

sudo apt-get install maven

If you're running OSX or Windows, you'll have to find your own resources for installing maven. OSX seems to be pretty easy, but Windows may be a bit more involved

If you haven't configured build.properties to connect properly to your database yet, you should do that now. If you've not done this at all, ajanata has provided a template build.properties file named build.properties.example. Maven will not build the project unless the root contains a build.properties file.

With Java installed, the $JAVA_HOME environment variable set, and Maven installed and on your $PATH, you should be able to build the project via running this in the project's root:

mvn clean package war:war

This should create a WAR file within /target named ROOT.war. If you'd like the game to be run from some path on your server other than /, rename the war to PATH.war. For example, I run it at /cah so I renamed it to cah.war

After building, move the created war file to tomcat7's webapp directory. If you installed tomcat7 via apt-get on Linux, this should be /var/lib/tomcat7/webapps (if you've configured your $CATALINA_BASE to somewhere else you'll have to find that yourself). Where exactly this directory is is highly dependent upon how you installed tomcat, so I will leave finding the location of this folder to you. A good hint for googling is $CATALINA_BASE/webapps if you are unsure of where it is on your system.

After moving the war, tomcat should automatically detect and deploy the war file. Within about 30 seconds you should now be able to reach the application at wherever you deployed it (if you didn't rename the war you would reach it at localhost:8080/).