soupui post api download file
https://www.soapui.org/getting-started/working-with-soapui/saving-responses/
https://community.smartbear.com/discussions/readyapi-questions/resdump-file-option-for-request-properties-is-not-editable/39116
haproxy-2.6.6
was able to run with user root
but haproxy-3.0.6
hit error:
haproxy[384105]: [ALERT] (384105) : [/usr/local/sbin/haproxy.main()] Cannot chroot(/opt/haproxy/chroot).
The fact that HAProxy 2.6.6 ran as root while HAProxy 3.0.6 fails with a chroot
error when run as root indicates a key difference: HAProxy 2.6.6 was not actually using chroot, even if the directive was present in the configuration file. Running as root bypasses the chroot
setup because root has access to the entire filesystem. The chroot
directive was effectively being ignored.
With HAProxy 3.0.6, the chroot
is being correctly enforced. Since the chroot
environment (/opt/haproxy/chroot
) is likely missing the necessary files for HAProxy to run (its binary, libraries, configuration, etc.), it fails to start.
Here's what to do:
Confirm chroot
necessity: Do you actually need chroot
? If not, remove the chroot /opt/haproxy/chroot
line from your /etc/haproxy/haproxy.cfg
. This is often the simplest and best solution.
If chroot
is required:
chroot
environment: Copy the necessary files into /opt/haproxy/chroot
. This includes the HAProxy binary, required libraries (use ldd /usr/local/sbin/haproxy
to find them), your haproxy.cfg
file, and any other files HAProxy needs (e.g., certificates). Remember, the paths inside the chroot
must match the paths HAProxy expects. So, if a library is normally in /lib64/
, it needs to be in /opt/haproxy/chroot/lib64/
./opt/haproxy/chroot
have the correct permissions for the user HAProxy runs as within the chroot
.Alternatives: Consider alternatives to chroot
, such as Docker or systemd's isolation features, which are easier to manage and often provide better security.
The key takeaway: your HAProxy 2.6.6 was likely not using chroot
at all, even if the directive was present in the configuration. The root user bypassed the chroot
restriction. Now, with 3.0.6, the chroot
is being enforced, hence the error. Either populate the chroot
or, better yet, remove the chroot
directive if it's not essential.
/var/log/tomcat5/base/*.txt {
su tomcat tomcat
notifempty
copytruncate
weekly
rotate 52
compress
missingok
}
/var/log/tomcat5/base/catalina.out {
su tomcat tomcat
notifempty
copytruncate
weekly
rotate 52
compress
missingok
}
<!--
[ERROR]
.../generated/AcademicTitleCode.java:[11,33]
package javax.xml.bind.annotation does not exist
-->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<!--
<version>4.0.0</version>
-->
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<!--
<version>4.0.0</version>
<scope>runtime</scope>
-->
</dependency>
<!--
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>4.0.0</version>
</dependency>
-->
<!--
https://github.com/FasterXML/jackson-modules-base/discussions/239
-->
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
The EclipseAdoptium.Temurin packages are currently split as two separate packages: EclipseAdoptium.Temurin and EclipseAdoptium.TemurinJRE. I feel like it would be beneficial if, for clarity, the packages matched more like the ojdkbuild packages on here. (Shown below)
You can see some link files of unit services and some directories of the “wants” of a target. For example, what the multi-user target wants to be loaded when the boot procedure reaches its level, is listed in the directory with name /etc/systemd/system/multi-user.target.wants/.
As you can see it doesn’t contain only services but also other targets which are also collections of services.
Let’s make a service unit with the name connection.service.
# vim connection.service
and type the following (hit “i”
for insert mode), save it, and exit (with “esc”
and “:wq!”
) :
[Unit] Description = making network connection up After = network.target [Service] ExecStart = /root/scripts/conup.sh [Install] WantedBy = multi-user.target
You should change the declaration of out
to be of type ByteArrayOutputStream
rather than just OutputStream
. Then you can call ByteArrayOutputStream.toByteArray()
to get the bytes, and construct a ByteArrayInputStream
wrapping that.
As an aside, I wouldn't catch Exception
like that, and I'd use a try-with-resources statement to close the document, assuming it implements AutoCloseable
. It's also a good idea to follow Java naming conventions. So for example, you might have:
public InputStream createPdf() throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (Document doc = new Document(PageSize.A4, 50, 50, 50, 50)) {
PdfWriter writer = PdfWriter.getInstance(doc, out);
doc.open();
PdfPTable table = new PdfPTable(1);
PdfPCell cell = new PdfPCell(new Phrase("First PDF"));
cell.setBorder(Rectangle.NO_BORDER);
cell.setRunDirection(PdfWriter.RUN_DIRECTION_LTR);
table.addCell(cell);
doc.add(table);
}
return new ByteArrayInputStream(out.toByteArray());
}
/****/package test.com.report.daily;import static org.junit.jupiter.api.Assertions.*;import java.io.ByteArrayOutputStream;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.nio.file.Files;import java.nio.file.Paths;import java.text.DateFormat;import java.text.SimpleDateFormat;import java.util.Calendar;import org.apache.commons.lang3.StringUtils;import org.junit.jupiter.api.AfterEach;import org.junit.jupiter.api.BeforeAll;import org.junit.jupiter.api.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import com.itextpdf.kernel.geom.PageSize;import com.itextpdf.kernel.pdf.PdfDocument;import com.itextpdf.kernel.pdf.PdfReader;import com.itextpdf.kernel.pdf.PdfWriter;import com.itextpdf.kernel.pdf.canvas.parser.PdfTextExtractor;import com.itextpdf.layout.Document;import com.itextpdf.layout.element.Paragraph;import com.itextpdf.layout.element.Text;/*** @author Billson C**/class TestByteArrayOf_iTextPdfToFile{private static final Logger _LOG = LoggerFactory.getLogger(TestByteArrayOf_iTextPdfToFile.class);String pathRoot = "C:\\samples\\";@BeforeAllstatic void setUpBeforeClass() throws Exception {}@AfterEachvoid tearDown() throws Exception {}String pathSeperator = "/";DateFormat _DTF = new SimpleDateFormat("HHmm");@Testvoid test() throws IOException {String currentPathFolder = null;String currentPathFile = null;String currentTimingGenerated = _DTF.format(Calendar.getInstance().getTime());currentPathFolder = StringUtils.join(pathRoot, pathSeperator, currentTimingGenerated, pathSeperator// , currentPortLocationCode);Files.createDirectories(Paths.get(currentPathFolder));String dash = "-";String filename = StringUtils.join("bytearray-of-itext-pdf-to-file", ".", "pdf");String content = StringUtils.join("The filename of this file is: ", filename);currentPathFile = StringUtils.join(currentPathFolder, pathSeperator, filename);File fPdf = new File(currentPathFile);try (FileOutputStream fosPdf = new FileOutputStream(fPdf);) {byte[] aryByte = _getAryByteOfPdf(content);fosPdf.write(aryByte);// outputStream.writeTo(fosPdf);} catch (Exception e) {_LOG.error("Error while test|{}", e.getMessage(), e);}assertTrue(fPdf.exists());// TO DO: suppose to check file content equal to filenameString contentFromPdf = PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(fPdf)).getFirstPage());_LOG.debug("contentFromPdf|{}", contentFromPdf);assertEquals(content, contentFromPdf);}/*** @param content*/protected byte[] _getAryByteOfPdf(String content) {try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream();PdfWriter pdfWriter = new PdfWriter(outputStream);// PdfWriter pdfWriter = new PdfWriter(currentPathFile);Document document = new Document(new PdfDocument(pdfWriter// new PdfWriter("./hello-pdf.pdf")), PageSize.A4.rotate())) {document.add(new Paragraph(new Text(content)));document.close();return outputStream.toByteArray();} catch (Exception e) {e.printStackTrace();return null;}}}