|
| 1 | +# 🚨 Tennis Prediction Application - Troubleshooting Guide |
| 2 | + |
| 3 | +## Common Issues and Solutions |
| 4 | + |
| 5 | +### 1. **Java Version Issues** |
| 6 | + |
| 7 | +**Problem:** Application won't start due to Java version incompatibility |
| 8 | + |
| 9 | +**Solution:** |
| 10 | +```bash |
| 11 | +# Check your Java version |
| 12 | +java -version |
| 13 | + |
| 14 | +# Required: Java 17 or higher (preferably Java 21) |
| 15 | +# If you have multiple Java versions: |
| 16 | +java -version |
| 17 | +which java |
| 18 | +echo $JAVA_HOME |
| 19 | + |
| 20 | +# Set JAVA_HOME if needed: |
| 21 | +export JAVA_HOME=/path/to/your/java |
| 22 | +export PATH=$JAVA_HOME/bin:$PATH |
| 23 | +``` |
| 24 | + |
| 25 | +**Download Java 21:** |
| 26 | +- **Windows:** Download from Oracle or use OpenJDK |
| 27 | +- **macOS:** `brew install openjdk@21` |
| 28 | +- **Linux:** `sudo apt install openjdk-21-jdk` |
| 29 | + |
| 30 | +### 2. **Maven Issues** |
| 31 | + |
| 32 | +**Problem:** Maven not found or version issues |
| 33 | + |
| 34 | +**Solution:** |
| 35 | +```bash |
| 36 | +# Check Maven version |
| 37 | +mvn -version |
| 38 | + |
| 39 | +# Required: Maven 3.6+ (preferably 3.9+) |
| 40 | + |
| 41 | +# Install Maven if missing: |
| 42 | +# Windows: Download from Apache Maven website |
| 43 | +# macOS: brew install maven |
| 44 | +# Linux: sudo apt install maven |
| 45 | +``` |
| 46 | + |
| 47 | +### 3. **Port Already in Use** |
| 48 | + |
| 49 | +**Problem:** `Port 8080 is already in use` |
| 50 | + |
| 51 | +**Solution:** |
| 52 | +```bash |
| 53 | +# Check what's using port 8080 |
| 54 | +# Windows: netstat -ano | findstr :8080 |
| 55 | +# macOS/Linux: lsof -i :8080 |
| 56 | + |
| 57 | +# Kill the process or change port in application.properties: |
| 58 | +server.port=8081 |
| 59 | +``` |
| 60 | + |
| 61 | +### 4. **Build Failures** |
| 62 | + |
| 63 | +**Problem:** `mvn clean compile` fails |
| 64 | + |
| 65 | +**Solution:** |
| 66 | +```bash |
| 67 | +# Clean and rebuild |
| 68 | +mvn clean |
| 69 | +mvn compile |
| 70 | + |
| 71 | +# If still failing, check: |
| 72 | +# 1. Internet connection (for downloading dependencies) |
| 73 | +# 2. Maven settings.xml |
| 74 | +# 3. Java version compatibility |
| 75 | +``` |
| 76 | + |
| 77 | +### 5. **Database Issues** |
| 78 | + |
| 79 | +**Problem:** H2 database connection errors |
| 80 | + |
| 81 | +**Solution:** |
| 82 | +```bash |
| 83 | +# The application uses in-memory H2 database |
| 84 | +# No setup required, but check application.properties: |
| 85 | + |
| 86 | +# H2 Database Configuration |
| 87 | +spring.datasource.url=jdbc:h2:mem:tennisdb |
| 88 | +spring.datasource.driverClassName=org.h2.Driver |
| 89 | +spring.datasource.username=sa |
| 90 | +spring.datasource.password=password |
| 91 | +spring.h2.console.enabled=true |
| 92 | +spring.h2.console.path=/h2-console |
| 93 | +``` |
| 94 | + |
| 95 | +### 6. **Missing Dependencies** |
| 96 | + |
| 97 | +**Problem:** ClassNotFoundException or NoClassDefFoundError |
| 98 | + |
| 99 | +**Solution:** |
| 100 | +```bash |
| 101 | +# Download all dependencies |
| 102 | +mvn dependency:resolve |
| 103 | + |
| 104 | +# Force download |
| 105 | +mvn clean install -U |
| 106 | +``` |
| 107 | + |
| 108 | +### 7. **IDE Issues** |
| 109 | + |
| 110 | +**Problem:** IDE can't find classes or dependencies |
| 111 | + |
| 112 | +**Solution:** |
| 113 | +- **IntelliJ IDEA:** File → Invalidate Caches and Restart |
| 114 | +- **Eclipse:** Project → Clean |
| 115 | +- **VS Code:** Reload window and ensure Java extension is installed |
| 116 | + |
| 117 | +### 8. **Application Won't Start** |
| 118 | + |
| 119 | +**Problem:** Spring Boot application fails to start |
| 120 | + |
| 121 | +**Solution:** |
| 122 | +```bash |
| 123 | +# Check logs for specific errors |
| 124 | +mvn spring-boot:run |
| 125 | + |
| 126 | +# Common issues: |
| 127 | +# 1. Port already in use |
| 128 | +# 2. Database connection issues |
| 129 | +# 3. Missing dependencies |
| 130 | +# 4. Java version incompatibility |
| 131 | +``` |
| 132 | + |
| 133 | +### 9. **API Endpoints Not Working** |
| 134 | + |
| 135 | +**Problem:** 404 errors when accessing API endpoints |
| 136 | + |
| 137 | +**Solution:** |
| 138 | +```bash |
| 139 | +# Check the correct URL structure: |
| 140 | +# Base URL: http://localhost:8080/tennis-prediction |
| 141 | +# API: http://localhost:8080/tennis-prediction/api/matches |
| 142 | + |
| 143 | +# Test with curl: |
| 144 | +curl http://localhost:8080/tennis-prediction/api/matches |
| 145 | +``` |
| 146 | + |
| 147 | +### 10. **Web Dashboard Issues** |
| 148 | + |
| 149 | +**Problem:** Dashboard shows errors or doesn't load |
| 150 | + |
| 151 | +**Solution:** |
| 152 | +```bash |
| 153 | +# Check if Thymeleaf templates are in correct location: |
| 154 | +# src/main/resources/templates/dashboard.html |
| 155 | + |
| 156 | +# Verify template syntax and dependencies |
| 157 | +``` |
| 158 | + |
| 159 | +## 🔧 Step-by-Step Setup Guide |
| 160 | + |
| 161 | +### **Prerequisites:** |
| 162 | +1. **Java 21** (or Java 17+) |
| 163 | +2. **Maven 3.9+** |
| 164 | +3. **Git** (for cloning) |
| 165 | + |
| 166 | +### **Setup Steps:** |
| 167 | + |
| 168 | +```bash |
| 169 | +# 1. Clone or download the project |
| 170 | +git clone <repository-url> |
| 171 | +cd tennis-prediction-app |
| 172 | + |
| 173 | +# 2. Verify Java and Maven |
| 174 | +java -version |
| 175 | +mvn -version |
| 176 | + |
| 177 | +# 3. Clean and build |
| 178 | +mvn clean compile |
| 179 | + |
| 180 | +# 4. Run the application |
| 181 | +mvn spring-boot:run |
| 182 | + |
| 183 | +# 5. Test the application |
| 184 | +curl http://localhost:8080/tennis-prediction/api/matches |
| 185 | +``` |
| 186 | + |
| 187 | +### **Verification Steps:** |
| 188 | + |
| 189 | +1. **Check Application Startup:** |
| 190 | + ```bash |
| 191 | + # Look for these messages in logs: |
| 192 | + # "Started TennisPredictionApplication" |
| 193 | + # "H2 console available at '/tennis-prediction/h2-console'" |
| 194 | + ``` |
| 195 | + |
| 196 | +2. **Test API Endpoints:** |
| 197 | + ```bash |
| 198 | + # Test matches API |
| 199 | + curl http://localhost:8080/tennis-prediction/api/matches |
| 200 | + |
| 201 | + # Test players API |
| 202 | + curl http://localhost:8080/tennis-prediction/api/players |
| 203 | + |
| 204 | + # Test prediction API |
| 205 | + curl -X POST http://localhost:8080/tennis-prediction/api/predictions/match-winner/1 |
| 206 | + ``` |
| 207 | + |
| 208 | +3. **Access Web Dashboard:** |
| 209 | + - Open browser: `http://localhost:8080/tennis-prediction/` |
| 210 | + |
| 211 | +## 🆘 Still Having Issues? |
| 212 | + |
| 213 | +### **Debug Mode:** |
| 214 | +```bash |
| 215 | +# Run with debug logging |
| 216 | +mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dlogging.level.com.tennis=DEBUG" |
| 217 | +``` |
| 218 | + |
| 219 | +### **Common Error Messages:** |
| 220 | + |
| 221 | +1. **"Port 8080 already in use"** |
| 222 | + - Change port in `application.properties` |
| 223 | + - Kill existing process |
| 224 | + |
| 225 | +2. **"No compiler is provided in this environment"** |
| 226 | + - Install JDK (not just JRE) |
| 227 | + - Set JAVA_HOME correctly |
| 228 | + |
| 229 | +3. **"Could not resolve dependencies"** |
| 230 | + - Check internet connection |
| 231 | + - Clear Maven cache: `mvn dependency:purge-local-repository` |
| 232 | + |
| 233 | +4. **"ClassNotFoundException"** |
| 234 | + - Run `mvn clean install` |
| 235 | + - Check if all dependencies are downloaded |
| 236 | + |
| 237 | +### **System-Specific Issues:** |
| 238 | + |
| 239 | +**Windows:** |
| 240 | +- Use Command Prompt or PowerShell as Administrator |
| 241 | +- Check Windows Defender/firewall settings |
| 242 | +- Ensure Java is in PATH |
| 243 | + |
| 244 | +**macOS:** |
| 245 | +- Use Terminal |
| 246 | +- Install Java via Homebrew: `brew install openjdk@21` |
| 247 | +- Set JAVA_HOME: `export JAVA_HOME=$(/usr/libexec/java_home -v 21)` |
| 248 | + |
| 249 | +**Linux:** |
| 250 | +- Use terminal |
| 251 | +- Install Java: `sudo apt install openjdk-21-jdk` |
| 252 | +- Set JAVA_HOME if needed |
| 253 | + |
| 254 | +## 📞 Need More Help? |
| 255 | + |
| 256 | +If you're still experiencing issues, please provide: |
| 257 | +1. **Operating System** (Windows/macOS/Linux) |
| 258 | +2. **Java version** (`java -version`) |
| 259 | +3. **Maven version** (`mvn -version`) |
| 260 | +4. **Exact error message** from the console |
| 261 | +5. **Steps you followed** to reproduce the issue |
| 262 | + |
| 263 | +This will help provide more specific solutions for your environment. |
0 commit comments