Java Chirpstack-api build

Hello all,

I am trying to compile and run this on my ubuntu-24-04-01 VM running on VirtualBox.

The first time I fired:
sudo docker-compose up chirpstack-api-java-current-user

it gave a warning:
WARNING: The CURRENT_UID variable is not set. Defaulting to a blank string.
WARNING: The CURRENT_HOME variable is not set. Defaulting to a blank string.

and ran until:
ERROR: for chirpstack-api_chirpstack-api-java-current-user_1 Cannot start service chirpstack-api-java-current-user: error while creating mount source path ‘/.m2’: mkdir /.m2: read-only file system

ERROR: for chirpstack-api-java-current-user Cannot start service chirpstack-api-java-current-user: error while creating mount source path ‘/.m2’: mkdir /.m2: read-only file system

I changed the line in docker-compose.yml from :
- ${CURRENT_HOME}/.m2:/var/maven/.m2
to
- ${HOME}/.m2:/var/maven/.m2
and removed the line:
- ${CURRENT_HOME}/.m2:/var/maven/.m2

That allowed the build image to be successfully built. There is a build directory created under java/build with the build/target/chirpstack-api-3.12.4.jar and the rest of the artifacts all there

Towards the end of the log of the build we have:

chirpstack-api-java-current-user_1 | [INFO] Installing /chirpstack-api/java/build/target/chirpstack-api-3.12.4.jar to /var/maven/.m2/repository/io/chirpstack/chirpstack-api/3.12.4/chirpstack-api-3.12.4.jar

but neither on the image nor on my local VM I can find the /var/maven, let alone /var/maven/.m2. Is the log lying and the build install was not actually successful or this is by design? Since I notice on github Chirpstack-api java page it refers to the jar artifact to be installed to local maven repository $HOME/.m2 for the code snippet published there to be built. Has my changes to the environment variables in the playbook caused this or there’s something else which is the problem.

Also is there another docker-compose which needs to be fired up for building the code snippet in the link above? Or that is meant to be built directly on the VM using the jar generated (and somehow installed) by the original docker-compose. Looking at the above link I was not very sure how to build the snippet published there. (ie need to generate the maven source structure using mvn archetype:generate and mvn package on my VM or there’s another docker-compose for these?)

Thank you

The first part of the question was solved. It was somehow careless of me not checking out the top level Makefile as it had the java-current-user target defined which is where all those undefined env vars were defined. so instead of running docker-compose directly, it was run through make and it worked.

Also since I was running it with sudo the maven home was actually under root not under my own home, so that explains why I couldn’t find it.

Now trying to figure out how to build and run the service wrapper stub…

1 Like

I don’t have experience with Java, but you should be able to run the following (outside docker):

cd api
make java

Is there on official java library in a public maven repo available ?

If I build the lib from source as described, will this be compatible with chipstack v4 ?

Regards,
Dirk

You can find a v4 compatible Java library here:

I’m not a Java dev, so please feel free to propose improvements :slight_smile:

Hello:
I am a java developer.
I run the command of docker-compose for java succeed.
Bud when I use the chirpstack-api-3.12.4.jar something went wrong,details as following :

My codes:

//get jwt
ManagedChannel channel = ManagedChannelBuilder.forAddress(“XXXX”, 8080).usePlaintext().build();
InternalServiceGrpc.InternalServiceBlockingStub stub = InternalServiceGrpc.newBlockingStub(channel);
final LoginRequest loginRequest = LoginRequest.newBuilder().setEmail(“XXX”).setPassword(“XXX”).build();
LoginResponse loginResponse = stub.login(loginRequest);
Metadata metadata = new Metadata();
metadata.put(Metadata.Key.of(“authorization”, Metadata.ASCII_STRING_MARSHALLER), "Bearer " + loginResponse.getJwt());
Channel headChannel = ClientInterceptors.intercept(channel, MetadataUtils.newAttachHeadersInterceptor(metadata));
//get application list
ApplicationServiceGrpc.ApplicationServiceBlockingStub appStub = ApplicationServiceGrpc.newBlockingStub(headChannel);
ListApplicationRequest.newBuilder().setOrganizationId(1).build();
final ListApplicationResponse list = appStub.list(ListApplicationRequest.newBuilder().setOrganizationId(1).build());

Result log:

INTERNAL: failed to decode Protobuf message: ListApplicationsRequest.search: invalid wire type: Varint (expected LengthDelimited)
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:271)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:252)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:165)
at io.chirpstack.api.as.external.api.ApplicationServiceGrpc$ApplicationServiceBlockingStub.list(ApplicationServiceGrpc.java:2698)

My question:
the request I defined is :ListApplicationRequest(It is in chirpstack-api-3.12.4.jar) but error trace is :ListApplicationsRequest(It is not in chirpstack-api-3.12.4.jar) .
That is why? I looking forward to your reply. :slight_smile: