GlassFish 4, Grizzly Framework 2.3.23: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn - spring-mvc

While starting GlassFish 4.1.1 server (Grizzly Framework 2.3.23), below warning message is displayed: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn
Do Grizzly Framework 2.3.23 to be separately installed on the computer? (As per details: "Class=interface org.glassfish.grizzly.http.server.AddOn" it seems like grizzly http server is part of glassfish) If grizzly http server seperately not needed to be installed, then which instance it is trying to be initialized and failing.
Do GlassFish Plugin for Eclipse is to be added in Spring Tool Suite IDE?
GlassFish 4 server stop and start using command prompt tested:
glassfish4\bin>asadmin stop-domain
Command stop-domain executed successfully.
glassfish4\bin>asadmin start-domain
Waiting for domain1 to start ;
Successfully started the domain : domain1;
domain Location: glassfish4\glassfish\domains\domain1;
Log File: glassfish4\glassfish\domains\domain1\logs\server.log;
Admin Port: 4848;
Command start-domain executed successfully.
Still the warning exist as given above.
If Grizzly Framework is inbuilt in GlassFish 4 then, does Grizzly dependency inclusion in the project pom.xml needed explicitly as given below? (code is from: Grizzly)
<dependencies>
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-http-server</artifactId>
<version>2.3.22</version>
</dependency>
</dependencies>

I had the same problem, with Glassfish embedded 4.1.2. Please notice that you wrote only a part of the errore message, full error message is:
Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=http-listener-1, realClassName=org.glassfish.grizzly.http2.Http2AddOn
So, Glassfish is trying to instantiate a class in package http2, however this package is not included in embedded Glassfish! There is no such folder in glassfish-embedded-all-4.1.2.jar.
I don't know if this was fixed in 5.0.
My solution for 4.1.2 is to add dependencies that include this package (well, this is exactly the solution you propose):
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-http2</artifactId>
<version>2.3.28</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-npn-bootstrap</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>

Related

Problem using WebView and GluonFx / Gluion Mobile native build on Windows

I am trying to use a WebView within my JavaFX application built using Gluon Mobile. It works fine when running in IntelliJ using the gluonfx:runagent, and javafx:run targets. However, when I try to run the native application then I get the following runtime error:
Caused by: java.lang.UnsatisfiedLinkError: no jfxwebkit in java.library.path
at com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:132)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:47)
at java.lang.Runtime.loadLibrary0(Runtime.java:818)
at java.lang.System.loadLibrary(System.java:1989)
at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:166)
at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:54)
at com.sun.webkit.WebPage.lambda$static$0(WebPage.java:138)
at java.security.AccessController.doPrivileged(AccessController.java:89)
at com.sun.webkit.WebPage.<clinit>(WebPage.java:137)
at javafx.scene.web.WebEngine.<init>(WebEngine.java:854)
at javafx.scene.web.WebEngine.<init>(WebEngine.java:839)
at javafx.scene.web.WebView.<init>(WebView.java:275)
at com.jdf.views.BullpenPresenter.onActionVideoPopout(BullpenPresenter.java:713)
I've added the javafx-web module to my POM file.
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>${javafx.version}</version>
</dependency>
Other Settings:
Java Version: 17
<javafx.version>17.0.2</javafx.version>
<attach.version>4.0.13</attach.version>
<gluonfx.plugin.version>1.0.12</gluonfx.plugin.version
<javafx.plugin.version>0.0.8</javafx.plugin.version>
Graalvm Version: graalvm-svm-java17-windows-gluon-22.0.0.3-Final
Any and all help appreciated.
Thanks,
Joshua

NoClassDefFoundError for a class due to the interrelative dependencies in karaf

Consider the below scenario where i am getting an unexpected error and unable to fix it.
In Opendaylight architype project, I just used a class(Say test.class from io-example dependency) when I just declared only one dependency (i.e io-example) in the pom.xml, there is no error.
But if i add one more dependency (io-example-api) in the pom.xml, I am getting java.lang.NoClassDefFoundError: io/example/test.class
at org.opendaylight.gnmi.impl.base.OpenconfigInter
..................................................
..................................................
Caused by: java.lang.ClassNotFoundException: io.example.Test cannot be found by org.opendaylight
I found that io.example-api has the io-example as the dependency.. Summarize the issue, If i have the io-example alone in the pom.xml, there is no issue. If I have both io-example and io-example-api in the pom.xml, I am getting the NoclassDef error.
Even I have tried the exclusion option in the dependency section, Nothing works.
Thanks in advance...
Edited:
classname : io.grpc.Context
Dependencies :
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-context</artifactId>
<version>1.38.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
<version>1.38.0</version>
</dependency>
In karaf container, I ran the "package:exports" commands and the results are,
opendaylight-user#root>package:exports -p io.grpc
io.grpc 0.0.0 354 wrap_file__home_verizon_gnmi_gnmi_karaf_target_assembly_system_io_grpc_grpc-api_1.38.0_grpc-api-1.38.0.jar
io.grpc 0.0.0 355 wrap_file__home_verizon_gnmi_gnmi_karaf_target_assembly_system_io_grpc_grpc-context_1.38.0_grpc-context-1.38.0.ja
opendaylight-user#root>package:exports -d
io.grpc 0.0.0 354 355
You can see that, io.grpc package exported by two bundles (354 and
355)..
A common cause for ClassNotFoundException in OSGi and Karaf is that multiple bundles export the same package with the same version. This causes only one of them be imported which may or may not contain your Test class.
Check which packages export io.example with package:exports command:
packages:exports -p io.example
I am guessing that adding the dependency causes your bundle to import the package io.example from io-example-api instead of io-example.
Solution for this would be to make sure only one bundle exports io.example package.
[Edit] I am unfamiliar with grpc but there seems to be issue on github about this and some workarounds that you could look in to.
You could also try creating a bundle that embeds these problematic dependencies and exports the packages for other bundles to use.
Create a new bundle project using archetype karaf-bundle-archetype
Add grpc-context and grpc-api dependencies
Configure maven-bundle-plugin to emped the grpc dependencies and export io.grpc package along with its sub packages.
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven-bundle-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>
${project.groupId}.${project.artifactId}
</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-Activator>com.example.Activator</Bundle-Activator>
<Import-Package>
*;resolution:=optional
</Import-Package>
<Export-Package>
io.grpc*;-split-package:=merge-first
</Export-Package>
<Emped-Dependency>
grpc-context;scope=compile|runtime;inline=true,
grpc-api;scope=compile|runtime;inline=true
</Emped-Dependency>
</instructions>
</configuration>
</plugin>
Managed to install the bundle successfully to Karaf 4.2.11 and "use" the exported io.grpc.Context class in the bundle and in another bundle.
Simply called this from the Activator of two bundles
Context grpcContext = Context.current();
System.out.println(grpcContext.getClass().getName());

Issue when flink upload a job with stream sql query

I used the latest flink version(1.10.0) and sbt(1.3.7). I have this exception when upload a job with streaming sql query:
Caused by: java.lang.ClassCastException:
org.codehaus.janino.CompilerFactory cannot be cast to
org.codehaus.commons.compiler.ICompilerFactory
at org.codehaus.commons.compiler.CompilerFactoryFactory.getCompilerFactory(CompilerFactoryFactory.java:129)
at org.codehaus.commons.compiler.CompilerFactoryFactory.getDefaultCompilerFactory(CompilerFactoryFactory.java:79)
at org.apache.calcite.rel.metadata.JaninoRelMetadataProvider.compile(JaninoRelMetadataProvider.java:432)
When I running main class with sbt run it works perfectly. I made jar with the sbt assembly command and I have conflicts between libraries. For this reason add this in the build.sbt:
assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs # _*) => MergeStrategy.discard
case x => MergeStrategy.first
}
I read a similar case with hive connector https://issues.apache.org/jira/browse/FLINK-14849 and this is the answer:
After https://issues.apache.org/jira/browse/FLINK-13749 , flink-client will use default child-first resolve-order.
If user jar has some conflict dependents, there will be some problem.
My question is: How to resolve these conflicts? Any assembly merge strategy suggest for this case?
Help would be appreciated.
I faced the same issue and the following solution helped me get through :
assembly / assemblyMergeStrategy := {
case PathList("org", "codehaus", "janino", "CompilerFactory.class") => MergeStrategy.discard // discard
case x => MergeStrategy.first // first
}
Also, took help from the this link.
The above addition needs to be done in sbt.build file and make sure you're building using assembly command.
In case one is building using package-bin in case of legacy applications, follow this link.
Another solution includes checking the scope of the flink libraries. If by any chance you have accidentally pushed libraries that were earlier set to 'provided' with something like 'compile', do revert the changes and test.
Hope this helps.
I have same problem.
Maybe you have package your code with flink-table-planner_${scala.binary.version}, so you need to change your maven config with those settings:
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner-blink_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
I had the same issue. My problem was, that I added the dependency
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
without the provided scope. Therefore, maven packaged it in my jar, which lead to the ClassCastException when trying to submit the job to my local flink cluster.

Spring Boot app deployed to Glassfish is giving strange results

As mentioned here, I am having a heck of a time getting my small Spring-Boot project to deploy "correctly" to Glassfish. It runs fine using the embedded Tomcat, but once I try and move it into my organization's environment (Glassfish 3.1.2) I get some strange behavior.
Thinking it was my code, I reverted to the time-tested "Hello World"-approach and built a super-basic app following this tutorial on Spring's blog.
I did make a few very minor deviations as I went along but nothing that should have affected the app like this at all.
The only major deviation I made was that I found I could not exclude "spring-boot-starter-tomcat" from "spring-boot-starter-web" -- when I tried to that, I got 2 errors in the STS "Markers"-tab:
The project was not built since its build path is incomplete. Cannot find the class file for javax.servlet.ServletContext. Fix the build path then try building this project
The type javax.servlet.ServletContext cannot be resolved. It is indirectly referenced from required .class files Application.java
If I cleaned the STS project, then ran Maven Clean, Update, Install the Install goal gave the following error:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project test: Compilation failure [ERROR] /Users/brandon_utah/Utah Development/sts_workspaces/NidTools Rebooted/test/src/main/java/test/Application.java:[13,8] cannot access javax.servlet.ServletException [ERROR] class file for javax.servlet.ServletException not found
So what I did instead was include this dependency (which I found mentioned in several other SpringBoot resources):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
In this deployed fine to the embedded Tomcat and it did deploy to my Glassfish (local install) -- but with a whole bunch (about a half-dozen) errors similar to this one:
2014-04-03T16:23:48.156-0600|SEVERE: Class [ Lorg/springframework/jdbc/datasource/embedded/EmbeddedDatabase; ] not found. Error while loading [ class org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration ]
Most of them are SEVERE, but I am also getting a few with a WARNING:
2014-04-04T06:57:35.921-0600|WARNING: Error in annotation processing: java.lang.NoClassDefFoundError: org/springframework/batch/core/configuration/annotation/BatchConfigurer
Except that I'm not referencing any of these missing classes anywhere in my project (other than what might be referenced by Spring Boot itself).
Also, the app doesn't quite work as expected. If I hit the RestController, I do get my page rendered as I expect -- but if I put any sort of System.out or Logger.log statement in the controller's method, that line of code seemingly never gets executed; by all appearances, it just gets skipped.
To demonstrate this problem, in my sample app's RestController I created a static counter. Then in the GET-/ method I increment that counter and System.out.println it's value. I also return the value as part of the Response.
And again, from a user's perspective, it seems to be working: the screen renders "Hello World" and in parentheses it shows the counter's value. I refresh the window, the counter increments. But nothing in the STS Console. And if I navigate to the Glassfish log for the app, nothing there either. Nothing. Nada. Zip. From what I can tell, something is mysteriously eating any attempt to log anything.
To add to the mystery, if I add a System.out to the SpringBootServletInitializer#configure(), that does make it to the Console. But if I declare a constructor in my RestController and include a System.out there, that one does not make it to the Console. For good measure, I even tried including a System.err in the constructor and a Logger.getAnonymousLogger.severe in the method; neither of those result in anything.
I should note that this also deploys and runs as expected using an external Tomcat.
I would very much appreciate any input, as it's not likely that I can convince my organization to deploy this to Tomcat nor use the embedded-Tomcat approach (due to politics and an overwhelming existing Glassfish environment).
My test project on Github is here.
This has been answered here: https://stackoverflow.com/a/29438821/508247
There is a bug in Glassfish 3.1.X. You need to include metadata-complete="true" in your web.xml root element.
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1"
metadata-complete="true"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
</web-app>
I had this problem with Payara 5, I understand the problem became from Glassfish.
Versions:
Payara 5.192
Spring Boot 2.1.6
The solution worked for me:
I added this dependency in the pom.xml.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
<version>2.1.4.RELEASE</version>
</dependency>
My glassfish-web configuration:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC ...>
<glassfish-web-app error-url="">
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
<!-- set a friendly context root -->
<context-root>/micuenta-api</context-root>
<!-- Change the default character encoding from ISO-8859-1 to UTF-8 -->
<parameter-encoding default-charset="UTF-8"/>
</glassfish-web-app>

How to have access to ServletRequestAware on struts2-core 2.3.16.1?

I changed my struts2 version from 2.3.14 to 2.3.16.1, it seems that newest version does not support ServletRequestAware and ServletResponseAware anymore, what should I do? I could not find anything online.
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.16.1</version>
<type>jar</type>
</dependency>
Code
import org.apache.struts2.interceptor.ServletRequestAware;
public class MyExample implements ServletRequestAware, ServletResponseAware {
Error
package org.apache.struts2.interceptor does not exist.
When I try to find a dependency for it Maven shows the latest version of Struts2 which is supporting it is 2.3.14!
You probably have some problem with the libraries included in your project;
Be sure to erase all the old JARs from the classpath (your WAR / EAR and shared libs on the AS;
run Clean Project in your IDE;
download Struts2.3.16.1 from Maven or manually from here;
check out the ServletRequestAware and ServletResponseAware Interfaces at
/struts-2.3.16.1/src/core/src/main/java/org/apache/struts2/interceptor/
, exactly where they were before ;)
E.g., output from 2.3.16.3 distribution:
$ jar tvf struts2-core-2.3.16.3.jar | grep ServletRequest
223 Fri May 02 17:23:44 EDT 2014 org/apache/struts2/interceptor/ServletRequestAware.class
It's also in the 2.3.16.1 jars.
At the Step 3 of Welcome to Struts2 add the following dependency to your pom.xml
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>X.X.X.X</version>
</dependency>
Check the file version X.X.X.X is available in the repository and downloaded to your hard drive.

Resources