Skip to content

Troubleshooting

Pedro Xavier Leite Cavadas edited this page Sep 5, 2024 · 1 revision

This page addresses common issues that may arise while using js2pets in your Maven or Gradle projects.

Common Issues

POJOs Not Generating as Expected

If your POJOs are not being generated or are missing certain features, try the following:

  • Check Plugin Configuration: Ensure that the jsonschema2pojo plugin and js2pets dependency are properly configured in your pom.xml (for Maven) or build.gradle.kts (for Gradle).
  • Version Mismatch: Verify that the jsonschema2pojo and js2pets versions are compatible. Outdated versions can sometimes cause unexpected behavior.
  • Schema Issues: Check if your JSON schema is valid and correctly formatted, as jsonschema2pojo will fail if the schema is malformed.

Custom Constructor Rules Not Applying

If the custom rules for constructors (e.g., skipping no-args constructors) are not working:

  • Verify Rule Factory: Make sure the customRuleFactory is set to io.github.lengors.js2pets.factories.EnhancedRuleFactory.
  • Configuration Parameters: Double-check that includeConstructors and includeNoArgsConstructor are properly set in your configuration.
  • Gradle-Specific Issues: For Gradle users, ensure you're explicitly choosing between IncludeNoArgsConstructor or ExcludeNoArgsConstructor in the rule factory, as js2pets currently doesn't infer the behavior for Gradle-based projects automatically.

Dependency Resolution Errors

If Maven or Gradle cannot resolve js2pets or jsonschema2pojo dependencies:

  • Check Repositories: Ensure your project is using a repository that includes the necessary dependencies (e.g., Maven Central).
  • Update Dependency Version: Make sure you're using the latest versions of js2pets and jsonschema2pojo. You may need to update your project’s dependencies.

Debugging Tips

  • Verbose Logging in Maven: Use mvn -X to enable verbose logging and get more detailed error messages.
  • Gradle Debugging: For Gradle, use --info or --debug to gain more insight into what might be going wrong.

Further Assistance

If the above solutions do not resolve your issue, consider opening a detailed issue on the GitHub repository with information about your project setup and any error logs you're seeing.