<Tim>
<Tim>
Explore posts from servers
JCHJava Community | Help. Code. Learn.
Created by <Tim> on 10/20/2024 in #java-help
Deploying Spring Boot application with Stomp over WSS using nginx
Does anyone have experience with Secure Websockets (WSS) over Nginx? I currently have this nginx config file, but the websockets stopped working once I switched from unsecure http:// and ws:// to https:// and wss:// (the https:// traffic and the rest of the application works fine though, just the websocket connection fails to establish)
server {
server_name 132.231.1.166;
server_name sojourner-under-sabotage.se2.fim.uni-passau.de;

location /websocket {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header HOST $host;
proxy_set_header X_Forwarded_For $remote_addr;
proxy_pass http://localhost:8080;
proxy_redirect default;
client_max_body_size 1000m;
}

location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/sojourner-under-sabotage.se2.fim.uni-passau.de/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/sojourner-under-sabotage.se2.fim.uni-passau.de/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
if ($host = sojourner-under-sabotage.se2.fim.uni-passau.de) {
return 301 https://$host$request_uri;
} # managed by Certbot


listen 80;
server_name 132.231.1.166;
server_name sojourner-under-sabotage.se2.fim.uni-passau.de;
return 404; # managed by Certbot


}
server {
server_name 132.231.1.166;
server_name sojourner-under-sabotage.se2.fim.uni-passau.de;

location /websocket {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header HOST $host;
proxy_set_header X_Forwarded_For $remote_addr;
proxy_pass http://localhost:8080;
proxy_redirect default;
client_max_body_size 1000m;
}

location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/sojourner-under-sabotage.se2.fim.uni-passau.de/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/sojourner-under-sabotage.se2.fim.uni-passau.de/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
if ($host = sojourner-under-sabotage.se2.fim.uni-passau.de) {
return 301 https://$host$request_uri;
} # managed by Certbot


listen 80;
server_name 132.231.1.166;
server_name sojourner-under-sabotage.se2.fim.uni-passau.de;
return 404; # managed by Certbot


}
Do I need to change anything on the Java Spring side or the Tomcat setup?
55 replies
JCHJava Community | Help. Code. Learn.
Created by <Tim> on 4/24/2024 in #java-help
java.lang.NoSuchFieldError: UUID
When I try to deploy my WAR archive on the tomcat 10 I just set up (Debian, Tomcat 10.1.23, MySQL 8.24), I get the following error:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: UUID
at
...
Caused by: java.lang.NoSuchFieldError: UUID
at
...
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: UUID
at
...
Caused by: java.lang.NoSuchFieldError: UUID
at
...
The only thing I could find on the internet about it was https://stackoverflow.com/q/76296222/6336728 I use Hibernate 6.2.7, so I downgraded to JPA 3.0.12 and Hibernate 6.1.7.Final. Now I get a java.util.zip.ZipException: zip END header not found, even though jar xvf archive.war works fine.
14 replies
JCHJava Community | Help. Code. Learn.
Created by <Tim> on 3/20/2024 in #java-help
Problems with an ArrayIndexOutOfBoundsException
Context I have source code (as a String) that I compile in memory with the Java compiler API. I then transform the bytecode to add instrumentation: mainly tracking line coverage and obtaining variable changes. What I'm trying to do Now I want to add logging. For this I want to replace calls to System.out.println with my own logging function. (This is necessary, because (1) my custom class loader blocks loading of the System class and (2) because I want the log information stored along with the other data and contain class, method and line number of the call.) What already works Simply calling System.out.println("Hello, World!"); works already. Concatenating a string with a variable works now as well, e.g. System.out.println("x = " + x); The transformation is done with the MethodVisitor from ASM:
@Override
public void visitMethodInsn(int opcode, String owner, String name, String descriptor, boolean isInterface) {
if (owner.equals("java/io/PrintStream") && name.equals("println") && descriptor.equals("(Ljava/lang/String;)V")) {
visitLdcInsn(classId);
visitLdcInsn(pMethodName);
super.visitMethodInsn(
Opcodes.INVOKESTATIC,
Type.getInternalName(Debug.class),
"log",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
false);
} else {
super.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
}
}

@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
if (opcode == Opcodes.GETSTATIC
&& owner.equals("java/lang/System")
&& name.equals("out")
&& desc.equals("Ljava/io/PrintStream;")) {
// needs to be loaded to keep stack size valid
super.visitFieldInsn(opcode, Type.getInternalName(Debug.class), "dummyStream", desc);
} else {
super.visitFieldInsn(opcode, owner, name, desc);
}
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String descriptor, boolean isInterface) {
if (owner.equals("java/io/PrintStream") && name.equals("println") && descriptor.equals("(Ljava/lang/String;)V")) {
visitLdcInsn(classId);
visitLdcInsn(pMethodName);
super.visitMethodInsn(
Opcodes.INVOKESTATIC,
Type.getInternalName(Debug.class),
"log",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
false);
} else {
super.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
}
}

@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
if (opcode == Opcodes.GETSTATIC
&& owner.equals("java/lang/System")
&& name.equals("out")
&& desc.equals("Ljava/io/PrintStream;")) {
// needs to be loaded to keep stack size valid
super.visitFieldInsn(opcode, Type.getInternalName(Debug.class), "dummyStream", desc);
} else {
super.visitFieldInsn(opcode, owner, name, desc);
}
}
So I mainly switch out the call to a printStreams println with the call to my logging function and I switch out accessing System.out with fetching a dummy PrintStream (that does nothing) from my Debug class. In bytecode this means that an access to System.out.println is replaced with:
7: getstatic #50 // Field de/tim_greller/susserver/model/execution/instrumentation/Debug.dummyStream:Ljava/io/PrintStream;
10: ldc #13 // String Hello, World!
12: ldc #38 // String Demo#[email protected]
14: ldc #51 // String add
16: invokestatic #55 // Method de/tim_greller/susserver/model/execution/instrumentation/Debug.log:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
7: getstatic #50 // Field de/tim_greller/susserver/model/execution/instrumentation/Debug.dummyStream:Ljava/io/PrintStream;
10: ldc #13 // String Hello, World!
12: ldc #38 // String Demo#[email protected]
14: ldc #51 // String add
16: invokestatic #55 // Method de/tim_greller/susserver/model/execution/instrumentation/Debug.log:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
which in Java means:
PrintStream var10000 = Debug.dummyStream;
Debug.log("Hello, World!", "Demo#[email protected]", "add");
PrintStream var10000 = Debug.dummyStream;
Debug.log("Hello, World!", "Demo#[email protected]", "add");
9 replies
PDProgram Dream
Created by <Tim> on 2/21/2024 in #📦┃project-showcase
Website ─ inn2nation.com
No description
1 replies
PDProgram Dream
Created by <Tim> on 2/17/2024 in #📦┃project-showcase
Client Website ─ EmilBach.de
No description
26 replies
PDProgram Dream
Created by <Tim> on 2/10/2024 in #📦┃project-showcase
Sling Survivor ─ a mobile game
Do you have what it takes to save the kingdom? Show your skills in this blend of strategy, action and survival that has been inspired by the vampire survivors genre! Fight your way through hordes of enemies as you level up and unlock devastating combos. Use your cunning and slingshot skills to dominate the battlegrounds! We recently published our first mobile game in the play store :) https://play.google.com/store/apps/details?id=com.inn2nation.slingshot_survivors
3 replies
PDProgram Dream
Created by <Tim> on 5/21/2023 in #📦┃project-showcase
Go Go Pangolin!
Control a pangolin, eat the termites and rescue the other pangolins. A game created in 48 hours for the Climate Jam 2023. https://brightc.itch.io/gogopangolin
7 replies
PDProgram Dream
Created by <Tim> on 12/17/2022 in #📦┃project-showcase
Haispeed - Can you beat the highscore?
I just finished a game! In just one week we created a 2D endless runner where you have to row with a boat and collect coins. Watch out for the shark tho ^^ https://tim-greller.itch.io/haispeed
20 replies
PDProgram Dream
Created by <Tim> on 8/10/2022 in #💬┃forum
poggers, they made Reddit in Discord??
hehe first. just trying out how this looks yada yada
68 replies