Hot questions for Using Ubuntu in apache

Question:

I'm trying to setup Tomcat in Eclipse. I've already followed this tutorial on how to install Tomcat and I'm even able to see the default Tomcat page at localhost:8080.

What I need now is to setup Tomcat on Eclipse.

I do the following:

Window->Preferences->Server->Runtime Environment->Add->"Apache Tomcat v8.5"

As Tomcat's installation directory I enter /opt/tomcat, as specified in the tutorial linked above in Step 3: Install Tomcat:

We will install Tomcat to the /opt/tomcat directory. Create the directory, then extract the archive to it [...]

But I get the following error:

Unknown version of Tomcat was specified.

As can be seen here:

Some more infos:

  • Tomcat 8.5.20
  • Eclipse Java EE IDE for Web Developers (4.7.0)
  • Ubuntu 17.04

Update:

When I check the permission with ls -ltra /opt/tomcat I get that output:

total 124
drwxr-x---  7 tomcat tomcat  4096 Aug  2 23:36 webapps
-rw-r-----  1 tomcat tomcat 15946 Aug  2 23:36 RUNNING.txt
-rw-r-----  1 tomcat tomcat  7064 Aug  2 23:36 RELEASE-NOTES
-rw-r-----  1 tomcat tomcat  1723 Aug  2 23:36 NOTICE
-rw-r-----  1 tomcat tomcat 57092 Aug  2 23:36 LICENSE
drwxr-xr-x  6 root   root    4096 Aug 11 17:56 ..
drwxr-x---  2 tomcat tomcat  4096 Aug 11 17:56 lib
drwxr-x---  2 tomcat tomcat  4096 Aug 11 17:56 bin
drwxr-x---  2 tomcat tomcat  4096 Aug 12 14:53 .oracle_jre_usage
drwxr-xr-x 10 tomcat tomcat  4096 Aug 12 14:53 .
drwxr-x---  3 tomcat tomcat  4096 Aug 12 14:53 work
drwxr-x---  3 tomcat tomcat  4096 Aug 12 15:01 conf
drwxr-x---  2 tomcat tomcat  4096 Aug 14 17:21 temp
drwxr-x---  2 tomcat tomcat  4096 Aug 14 17:21 logs

Answer:

You really don't want Eclipse and a production installation of Tomcat to mix. The most straightforward thing to do is to download a tarball from http://tomcat.apache.org/ , unpack it, and point the Server->Runtime Environments preference page at that. This lets you sidestep any file permission issues as long as your make sure that they don't try to use the same ports.

Question:

I'm having trouble configuring fonts in apache batik + apache fop svg pdf transcoder.

The config file does not seem to be loaded on properly but only on Ubuntu. I've tried running the exact same code on MacOSX and it works just fine...

Trying to load the same svg on both systems yield different results.

The relevant bit of java is this:

try {
   DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
   Configuration effCfg = cfgBuilder.buildFromFile(new File(this.fontCfgFilePath));
   if (effCfg != null) {
        PDFDocumentGraphics2DConfigurator configurator = new PDFDocumentGraphics2DConfigurator();
        configurator.configure(graphics, effCfg, false);
   } else {
        graphics.setupDefaultFontInfo();
   }
} catch (Exception e) {
   throw new TranscoderException("Error while setting up PDFDocumentGraphics2D", e);
}

but the full version is only a slightly modified version of

https://github.com/naofum/thinreports-java/blob/master/src/com/github/naofum/thinreports/MultiPagePDFTranscoder.java

The only difference is how the config file is passed. in the original the config file is hardcoded in my version is passed via in via the constructor.

this.fontCfgFilePath is set in the constructor with the value "resources/fonts.cfg.xml"

the folder structure is

project/
   resources/
      font.cfg.xml
      fonts/
         0b0b385a-f6e8-4a33-887f-2f178a576139.ttf
         ... a bunch of other fonts ....
   pdf-generator.jar
   ... other files that are not relevant to the problem...

The font.cfg.xml is setup like this

<configuration>
  <fonts>
    ... other fonts ....
    <font kerning="no" embed-url="file:resources/fonts/0b0b385a-f6e8-4a33-887f-2f178a576139.ttf">
        <font-triplet name="Papyrus" style="normal" weight="normal"></font-triplet>
    </font>
    <font kerning="no" embed-url="file:resources/fonts/0b0b385a-f6e8-4a33-887f-2f178a576139.ttf">
        <font-triplet name="Papyrus" style="normal" weight="bold"></font-triplet>
    </font>
    <font kerning="no" embed-url="file:resources/fonts/0b0b385a-f6e8-4a33-887f-2f178a576139.ttf">
        <font-triplet name="Papyrus" style="italic" weight="normal"></font-triplet>
    </font>
    <font kerning="no" embed-url="file:resources/fonts/0b0b385a-f6e8-4a33-887f-2f178a576139.ttf">
        <font-triplet name="Papyrus" style="italic" weight="bold"></font-triplet>
    </font>
    ... other fonts
  </fonts>
</configuration>

The exact same project with the exact same configs if run both on Ubuntu and MacOSX.

MacOSX generates the correct PDF with the correct fonts

Ubuntu does not....

The interesting bit is that Ubuntu does not even try to use the fonts...

If i remove a font from the config file on mac it will not render the font (as expected)

If i change the font file to something invalid, again on mac, it throws FileNotFoundException.

But on Ubuntu none of this matters... Basically it looks like the font file is never read.

I've tried adding the fonts directly in system (at /usr/share/fonts) and force updating the font cache on ubuntu with "fc-cache -fv" but that did not help.

I've also tried various embed-url links (in the config) but it did not have any effect (i.e. changing embed-url="file://resources..." to embed-url="file:///resources..." and other variations).

Both systems run java1.8 (ubuntu in on Oracle JDK 1.8.151 and mac is Oracle JDK 1.8.131)


Answer:

After much searching online and reading source code both in batik/fop and java its self i've found that Batik and FOP need to have fonts present in the java.awt.GraphicsEnvironment

java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment() 

will get the GraphicsEnvironment instance on which you can call

ge.getAvailableFontFamilyNames()

to get an array of currently loaded font families.

Note that .ttf fonts don't need to have font families defined in order to be correctly loaded.

But Batik and FOP DO need to the correct font family to be specified...

As it happens MacOSX knows somehow (upon installing a system level font) to set the correct font family. But GNU/Linux seams to not do the same thing.

If a font is not available system wide (which was the case for me on linux) it has to be registered in java.

That can be done with the GraphicsEnvironment like so:

boolean loaded = ge.registerFont(java.awt.Font.createFont(java.awt.Font/TRUETYPE_FONT, new File("<path to font>"));

if loaded is true then the font was correctly loaded and it will register with batik/fop and render correctly. Note that the font.cfg.xml (from my question) still needs to be present and the path of the font needs to match the regitered font.

if loaded is false then the font was not loaded.

The main reason for this seems to be that a font with the same font family OR the same font name is already registered. (see here http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/sun/font/FontManager.java#2921)

It's also important that the fonts are registered before any rendering happens since batik/fop caches the fonts somewhere and does not refresh them.

The solution in my case was to remove the system font and keep the local one.

So my problem was

  1. none of my .ttf fonts had a proper font family defined

  2. the font's were not registered in java correctly.

My solution was

  1. For 1. Use fontforge to add the correct font family to all my fonts.
  2. For 2. Register all my fonts with the GraphicsEnvironment as decribed above.
  3. Extra Step. Remove all old fonts (the ones without the correct font family) from my ubuntu system because i had added them to see if it fixed anything.

Question:

When I try to run Zeppelin by either

bin/zeppelin.sh

or

bin/zeppelin-deamon.sh start

I was getting the following error message.

Unrecognized VM option 'MaxPermSize=512m'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Java 9 is installed on my system (Ubuntu 16.04).

$ java -version                         
openjdk version "9-internal"
OpenJDK Runtime Environment (build 9-internal+0-2016-04-14-195246.buildd.src)
OpenJDK 64-Bit Server VM (build 9-internal+0-2016-04-14-195246.buildd.src, mixed mode)

Answer:

It appears the MaxPermSize VM option is no longer supported in Java 9. Perhaps they changed the parameter name or something. Instead of digging into this issue further, as I had no particular reason to insist on using Java 9, I installed Java 8 as follows:

sudo apt install openjdk-8-jdk

And made it a default Java environment

sudo update-alternatives --config java

This fixed the issue.

Question:

I am trying to upload a file to an FTP server. This is my code:

FTPClient ftpClient = new FTPClient();
try {
    List<PoiCmsRule> appPois = getAllRules();
    try (FileWriter writer = new FileWriter(backupFile)) {
        new Gson().toJson(backupData, writer);
    }
    try (FileInputStream fis = new FileInputStream(backupFile)) {
        ftpClient.connect(host);
        ftpClient.login(login, password);
        ftpClient.storeFile("backup.json", fis);
        ftpClient.logout();
    }
} catch (Exception e) {
    log.error(e.getMessage(), e);
} finally {
    try {
        ftpClient.disconnect();
    } catch (IOException e) {
        log.error(e.getMessage(), e);
    }
}

And it works perfectly fine when I run this on localhost. But when I run in on server I get this exception:

Caused by: java.net.SocketException: Connection reset
    at java.base/java.net.SocketInputStream.read(SocketInputStream.java:186)
    at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
    at java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
    at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)

I think it indicates I might have some problems with the firewall or proxy.

This is a Spring Boot app run on the Ubuntu server with Nginx as a proxy.

How can I find what is causing this exception?


Logs from a successful connection with command-line ftp in passive mode:

ubuntu@ip-server:~$ ftp -p -d my_host
Connected to my_host
220 FTP-Server
ftp: setsockopt: Bad file descriptor
Name (my_host): username
---> USER username
331 Please specify the password.
Password:
---> PASS XXXX
230 Login successful.
---> SYST
215 UNIX Type: L8
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
ftp: setsockopt (ignored): Permission denied
---> PASV
227 Entering Passive Mode (153,92,207,128,127,65)
---> LIST
150 Here comes the directory listing.
// file list
226 Directory send OK.
ftp>

Answer:

Apache Commons Net FTPClient defaults to the FTP active mode. The active mode hardly ever works these days due to ubiquitous firewalls and NATs (for details, see my article on FTP active/passive connection modes).

To switch FTPClient to the passive mode, call FTPClient.enterLocalPassiveMode somewhere after FTPClient.connect:

ftpClient.connect(host);
ftpClient.login(login, password);
ftpClient.enterLocalPassiveMode();

Question:

I have currently deployed an application which used to work fine until i decided to extend /home/ubuntu volume. I attached another volume and copied all the contents of /home/ubuntu to the new volume and now the new volume is /home/ubuntu, I am able to login and all the permissions are fine.

My tomcat java application was working fine until I made this change, Now evey time I make a any of the POST,get,update calls my logs show

2019-06-10 16:55:08 ERROR ApplicationExceptionHandler:47 - MultipartException org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. /home/ubuntu/upload_xxxxxxxxxxxxxxxxxxxxx.tmp (Permission Denied)

Now I noticed this is a permission issue and just to test it i assigned -R 777 to /home/ubuntu, The application is able to respond to my REST calls, but as expected I am unable to login with the my private key because of the permission change thing, I just made it -R 755 and can login but the application cant respond to REST calls.

How do I fix this?


Answer:

Check your /etc/systemd/system/tomcat.service file to see which user is running Tomcat. (usually user "tomcat")

Then run this command to give user "tomcat", group "tomcat" ownership of /home/ubuntu

chown -R tomcat:tomcat /home/ubuntu

https://gist.github.com/drmalex07/e6e99dad070a78d5dab24ff3ae032ed1

Question:

I am having a problem with the maven compiling in the ubuntu 16. The same code it is compiling into others machines, so looks like the problem it is related to some environmental change, probably automatic update.

If I spend one more day stuck on this, I probably will try format the machine and start from scratch. But, maybe, this question could help other people to find the solution and don't have to do that too.

$ mvn compile

[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ my-project ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/me/projects/my-project/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.5:compile (default-compile) @ my-project ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 28 source files to /home/me/projects/my-project/target/classes
An exception has occurred in the compiler (9.0.4). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.time.DateTimeException: Invalid value for MonthOfYear (valid values 1 - 12): 0
    at java.base/java.time.temporal.ValueRange.checkValidValue(ValueRange.java:311)
    at java.base/java.time.temporal.ChronoField.checkValidValue(ChronoField.java:714)
    at java.base/java.time.LocalDate.of(LocalDate.java:269)
    at java.base/java.time.LocalDateTime.of(LocalDateTime.java:336)
    at jdk.zipfs/jdk.nio.zipfs.ZipUtils.dosToJavaTime(ZipUtils.java:109)
    at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem$Entry.cen(ZipFileSystem.java:1950)
    at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem$Entry.readCEN(ZipFileSystem.java:1937)
    at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.getEntry(ZipFileSystem.java:1324)
    at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.newInputStream(ZipFileSystem.java:550)
    at jdk.zipfs/jdk.nio.zipfs.JarFileSystem.isMultiReleaseJar(JarFileSystem.java:91)
    at jdk.zipfs/jdk.nio.zipfs.JarFileSystem.<init>(JarFileSystem.java:67)
    at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:134)
    at jdk.compiler/com.sun.tools.javac.file.JavacFileManager$ArchiveContainer.<init>(JavacFileManager.java:517)
    at jdk.compiler/com.sun.tools.javac.file.JavacFileManager.getContainer(JavacFileManager.java:319)
    at jdk.compiler/com.sun.tools.javac.file.JavacFileManager.list(JavacFileManager.java:715)
    at jdk.compiler/com.sun.tools.javac.code.ClassFinder.list(ClassFinder.java:722)
    at jdk.compiler/com.sun.tools.javac.code.ClassFinder.scanUserPaths(ClassFinder.java:655)
    at jdk.compiler/com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:526)
    at jdk.compiler/com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:293)
    at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:633)
    at jdk.compiler/com.sun.tools.javac.code.Symbol$PackageSymbol.members(Symbol.java:1120)
    at jdk.compiler/com.sun.tools.javac.code.Symtab.listPackageModules(Symtab.java:810)
    at jdk.compiler/com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:344)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:529)
    at jdk.compiler/com.sun.tools.javac.comp.Enter.classEnter(Enter.java:285)
    at jdk.compiler/com.sun.tools.javac.comp.Enter.classEnter(Enter.java:300)
    at jdk.compiler/com.sun.tools.javac.comp.Enter.complete(Enter.java:570)
    at jdk.compiler/com.sun.tools.javac.comp.Enter.main(Enter.java:554)
    at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1052)
    at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:923)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:100)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:142)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:96)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:90)
    at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:125)
    at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:171)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:884)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] An unknown compilation problem occurred
[INFO] 1 error
[INFO] -------------------------------------------------------------

Extra informations:

$ mvn version

Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 9.0.4, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-9-oracle
Default locale: en_NZ, platform encoding: UTF-8
OS name: "linux", version: "4.13.0-32-generic", arch: "amd64", family: "unix"

$ java -version

java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

$ lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:    16.04
Codename:   xenial

pom.xml:

        ...
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5</version>
            <!-- 
               already try to fix using
               <version>3.7.0</version>
            -->
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.19.1</version>
            ...
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.0.2</version>
        </plugin>
        ...

Commands that I already have tested trying to fix that, with no success:

$ sudo apt-get update; sudo apt-get upgrade 
$ mvn -U clean package
$ sudo update-alternatives --config java # changing to oracle java 8
$ sudo update-alternatives --config java # changing to open jdk 8
$ sudo update-alternatives --config java # changing to oracle java 9
$ sudo update-alternatives --config java # changing to open jdk 9
$ mvn dependency:resolve -U

Links that could be useful, but could not fix the problem:

https://bugs.openjdk.java.net/browse/JDK-8196777

Updating...

The problem happens only when:

  • one internal project is into the maven dependency;
  • the project has at least one unitary test, even if the unitary test does nothing.
  • The project has at least one class, even if that class does nothing.

Now, I am trying to load this dependent project as source code to try to discover what is the call, class or method that trigger the problem.

In time, we try to test the same code with the problem "isolated" into another machine, and everything worked. So, for now, the problem looks like be the result of a combination of some java call executed in a special environment.

<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>my.projects</groupId>
        <artifactId>project-parent</artifactId>
        <version>1.234.567</version>
    </parent>
    <artifactId>my-buggy-project</artifactId>
    <version>0.${minor.version}</version>
    <properties>
        <minor.version>123.456.789</minor.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>my.projects.models</groupId>
            <artifactId>models</artifactId>
            <version>111.222.333</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>my-buggy-project</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Answer:

The problem is caused by the package beam-sdks-java-core in the version 2.2.0. This package was being loaded into the package my.projects.models.

Here is the isolated program that replicates the same error message:

./pom.xml
 <?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mock.bug</groupId>
    <artifactId>mock-bug</artifactId>
    <version>0.123</version>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.beam</groupId>
            <artifactId>beam-sdks-java-core</artifactId>
            <version>2.2.0</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
./src/main/java/com/mock/bug/Main.java
 package com.mock.bug;

public class Main {
    public void main(String[] input){
        System.out.println("hello workd");
    }
}
./src/test/java/com/mock/bug/DummyHealthCheckTest.java
package com.mock.bug;

import org.junit.Test;

import static org.junit.Assert.*;

public class DummyHealthCheckTest {
    @Test
    public void DummyCheckTest() {
        boolean t = true;
        assertTrue(t);
    }
}
Command to fire the error message:
mvn -U clean package

If we change the beam-sdks-java-core version from 2.2.0 to 2.1.0, the project can be successfully compiled and tested.

While this information is not enough to fix the issues or to inform why this is only happening on some machines, I believe that is the best answer that can be extracted from this.

I have created one issue request about it with the Apache Beam team https://issues.apache.org/jira/browse/BEAM-3693

Question:

We have installed kafka on a Linux Ubuntu server and tested the communication using the batch files - kafka-console-producer.sh and kafka-console-consumer.sh and found that we can publish and receive messages

On a windows machine running on the same network . We wrote a java producer client , whose code is shown

Properties properties = new Properties();
properties.put("metadata.broker.list","192.168.7.1:9092");
properties.put("serializer.class","kafka.serializer.StringEncoder");
ProducerConfig producerConfig = new ProducerConfig(properties);
kafka.javaapi.producer.Producer<String,String> producer = new kafka.javaapi.producer.Producer<String, String>(producerConfig);
KeyedMessage<String, String> message =new KeyedMessage<String, String>("Calamp2","Test message from java program ");
producer.send(message);
producer.close();

When we run the client, we are getting the following error

log4j:WARN No appenders could be found for logger (kafka.utils.VerifiableProperties). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. Failed to send messages after 3 tries.

We tried the following

  1. Pinged the ubuntu machine from Windows machine and it seems to be working fine
  2. Tried the solution from Apache Kafka example error: Failed to send message after 3 tries , but it did not work

One strange thing we observed that when we ran the following command on the server - bin/kafka-topics.sh --list --zookeeper localhost:2181 , We found that topics were created from the Java code , but message was not published

Any help is appreciated


Answer:

We finally figured out the issue... We were running kafka in a hybrid evironment as mentioned in the following post -

https://medium.com/@thedude_rog/running-kafka-in-a-hybrid-cloud-environment-17a8f3cfc284

We changed the host.name to the internal IP and advertised.host.name to external IP. This was the same problem as Kafka 0.8.2.2 - Unable to publish messages

Question:

I'm facing this problem when I have installed Apache Storm on two machines on AWS EC2 Amazon

storm list

Running: java -client -apache-storm-0.9.4/bin backtype.storm.command.list
53149 [main] INFO  backtype.storm.thrift - Connecting to Nimbus at 172.31.32.97:6627
Exception in thread "main" org.apache.thrift7.transport.TTransportException: java.net.ConnectException: Connection refused

Answer:

The problem was Nimbus could not connect with Zookeeper nodes on other machines due to the ports of Nimbus and Zookeeper were not opened .The security was the problem on the machines and the port 2181 of Zookeeper was closed on machines. I solved the problem by setting the ports of Nimbus and zookeepers are open. If you need more description about the answer, just write comment.

Question:

I have manually downloaded apache-tomcat-7.0.54.tar.gz and unpack it in /usr/local/. I have searched for proxy configuration on many websites but they are talking about httpd.conf or apache2.conf and ./configure file. I searched many times for these files in /usr/local/apache-tomcat-7.0.54 but i find nothing.

Please tell me, proxy configuration is possible with apache-tomcat-7.0.54 or not. If it is not possible than tell me how is it possible?

Should i use apache and tomcat both for proxy setting?

please suggest me any way to do proxy configuration for tomcat.


Answer:

You you use the startup or catalina scripts you can certainly use the environment to do that, try setting a JAVA_OPTS variable to something like

-Dhttp.proxyHost=<proxy> 
-Dhttp.proxyPort=<port> 
-Dhttps.proxyHost=<proxy> 
-Dhttps.proxyPort=<port> 
-Dhttp.nonProxyHosts=<domain_one>|<domain two> $JAVA_OPTS

Best regards, Dido

Question:

I'm trying to use a class on my index.jsp file on tomcat 7.0.52. I'm running the webapp using a WAR file, /test/WEB-INF/classes/matrix.class compiled it from matrix.java in the same directory. I get the error

An error occurred at line: [14] in the generated java file: [/var/lib/tomcat7/work/Catalina/localhost/test2/org/apache/jsp/index_jsp.java] The import my_matrix cannot be resolved

index.jsp:

<%@page import="my_matrix"%>

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Apache Tomcat</title>
</head>

<body>
<%
    System.out.println( "Evaluating date now" );
    java.util.Date date = new java.util.Date();
%>
Hello!  The time is now
<%
    out.println( date );
    out.println( "<BR>Your machine's address is " );
    out.println( request.getRemoteHost());
    matrix test = new matrix();
%>

<br><br>

<form method="get">
    <td><input type="number" name="lim" value="0"></td>
    <input type="submit" value="Submit">
</form>

<% 
    int n = 0;

    if(request.getParameter("lim") != null)
        n = Integer.parseInt(request.getParameter("lim")); 
%>

<TABLE BORDER=2>
<%
    for ( int i = 0; i < n; i++ ) {
        %>
        <TR>
        <TD>Number</TD>
        <TD><%= i+1 %></TD>
        </TR>
        <%
    }
%>
</TABLE>
</body>
</html>

matrix.class (matrix.java):

package my_matrix;
public class matrix
{   
   public void myMatrix()
   {
     System.out.println("dbpool evidence!");
   }
}

Answer:

The class is defined as

package my_matrix;
public class matrix

and you're importing like this:

<%@page import="my_matrix"%>

Java cannot import classes in the default package on classes within one. So make sure you have the matrix class in the correct classpath: /test/WEB-INF/classes/my_matrix/matrix and import using the class name: <%@page import="my_matrix.matrix"%>

Additionaly, take into account that just importing a class won't invoke its main() method automatically.