Generated classes (Java)

Hi, the project(eventing sample example) has both value entity and event sourced entity. When I build the project (mvn compile), I was expecting to see both the interface and implementation classes but it’s not being generated and also, the integration folder with Test classes. I retried with clean and compile but still the same result. Am I missing something or is that expected?

1 Like

Do you mean the generated protobuf files? They would be in target/generated-sources/protobuf and target/generated-test-sources/protobuf.

That’s not what I meant. For example, check this part of the documentation Kickstart a Maven project :: Akka Serverless Documentation

I believe as per Patrik’s answer earlier in another thread, code gen isn’t available for this project but I’ll update this thread once I have confirmed answer. Thanks.

We have not updated that sample to make use of the code generation from the Akka Serverless maven plugin yet. Contributions are welcome, but coordinate with us first because that work might already be in progress.

Thanks Patrik.

To expand on this - is the intent that the maven plugin’s generate command would generate the code stubs from proto files in the future? Would this work for all proto files that are in the value-entities folder? At the moment, it’s a bit unclear. Compile does indeed generate the Java stubs the first time, but it will not do so for any additional proto files that you might add into the project.

mvn compile should generate code stubs on every run. Including newly created protos.

Ah, it did not do this for me. As it turns out, I had an issue in the format of my proto file. There were no errors to indicate that the proto files had an error though, so I was confused as to why no files were generated for my new service.

Could you share, for reference, what issue(s) did you have in your proto file?

I noticed that if you do not specify correctly, in your *_api.proto, component then the code gen will not generate and there will be no errors:

option (akkaserverless.service) = {
    component: "MyEntity"

I don’t have the malformed proto files, unfortunately. I wiped the erroneous ones while troubleshooting the issue. But I do know that I had a mismatch exactly as you stated. My RPC service descriptor component did not match the name field for my (akkaserverless.file).value_entity:

option (akkaserverless.file).value_entity = {
    name: "MyMisnamedEntity"
    entity_type: "myentity"
    state: "MyEntityState"

The lack of errors during maven generation baffled me, so I started from scratch again. Only then did I realize the relationship between these fields.

Sorry for the late reply.

Yes, that was the exact issue and the resolution. Thanks everyone.