You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by Nathaniel Belles <mo...@gmail.com> on 2024/03/09 23:08:02 UTC
Simple modification to Event Listener example throwing runtime errors
Hello,
I’m currently trying to write a simple extension for guacamole that allows for push notifications through web hooks. The extension of course relies a lot on guacamole's event listeners. The documentation shows a very simple example (TutorialListener.java) of these event listeners which I have added to the `guacamole-client/extensions/` folder, compiled and then added the extension jar to the extensions folder of my guacamole instance. This example runs just fine and produces debugging output as expected. But when I try to extend the functionality, even just to store a copy of the `AuthenticationProvider` object from the event after including the `import org.apache.guacamole.net.auth.AuthenticationProvider;` line at the top of the file, I am able to compile the extension but then at runtime I get the following: `Unexpected internal error: 'org.apache.guacamole.net.auth.AuthenticationProvider org.apache.guacamole.net.event.AuthenticationFailureEvent.getAuthenticationProvider()'`.
I started looking through the code and I have found that there is a `.getAuthenticationProvider()` function in the `AuthenticationFailureEvent.java` file so I know that I’m using the write function. I also found similar instances of the `AuthenticationFailureEvent` being used in the `EventLoggingListener.java` file and tried to replicate the imports and logic used for the guacamole-client. Do I need to do something special to get proper access to the object types?
I have included the tutorial example with the problematic line notated. That line is the only one added from the off-the-shelf tutorial. If I comment it out, it runs perfectly fine. If I uncomment it, it throws the error mentioned above.
Thanks!
Code:
package org.apache.guacamole.event;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.net.auth.AuthenticationProvider;
import org.apache.guacamole.net.event.AuthenticationFailureEvent;
import org.apache.guacamole.net.event.AuthenticationSuccessEvent;
import org.apache.guacamole.net.event.listener.Listener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A Listener that logs authentication success and failure events.
*/
public class Notifier implements Listener {
private static final Logger logger = LoggerFactory.getLogger(Notifier.class);
@Override
public void handleEvent(Object event) throws GuacamoleException {
if (event instanceof AuthenticationSuccessEvent) {
logger.info("successful authentication for user {}",
((AuthenticationSuccessEvent) event)
.getCredentials().getUsername());
} else if (event instanceof AuthenticationFailureEvent) {
logger.info("failed authentication for user {}",
((AuthenticationFailureEvent) event)
.getCredentials().getUsername());
// Problematic line:
AuthenticationProvider authProvider = ((AuthenticationFailureEvent) event).getAuthenticationProvider();
}
}
}
Re: Simple modification to Event Listener example throwing runtime errors
Posted by bu...@icloud.com.INVALID.
I am currently using Guacamole 1.5.4. Here’s the whole pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.guacamole</groupId>
<artifactId>guacamole-notifier</artifactId>
<packaging>jar</packaging>
<version>1.5.4</version>
<name>guacamole-notifier</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<!-- Written for Java 8 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Guacamole Extension API -->
<dependency>
<groupId>org.apache.guacamole</groupId>
<artifactId>guacamole-ext</artifactId>
<version>1.5.4</version>
<scope>provided</scope>
</dependency>
<!-- Slf4j API -->
<!-- This is needed only if your listener wants to
write to the Guacamole web application log -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
-Nathaniel
> On Mar 9, 2024, at 6:55 PM, Nick Couchman <vn...@icloud.com> wrote:
>
> On Sat, Mar 9, 2024 at 6:34 PM Nathaniel Belles <mon99keymon99key@gmail.com <ma...@gmail.com>> wrote:
> Thanks for the quick response!
>
> The only output I get is:
>
> guacamole_guacamole | 22:39:55.184 [http-nio-8080-exec-9] INFO org.apache.guacamole.event.Notifier - failed authentication for user null
> guacamole_guacamole | 22:39:55.186 [http-nio-8080-exec-9] ERROR o.a.g.rest.RESTExceptionMapper - Unexpected internal error: 'org.apache.guacamole.net.auth.AuthenticationProvider org.apache.guacamole.net.event.AuthenticationFailureEvent.getAuthenticationProvider()'
>
> As for the pom.xml, the only thing I changed was the name of the artifactId produced to `guacamole-notifier`.
>
>
> What version of Guacamole are you running, and what version(s) are specified in the pom.xml for pulling in the guacamole-ext dependency?
>
> -Nick
Re: Simple modification to Event Listener example throwing runtime errors
Posted by Nathaniel Belles <mo...@gmail.com>.
Spent a little more time debugging. I decided to use the guacamole-client/Dockerfile to try and build the extension using the builder portion of the docker container in hopes that it would provide a consistent build environment. I was able to build the extension without the problematic line. When I add back the problematic line, it actually threw a compilation error, unlike before. I tried a few other variations of storing different variable types and they all throw similar errors about being unable to find the symbol.
The full error is below:
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /tmp/guacamole-docker-BUILD/extensions/guacamole-notifier/src/main/java/org/apache/guacamole/event/Notifier.java:[32,87] cannot find symbol
symbol: method getAuthenticationProvider()
location: class org.apache.guacamole.net.event.AuthenticationFailureEvent
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for guacamole-client 1.5.4:
[INFO]
[INFO] guacamole-client ................................... SUCCESS [ 22.159 s]
[INFO] guacamole-common ................................... SUCCESS [ 18.192 s]
[INFO] guacamole-ext ...................................... SUCCESS [ 13.470 s]
[INFO] guacamole-common-js ................................ SUCCESS [ 27.115 s]
[INFO] guacamole .......................................... SUCCESS [01:03 min]
[INFO] extensions ......................................... SUCCESS [ 0.218 s]
[INFO] guacamole-auth-duo ................................. SUCCESS [ 4.289 s]
[INFO] guacamole-auth-header .............................. SUCCESS [ 1.649 s]
[INFO] guacamole-auth-jdbc ................................ SUCCESS [ 0.190 s]
[INFO] guacamole-auth-jdbc-base ........................... SUCCESS [ 4.586 s]
[INFO] guacamole-auth-jdbc-mysql .......................... SUCCESS [ 2.951 s]
[INFO] guacamole-auth-jdbc-postgresql ..................... SUCCESS [ 2.054 s]
[INFO] guacamole-auth-jdbc-sqlserver ...................... SUCCESS [ 2.056 s]
[INFO] guacamole-auth-jdbc-dist ........................... SUCCESS [ 1.801 s]
[INFO] guacamole-auth-json ................................ SUCCESS [ 4.449 s]
[INFO] guacamole-auth-ldap ................................ SUCCESS [ 5.090 s]
[INFO] guacamole-auth-quickconnect ........................ SUCCESS [ 3.933 s]
[INFO] guacamole-auth-sso ................................. SUCCESS [ 0.195 s]
[INFO] guacamole-auth-sso-base ............................ SUCCESS [ 1.797 s]
[INFO] guacamole-auth-sso-cas ............................. SUCCESS [ 6.892 s]
[INFO] guacamole-auth-sso-openid .......................... SUCCESS [ 2.625 s]
[INFO] guacamole-auth-sso-saml ............................ SUCCESS [ 2.814 s]
[INFO] guacamole-auth-sso-dist ............................ SUCCESS [ 2.498 s]
[INFO] guacamole-auth-totp ................................ SUCCESS [ 4.915 s]
[INFO] guacamole-notifier ................................. FAILURE [ 2.274 s]
[INFO] guacamole-history-recording-storage ................ SKIPPED
[INFO] guacamole-vault .................................... SKIPPED
[INFO] guacamole-vault-base ............................... SKIPPED
[INFO] guacamole-vault-ksm ................................ SKIPPED
[INFO] guacamole-vault-dist ............................... SKIPPED
[INFO] guacamole-example .................................. SKIPPED
[INFO] guacamole-playback-example ......................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:22 min
[INFO] Finished at: 2024-03-10T03:52:47Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project guacamole-notifier: Compilation failure
[ERROR] /tmp/guacamole-docker-BUILD/extensions/guacamole-notifier/src/main/java/org/apache/guacamole/event/Notifier.java:[32,87] cannot find symbol
[ERROR] symbol: method getAuthenticationProvider()
[ERROR] location: class org.apache.guacamole.net.event.AuthenticationFailureEvent
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :guacamole-notifier
> On Mar 9, 2024, at 7:06 PM, Nathaniel Belles <mo...@gmail.com> wrote:
>
> Somehow managed to reply with the wrong email… Sorry. Here’s the message I sent:
>
> I am currently using Guacamole 1.5.4. Here’s the whole pom.xml
>
> <project xmlns="http://maven.apache.org/POM/4.0.0 <http://maven.apache.org/POM/4.0.0>"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance <http://www.w3.org/2001/XMLSchema-instance>"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 <http://maven.apache.org/POM/4.0.0> http://maven.apache.org/maven-v4_0_0.xsd <http://maven.apache.org/maven-v4_0_0.xsd>">
>
> <modelVersion>4.0.0</modelVersion>
> <groupId>org.apache.guacamole</groupId>
> <artifactId>guacamole-notifier</artifactId>
> <packaging>jar</packaging>
> <version>1.5.4</version>
> <name>guacamole-notifier</name>
>
> <properties>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> </properties>
>
> <build>
> <plugins>
>
> <!-- Written for Java 8 -->
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <version>3.3</version>
> <configuration>
> <source>1.8</source>
> <target>1.8</target>
> </configuration>
> </plugin>
>
> </plugins>
> </build>
>
> <dependencies>
>
> <!-- Guacamole Extension API -->
> <dependency>
> <groupId>org.apache.guacamole</groupId>
> <artifactId>guacamole-ext</artifactId>
> <version>1.5.4</version>
> <scope>provided</scope>
> </dependency>
>
> <!-- Slf4j API -->
> <!-- This is needed only if your listener wants to
> write to the Guacamole web application log -->
> <dependency>
> <groupId>org.slf4j</groupId>
> <artifactId>slf4j-api</artifactId>
> <version>1.7.7</version>
> <scope>provided</scope>
> </dependency>
>
> </dependencies>
>
> </project>
>
> -Nathaniel
>
>> On Mar 9, 2024, at 6:55 PM, Nick Couchman <vnick@apache.org <ma...@apache.org>> wrote:
>>
>> On Sat, Mar 9, 2024 at 6:34 PM Nathaniel Belles <mon99keymon99key@gmail.com <ma...@gmail.com>> wrote:
>> Thanks for the quick response!
>>
>> The only output I get is:
>>
>> guacamole_guacamole | 22:39:55.184 [http-nio-8080-exec-9] INFO org.apache.guacamole.event.Notifier - failed authentication for user null
>> guacamole_guacamole | 22:39:55.186 [http-nio-8080-exec-9] ERROR o.a.g.rest.RESTExceptionMapper - Unexpected internal error: 'org.apache.guacamole.net.auth.AuthenticationProvider org.apache.guacamole.net.event.AuthenticationFailureEvent.getAuthenticationProvider()'
>>
>> As for the pom.xml, the only thing I changed was the name of the artifactId produced to `guacamole-notifier`.
>>
>>
>> What version of Guacamole are you running, and what version(s) are specified in the pom.xml for pulling in the guacamole-ext dependency?
>>
>> -Nick
>
Re: Simple modification to Event Listener example throwing runtime errors
Posted by Nathaniel Belles <mo...@gmail.com>.
Somehow managed to reply with the wrong email… Sorry. Here’s the message I sent:
I am currently using Guacamole 1.5.4. Here’s the whole pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0 <http://maven.apache.org/POM/4.0.0>"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance <http://www.w3.org/2001/XMLSchema-instance>"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 <http://maven.apache.org/POM/4.0.0> http://maven.apache.org/maven-v4_0_0.xsd <http://maven.apache.org/maven-v4_0_0.xsd>">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.guacamole</groupId>
<artifactId>guacamole-notifier</artifactId>
<packaging>jar</packaging>
<version>1.5.4</version>
<name>guacamole-notifier</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<!-- Written for Java 8 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Guacamole Extension API -->
<dependency>
<groupId>org.apache.guacamole</groupId>
<artifactId>guacamole-ext</artifactId>
<version>1.5.4</version>
<scope>provided</scope>
</dependency>
<!-- Slf4j API -->
<!-- This is needed only if your listener wants to
write to the Guacamole web application log -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
-Nathaniel
> On Mar 9, 2024, at 6:55 PM, Nick Couchman <vn...@apache.org> wrote:
>
> On Sat, Mar 9, 2024 at 6:34 PM Nathaniel Belles <mon99keymon99key@gmail.com <ma...@gmail.com>> wrote:
> Thanks for the quick response!
>
> The only output I get is:
>
> guacamole_guacamole | 22:39:55.184 [http-nio-8080-exec-9] INFO org.apache.guacamole.event.Notifier - failed authentication for user null
> guacamole_guacamole | 22:39:55.186 [http-nio-8080-exec-9] ERROR o.a.g.rest.RESTExceptionMapper - Unexpected internal error: 'org.apache.guacamole.net.auth.AuthenticationProvider org.apache.guacamole.net.event.AuthenticationFailureEvent.getAuthenticationProvider()'
>
> As for the pom.xml, the only thing I changed was the name of the artifactId produced to `guacamole-notifier`.
>
>
> What version of Guacamole are you running, and what version(s) are specified in the pom.xml for pulling in the guacamole-ext dependency?
>
> -Nick
Re: Simple modification to Event Listener example throwing runtime errors
Posted by Nick Couchman <vn...@apache.org>.
On Sat, Mar 9, 2024 at 6:34 PM Nathaniel Belles <mo...@gmail.com>
wrote:
> Thanks for the quick response!
>
> The only output I get is:
>
> guacamole_guacamole | 22:39:55.184 [http-nio-8080-exec-9] INFO
> org.apache.guacamole.event.Notifier - failed authentication for user null
> guacamole_guacamole | 22:39:55.186 [http-nio-8080-exec-9] ERROR
> o.a.g.rest.RESTExceptionMapper - Unexpected internal error:
> 'org.apache.guacamole.net.auth.AuthenticationProvider
> org.apache.guacamole.net.event.AuthenticationFailureEvent.getAuthenticationProvider()'
>
> As for the pom.xml, the only thing I changed was the name of the
> artifactId produced to `guacamole-notifier`.
>
>
What version of Guacamole are you running, and what version(s) are
specified in the pom.xml for pulling in the guacamole-ext dependency?
-Nick
Re: Simple modification to Event Listener example throwing runtime errors
Posted by Nathaniel Belles <mo...@gmail.com>.
Thanks for the quick response!
The only output I get is:
guacamole_guacamole | 22:39:55.184 [http-nio-8080-exec-9] INFO org.apache.guacamole.event.Notifier - failed authentication for user null
guacamole_guacamole | 22:39:55.186 [http-nio-8080-exec-9] ERROR o.a.g.rest.RESTExceptionMapper - Unexpected internal error: 'org.apache.guacamole.net.auth.AuthenticationProvider org.apache.guacamole.net.event.AuthenticationFailureEvent.getAuthenticationProvider()'
As for the pom.xml, the only thing I changed was the name of the artifactId produced to `guacamole-notifier`.
-Nathaniel
> On Mar 9, 2024, at 6:27 PM, Nick Couchman <vn...@apache.org> wrote:
>
> On Sat, Mar 9, 2024 at 6:08 PM Nathaniel Belles <mon99keymon99key@gmail.com <ma...@gmail.com>> wrote:
> Hello,
>
> I’m currently trying to write a simple extension for guacamole that allows for push notifications through web hooks. The extension of course relies a lot on guacamole's event listeners. The documentation shows a very simple example (TutorialListener.java) of these event listeners which I have added to the `guacamole-client/extensions/` folder, compiled and then added the extension jar to the extensions folder of my guacamole instance. This example runs just fine and produces debugging output as expected. But when I try to extend the functionality, even just to store a copy of the `AuthenticationProvider` object from the event after including the `import org.apache.guacamole.net.auth.AuthenticationProvider;` line at the top of the file, I am able to compile the extension but then at runtime I get the following: `Unexpected internal error: 'org.apache.guacamole.net.auth.AuthenticationProvider org.apache.guacamole.net.event.AuthenticationFailureEvent.getAuthenticationProvider()'`.
>
>
> Could you share the full output of the runtime error or Java stack trace?
>
> I started looking through the code and I have found that there is a `.getAuthenticationProvider()` function in the `AuthenticationFailureEvent.java` file so I know that I’m using the write function. I also found similar instances of the `AuthenticationFailureEvent` being used in the `EventLoggingListener.java` file and tried to replicate the imports and logic used for the guacamole-client. Do I need to do something special to get proper access to the object types?
>
>
> Aside from the import, are you including the required dependencies, and the correct version(s) of them, in your pom.xml file?
>
> -Nick
Re: Simple modification to Event Listener example throwing runtime errors
Posted by Nick Couchman <vn...@apache.org>.
On Sat, Mar 9, 2024 at 6:08 PM Nathaniel Belles <mo...@gmail.com>
wrote:
> Hello,
>
> I’m currently trying to write a simple extension for guacamole that allows
> for push notifications through web hooks. The extension of course relies a
> lot on guacamole's event listeners. The documentation shows a very simple
> example (TutorialListener.java) of these event listeners which I have added
> to the `guacamole-client/extensions/` folder, compiled and then added the
> extension jar to the extensions folder of my guacamole instance. This
> example runs just fine and produces debugging output as expected. But when
> I try to extend the functionality, even just to store a copy of the
> `AuthenticationProvider` object from the event after including the
> `import org.apache.guacamole.net.auth.AuthenticationProvider;` line at the
> top of the file, I am able to compile the extension but then at runtime I
> get the following: `Unexpected internal error:
> 'org.apache.guacamole.net.auth.AuthenticationProvider org.apache.guacamole.net.event.AuthenticationFailureEvent.getAuthenticationProvider()'`.
>
>
Could you share the full output of the runtime error or Java stack trace?
> I started looking through the code and I have found that there is a
> `.getAuthenticationProvider()` function in the
> `AuthenticationFailureEvent.java` file so I know that I’m using the write
> function. I also found similar instances of the
> `AuthenticationFailureEvent` being used in the `EventLoggingListener.java`
> file and tried to replicate the imports and logic used for the
> guacamole-client. Do I need to do something special to get proper access to
> the object types?
>
>
Aside from the import, are you including the required dependencies, and the
correct version(s) of them, in your pom.xml file?
-Nick