Serious problems with Maven

As much as I'd like to be concise, this will take a while to explain. I wanted to make simple annotation processor for my side project - http server with sort of MVC model. I added annotations @Mapping and @Mappings (@Mapping is @Repeatable) and I proceeded with creating the processor. For this I used Google's AutoService, however it wouldn't generate the files (Maybe I did something wrong?). So, I included maven-compiler-plugin in my build configuration, but it still wouldn't generate the files. I started digging deeper, running mvn clean, mvn install, mvn compile, yet it almost always results in build failure. The only time it gets to work is when I delete the plugin mentioned earlier (which means that no files are generated). It's worth mentioning that my project has a umm unique structure, and so here it is:
HttpServerEnv/
├─ Application/
│ ├─ src/
│ │ ├─ main/
│ │ ├─ java/
│ │ ├─ org/
│ │ ├─ example/
│ │ ├─ IndexController.java
│ │ ├─ Main.java
│ ├─ pom.xml
├─ HttpServer/
│ ├─ src/
│ │ ├─ main/
│ │ ├─ java/
│ │ ├─ fun/
│ │ ├─ ender/
│ │ ├─ annotations/
│ │ │ ├─ ...
│ │ │ ├─ MappingsAnnotationProcessor.java
│ │ ├─ server/...
│ │ ├─ utils/...
│ │ ├─ module-info.java
│ ├─ pom.xml
├─ pom.xml
HttpServerEnv/
├─ Application/
│ ├─ src/
│ │ ├─ main/
│ │ ├─ java/
│ │ ├─ org/
│ │ ├─ example/
│ │ ├─ IndexController.java
│ │ ├─ Main.java
│ ├─ pom.xml
├─ HttpServer/
│ ├─ src/
│ │ ├─ main/
│ │ ├─ java/
│ │ ├─ fun/
│ │ ├─ ender/
│ │ ├─ annotations/
│ │ │ ├─ ...
│ │ │ ├─ MappingsAnnotationProcessor.java
│ │ ├─ server/...
│ │ ├─ utils/...
│ │ ├─ module-info.java
│ ├─ pom.xml
├─ pom.xml
22 Replies
JavaBot
JavaBot2d ago
This post has been reserved for your question.
Hey @ENDERFUN! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
ENDERFUN
ENDERFUNOP2d ago
And here are all pom.xml's: (HttpSeverEnv):
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>HttpServerEnv</artifactId>
<version>1.0</version>
<packaging>pom</packaging>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<modules>
<module>HttpServer</module>
<module>Application</module>
</modules>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>HttpServerEnv</artifactId>
<version>1.0</version>
<packaging>pom</packaging>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<modules>
<module>HttpServer</module>
<module>Application</module>
</modules>
</project>
(HttpServer):
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>fun.ender</groupId>
<artifactId>HttpServer</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<auto-service.version>1.1.1</auto-service.version>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>1.1.1</version>
</path>
<path>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service-annotations</artifactId>
<version>1.1.1</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>fun.ender</groupId>
<artifactId>HttpServer</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<auto-service.version>1.1.1</auto-service.version>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>1.1.1</version>
</path>
<path>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service-annotations</artifactId>
<version>1.1.1</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service-annotations</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.36</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>13.0</version>
<scope>compile</scope>
</dependency>
...
</dependencies>
</project>
<dependencies>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service-annotations</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.36</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>13.0</version>
<scope>compile</scope>
</dependency>
...
</dependencies>
</project>
And (Application):
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.example</groupId>
<artifactId>HttpServerEnv</artifactId>
<version>1.0</version>
</parent>

<artifactId>Application</artifactId>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>fun.ender</groupId>
<artifactId>HttpServer</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>

</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.example</groupId>
<artifactId>HttpServerEnv</artifactId>
<version>1.0</version>
</parent>

<artifactId>Application</artifactId>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>fun.ender</groupId>
<artifactId>HttpServer</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>

</project>
When I try to compile my project, I get this build output:
C:\Users\ENDER FUN\Main\IdeaProjects\HttpServerEnv\HttpServer\src\main\java\fun\ender\server\http\request\Encoder.java:16:45
java: cannot find symbol
symbol: method getAcceptsEncoding()
location: variable request of type fun.ender.server.http.request.Request
C:\Users\ENDER FUN\Main\IdeaProjects\HttpServerEnv\HttpServer\src\main\java\fun\ender\server\http\request\Encoder.java:16:45
java: cannot find symbol
symbol: method getAcceptsEncoding()
location: variable request of type fun.ender.server.http.request.Request
And this is just one of many such errors (there's like 20 of them) If you need any additional info, just ping me and I'll try to respond asap Oh and it's worth noting I'm using IntelliJ If you need a more detailed explanation, we can talk on vc
ayylmao123xdd
ayylmao123xdd2d ago
well maybe the problem is the project structure
ENDERFUN
ENDERFUNOP2d ago
It could be, but when I looked into the logs (mvn compile -X) it was first compiling HttpServer which seems right Then all of a sudden it cannot find elements
ENDERFUN
ENDERFUNOP2d ago
It's like huge
No description
ayylmao123xdd
ayylmao123xdd2d ago
are all of those classes yours or are some made by spring
ENDERFUN
ENDERFUNOP2d ago
Nah I ain't using spring It's all mine I'm writing a server from ground up Thought it'd be a good idea It wasn't
ayylmao123xdd
ayylmao123xdd2d ago
😱 well thats kind of an interesting approach what if you just switch to use spring
ENDERFUN
ENDERFUNOP2d ago
Well I'm making a competition to spring Something more lightweight And simple And just for the record: I'm writing HttpServer, the Application is just a testing site
ayylmao123xdd
ayylmao123xdd2d ago
btw for lombok you should mark it in annotation processors
ENDERFUN
ENDERFUNOP2d ago
Could it be the culprit? Oh and also don't take a bad impression I suck at maven Only know how to add dependencies I'm no expert in build process or anything else
ayylmao123xdd
ayylmao123xdd2d ago
yea same this is the first time i see someone use maven without spring show the encoder java class maybe all ur errors are related to lombok
ENDERFUN
ENDERFUNOP2d ago
Oh alright But I doubt it's that
package fun.ender.server.http.request;

import com.aayushatharva.brotli4j.encoder.BrotliOutputStream;
import fun.ender.server.http.response.ResponseBuilder;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.GZIPOutputStream;

public final class Encoder {
private Encoder() {
}

public static byte[] encodeBody(byte[] body, Request request, ResponseBuilder responseBuilder) {
String[] acceptedEncodings = request.getAcceptsEncoding();
if (acceptedEncodings.length == 0) return body;
return switch (acceptedEncodings[0]) {
case "gzip" -> encodeGzip(body, responseBuilder);
case "deflate" -> encodeDeflate(body, responseBuilder);
case "br" -> encodeBrotli(body, responseBuilder);
default -> body;
};
}

private static byte[] encodeBrotli(byte[] body, ResponseBuilder responseBuilder) {
try (ByteArrayOutputStream bArrayOutputStream = new ByteArrayOutputStream();
BrotliOutputStream brotliOutputStream = new BrotliOutputStream(bArrayOutputStream)) {
brotliOutputStream.write(body);
brotliOutputStream.close();

String field = responseBuilder.getHeaderFieldValue("Content-Encoding");
if (field == null) responseBuilder.headerField("Content-Encoding", "br");
else responseBuilder.headerField("Content-Encoding", field + ", br");

return bArrayOutputStream.toByteArray();
} catch (IOException e) {
return body;
}
}
package fun.ender.server.http.request;

import com.aayushatharva.brotli4j.encoder.BrotliOutputStream;
import fun.ender.server.http.response.ResponseBuilder;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.GZIPOutputStream;

public final class Encoder {
private Encoder() {
}

public static byte[] encodeBody(byte[] body, Request request, ResponseBuilder responseBuilder) {
String[] acceptedEncodings = request.getAcceptsEncoding();
if (acceptedEncodings.length == 0) return body;
return switch (acceptedEncodings[0]) {
case "gzip" -> encodeGzip(body, responseBuilder);
case "deflate" -> encodeDeflate(body, responseBuilder);
case "br" -> encodeBrotli(body, responseBuilder);
default -> body;
};
}

private static byte[] encodeBrotli(byte[] body, ResponseBuilder responseBuilder) {
try (ByteArrayOutputStream bArrayOutputStream = new ByteArrayOutputStream();
BrotliOutputStream brotliOutputStream = new BrotliOutputStream(bArrayOutputStream)) {
brotliOutputStream.write(body);
brotliOutputStream.close();

String field = responseBuilder.getHeaderFieldValue("Content-Encoding");
if (field == null) responseBuilder.headerField("Content-Encoding", "br");
else responseBuilder.headerField("Content-Encoding", field + ", br");

return bArrayOutputStream.toByteArray();
} catch (IOException e) {
return body;
}
}
private static byte[] encodeDeflate(byte[] body, ResponseBuilder responseBuilder) {

try (ByteArrayOutputStream bArrayOutputStream = new ByteArrayOutputStream();
DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(bArrayOutputStream)) {
deflaterOutputStream.write(body);
deflaterOutputStream.flush();
deflaterOutputStream.close();

String field = responseBuilder.getHeaderFieldValue("Content-Encoding");
if (field == null) responseBuilder.headerField("Content-Encoding", "deflate");
else responseBuilder.headerField("Content-Encoding", field + ", deflate");

return bArrayOutputStream.toByteArray();
} catch (IOException e) {
throw new RuntimeException("You fucked up");
}
}

private static byte[] encodeGzip(byte[] body, ResponseBuilder responseBuilder) {
try (ByteArrayOutputStream bArrayOutputStream = new ByteArrayOutputStream();
GZIPOutputStream gzipOutputStream = new GZIPOutputStream(bArrayOutputStream)) {
gzipOutputStream.write(body);
gzipOutputStream.finish();

String field = responseBuilder.getHeaderFieldValue("Content-Encoding");
if (field == null) responseBuilder.headerField("Content-Encoding", "gzip");
else responseBuilder.headerField("Content-Encoding", field + ", gzip");

return bArrayOutputStream.toByteArray();
} catch (IOException e) {
return body;
}
}
}
private static byte[] encodeDeflate(byte[] body, ResponseBuilder responseBuilder) {

try (ByteArrayOutputStream bArrayOutputStream = new ByteArrayOutputStream();
DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(bArrayOutputStream)) {
deflaterOutputStream.write(body);
deflaterOutputStream.flush();
deflaterOutputStream.close();

String field = responseBuilder.getHeaderFieldValue("Content-Encoding");
if (field == null) responseBuilder.headerField("Content-Encoding", "deflate");
else responseBuilder.headerField("Content-Encoding", field + ", deflate");

return bArrayOutputStream.toByteArray();
} catch (IOException e) {
throw new RuntimeException("You fucked up");
}
}

private static byte[] encodeGzip(byte[] body, ResponseBuilder responseBuilder) {
try (ByteArrayOutputStream bArrayOutputStream = new ByteArrayOutputStream();
GZIPOutputStream gzipOutputStream = new GZIPOutputStream(bArrayOutputStream)) {
gzipOutputStream.write(body);
gzipOutputStream.finish();

String field = responseBuilder.getHeaderFieldValue("Content-Encoding");
if (field == null) responseBuilder.headerField("Content-Encoding", "gzip");
else responseBuilder.headerField("Content-Encoding", field + ", gzip");

return bArrayOutputStream.toByteArray();
} catch (IOException e) {
return body;
}
}
}
There's even no lombok in here (As for the code quality, I'm considering to change this mechanism such that there will be interface Encoder which would be implemented by GzipEncoder, BrotliEncoder, etc. so you don't have to scold at me)
ayylmao123xdd
ayylmao123xdd2d ago
can u format the code
JavaBot
JavaBot2d ago
Please format your code & make it more readable. For the java programming language, it should look like this:
```java public class Main { public static void main(String[] args){ System.out.println("Hello World!"); } ```
• These are backticks, not quotes.
ayylmao123xdd
ayylmao123xdd2d ago
show the request class seems to be throwing an error there
ENDERFUN
ENDERFUNOP2d ago
Sorry im away from computer rn I'll send it when ill be active I'm back
ENDERFUN
ENDERFUNOP2d ago
Sorry it's too long (Don't comment me on overdose of stream api)
ayylmao123xdd
ayylmao123xdd2d ago
ill check it later cant open rn
ENDERFUN
ENDERFUNOP2d ago
Sure Well, after deleting the whole <build> tag from pom.xml, auto-service dependencies and all pieces of code including it the compilation works like a charm So one of those things is definetly a culprit The most probable cause is my mistake in <build> part of pom
JavaBot
JavaBot2d ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?