Peter Rader
Peter Rader
JCHJava Community | Help. Code. Learn.
Created by Peter Rader on 8/14/2024 in #java-help
Huge WSDL produce a jdk.internal.org.objectweb.asm.MethodTooLargeException
There is a wsdl that is huge. https://raw.githubusercontent.com/attester/virtualbox-soap/master/sdk-files/vboxweb.wsdl The wsdl has a portType (vboxPortType) having about 10.000 lines of code. The wsdl generate a java-interface (org.virtualbox.service.VboxPortType) having 35k lines / 1800 methods. This is the stacktrace:
Exception in thread "Thread-6" jdk.internal.org.objectweb.asm.MethodTooLargeException: Method too large: jdk/proxy3/$Proxy555.<clinit> ()V
at java.base/jdk.internal.org.objectweb.asm.MethodWriter.computeMethodInfoSize(MethodWriter.java:2120)
at java.base/jdk.internal.org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:543)
at java.base/java.lang.reflect.ProxyGenerator.generateClassFile(ProxyGenerator.java:506)
at java.base/java.lang.reflect.ProxyGenerator.generateProxyClass(ProxyGenerator.java:178)
at java.base/java.lang.reflect.Proxy$ProxyBuilder.defineProxyClass(Proxy.java:542)
at java.base/java.lang.reflect.Proxy$ProxyBuilder.build(Proxy.java:655)
at java.base/java.lang.reflect.Proxy.lambda$getProxyConstructor$1(Proxy.java:438)
at java.base/jdk.internal.loader.AbstractClassLoaderValue$Memoizer.get(AbstractClassLoaderValue.java:329)
at java.base/jdk.internal.loader.AbstractClassLoaderValue.computeIfAbsent(AbstractClassLoaderValue.java:205)
at java.base/java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:436)
(...)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:373)
at jakarta.xml.ws.Service.getPort(Service.java:139)
at org.virtualbox.service.VboxService.getVboxServicePort(VboxService.java:72)
at org.virtualbox.PortPool.getPort(VirtualBoxManager.java:134)
at org.virtualbox.PortPool.preinit(VirtualBoxManager.java:110)
at org.virtualbox.PortPool$1.run(VirtualBoxManager.java:93)
at java.base/java.lang.Thread.run(Thread.java:1570)
Exception in thread "Thread-6" jdk.internal.org.objectweb.asm.MethodTooLargeException: Method too large: jdk/proxy3/$Proxy555.<clinit> ()V
at java.base/jdk.internal.org.objectweb.asm.MethodWriter.computeMethodInfoSize(MethodWriter.java:2120)
at java.base/jdk.internal.org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:543)
at java.base/java.lang.reflect.ProxyGenerator.generateClassFile(ProxyGenerator.java:506)
at java.base/java.lang.reflect.ProxyGenerator.generateProxyClass(ProxyGenerator.java:178)
at java.base/java.lang.reflect.Proxy$ProxyBuilder.defineProxyClass(Proxy.java:542)
at java.base/java.lang.reflect.Proxy$ProxyBuilder.build(Proxy.java:655)
at java.base/java.lang.reflect.Proxy.lambda$getProxyConstructor$1(Proxy.java:438)
at java.base/jdk.internal.loader.AbstractClassLoaderValue$Memoizer.get(AbstractClassLoaderValue.java:329)
at java.base/jdk.internal.loader.AbstractClassLoaderValue.computeIfAbsent(AbstractClassLoaderValue.java:205)
at java.base/java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:436)
(...)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:373)
at jakarta.xml.ws.Service.getPort(Service.java:139)
at org.virtualbox.service.VboxService.getVboxServicePort(VboxService.java:72)
at org.virtualbox.PortPool.getPort(VirtualBoxManager.java:134)
at org.virtualbox.PortPool.preinit(VirtualBoxManager.java:110)
at org.virtualbox.PortPool$1.run(VirtualBoxManager.java:93)
at java.base/java.lang.Thread.run(Thread.java:1570)
11 replies
JCHJava Community | Help. Code. Learn.
Created by Peter Rader on 6/27/2024 in #java-help
InvocationTargetException using JCI
I try to run a simple main to compile(!) some java code. This is my pom:
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>a</groupId>
<artifactId>a</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>22</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-jci-javac</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>a</groupId>
<artifactId>a</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>22</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-jci-javac</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
And this is my main-class:
package a;

import java.nio.charset.StandardCharsets;

import org.apache.commons.jci.compilers.*;
import org.apache.commons.jci.readers.MemoryResourceReader;
import org.apache.commons.jci.stores.MemoryResourceStore;

public class Test {
public static void main(final String[] args) {
JavaCompilerFactory cf = new JavaCompilerFactory();
JavaCompiler compiler = cf.createCompiler("javac");
MemoryResourceReader pReader = new MemoryResourceReader();
int i = 0;
pReader.add("Test.java", "class Test{}".getBytes(StandardCharsets.UTF_8));
MemoryResourceStore pStore = new MemoryResourceStore();
CompilationResult result = compiler.compile(new String[] { pReader.list()[0] }, pReader, pStore,
Test.class.getClassLoader());
System.out.println(result.getErrors()[0]);
}
}
package a;

import java.nio.charset.StandardCharsets;

import org.apache.commons.jci.compilers.*;
import org.apache.commons.jci.readers.MemoryResourceReader;
import org.apache.commons.jci.stores.MemoryResourceStore;

public class Test {
public static void main(final String[] args) {
JavaCompilerFactory cf = new JavaCompilerFactory();
JavaCompiler compiler = cf.createCompiler("javac");
MemoryResourceReader pReader = new MemoryResourceReader();
int i = 0;
pReader.add("Test.java", "class Test{}".getBytes(StandardCharsets.UTF_8));
MemoryResourceStore pStore = new MemoryResourceStore();
CompilationResult result = compiler.compile(new String[] { pReader.list()[0] }, pReader, pStore,
Test.class.getClassLoader());
System.out.println(result.getErrors()[0]);
}
}
My output is: (0:0) : Error while executing the compiler: java.lang.reflect.InvocationTargetException What am I doing wrong?
67 replies
JCHJava Community | Help. Code. Learn.
Created by Peter Rader on 6/21/2024 in #java-help
Switch from commons-fileupload to commons-fileupload-jakarta-servlet6
I need to change my fileupload-integration to the jakarta6-version. The old code is
resp.setHeader("Transfer-Encoding", "chunked");
byte timeout = parseTimeoutParameter(req);
int port = parsePortParameter(req);
long expLen = Long.valueOf(req.getHeader(HttpHeaders.CONTENT_LENGTH));
ServletFileUpload upload = new ServletFileUpload();
ServletOutputStream servletOut = resp.getOutputStream();
FileItemIterator itemIterator = upload.getItemIterator(req);
while (itemIterator.hasNext()) {
FileItemStream streamItem = itemIterator.next();
if (streamItem.getFieldName().equals("ova")) {
String nameWithoutQuotas = streamItem.getName();
nameWithoutQuotas = nameWithoutQuotas.substring(0, nameWithoutQuotas.lastIndexOf('.'));
File tf = File.createTempFile("ova-rm", ".ova");
FileOutputStream fos = new FileOutputStream(tf);
copy(streamItem.openStream(), fos, servletOut, 1024 * 8, expLen);
fos.close();
try {
app.getBean(OVAImporter.class).importOVA(tf, nameWithoutQuotas, timeout, port);
} catch (Exception e) {
throw new ServletException(e);
}
}
}


resp.setHeader("Transfer-Encoding", "chunked");
byte timeout = parseTimeoutParameter(req);
int port = parsePortParameter(req);
long expLen = Long.valueOf(req.getHeader(HttpHeaders.CONTENT_LENGTH));
ServletFileUpload upload = new ServletFileUpload();
ServletOutputStream servletOut = resp.getOutputStream();
FileItemIterator itemIterator = upload.getItemIterator(req);
while (itemIterator.hasNext()) {
FileItemStream streamItem = itemIterator.next();
if (streamItem.getFieldName().equals("ova")) {
String nameWithoutQuotas = streamItem.getName();
nameWithoutQuotas = nameWithoutQuotas.substring(0, nameWithoutQuotas.lastIndexOf('.'));
File tf = File.createTempFile("ova-rm", ".ova");
FileOutputStream fos = new FileOutputStream(tf);
copy(streamItem.openStream(), fos, servletOut, 1024 * 8, expLen);
fos.close();
try {
app.getBean(OVAImporter.class).importOVA(tf, nameWithoutQuotas, timeout, port);
} catch (Exception e) {
throw new ServletException(e);
}
}
}


. Using the new version I have this constructor: new JakartaServletFileUpload<FileItem<I>, FileItemFactory<I>>();. How to use the constructor properly?
24 replies
JCHJava Community | Help. Code. Learn.
Created by Peter Rader on 4/23/2024 in #java-help
Live only exception with jaxb
Iv got an exception that I can not reproduce locally.
java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 16
at com.sun.xml.bind.v2.util.CollisionCheckStack.pushNocheck(CollisionCheckStack.java:102)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:457)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:298)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:226)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:80)
at de.e_nexus.server.i8n.TranslationArtifactExposer.writeMetadata(TranslationArtifactExposer.java:269)
java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 16
at com.sun.xml.bind.v2.util.CollisionCheckStack.pushNocheck(CollisionCheckStack.java:102)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:457)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:298)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:226)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:80)
at de.e_nexus.server.i8n.TranslationArtifactExposer.writeMetadata(TranslationArtifactExposer.java:269)
This is the writeMetadata method:
private boolean writeMetadata(final TranslationMavenRelevation o, final ByteArrayOutputStream baos) {
try {
Metadata md = prepareMetadata(o);
md.setVersioning(new Versioning());
TranslationStack stack = o.getStack();

String currentProjectVersion = generateVersionNumber(o, stack);
md.getVersioning().setLatest(currentProjectVersion);
if (fin.isFinal(currentProjectVersion)) {
md.getVersioning().setRelease(currentProjectVersion);
}

List<Version> versions = md.getVersioning().getVersions();
Version e = new Version();
e.setVersion(currentProjectVersion);
versions.add(e);
marshaller.getMetadataMarshaller().marshal(md, baos);
return true;
} catch (JAXBException ex) {
LOG.log(Level.SEVERE, "Can not marshall!", ex);
return false;
}
}
private boolean writeMetadata(final TranslationMavenRelevation o, final ByteArrayOutputStream baos) {
try {
Metadata md = prepareMetadata(o);
md.setVersioning(new Versioning());
TranslationStack stack = o.getStack();

String currentProjectVersion = generateVersionNumber(o, stack);
md.getVersioning().setLatest(currentProjectVersion);
if (fin.isFinal(currentProjectVersion)) {
md.getVersioning().setRelease(currentProjectVersion);
}

List<Version> versions = md.getVersioning().getVersions();
Version e = new Version();
e.setVersion(currentProjectVersion);
versions.add(e);
marshaller.getMetadataMarshaller().marshal(md, baos);
return true;
} catch (JAXBException ex) {
LOG.log(Level.SEVERE, "Can not marshall!", ex);
return false;
}
}
4 replies
JCHJava Community | Help. Code. Learn.
Created by Peter Rader on 4/7/2024 in #java-help
HQL not working. Gives strange Exception in console.
How could that happen? I have this HQL: SELECT mfr.id FROM EMailToEMailFolderOrdered mfr WHERE NOT(SIZE(mfr.EMail) = MAX(mfr.orderNumber) AND MIN(mfr.orderNumber)=1) GROUP BY mfr.id
55 replies
JCHJava Community | Help. Code. Learn.
Created by Peter Rader on 3/26/2024 in #java-help
HQL very slow
A HQL query I use is very slow.
SELECT
CONCAT(t.javaType,
'µ',
t.systemName) as v,
CASE
WHEN SIZE(t.SQLDatabaseColumns) > 0 THEN CONCAT(t.systemName,
' (',
SIZE(t.SQLDatabaseColumns),
')')
ELSE t.systemName
END as name
FROM
SQLDatabaseType t
WHERE
t.database.id = :db
ORDER BY
SIZE(t.SQLDatabaseColumns) DESC,
LENGTH(t.systemName) ASC,
SUBSTR(t.systemName,
1,
1) DESC
SELECT
CONCAT(t.javaType,
'µ',
t.systemName) as v,
CASE
WHEN SIZE(t.SQLDatabaseColumns) > 0 THEN CONCAT(t.systemName,
' (',
SIZE(t.SQLDatabaseColumns),
')')
ELSE t.systemName
END as name
FROM
SQLDatabaseType t
WHERE
t.database.id = :db
ORDER BY
SIZE(t.SQLDatabaseColumns) DESC,
LENGTH(t.systemName) ASC,
SUBSTR(t.systemName,
1,
1) DESC
What the query should do: The Query should output two columns: 1. Integerµint8 as a concat of the java-type, the letter 'µ' and then the database-native type. 2. int8 (29) what means that the type int8 is used 29 times. Ok, the reason why this query is slow is: SIZE(t.SQLDatabaseColumn) is executed multiple times. How to improve the speed in HQL?
4 replies