Running vert.x cluster backed by hazelcast cache in distributed mode - java

We are using Vert.X library to develop REST service layer to receive messages from many sources. Part of the requirements is to run REST verticle(s) in High availability (HA) mode. We are following vert.x core manual for implementation of VertX cluster to run in distributed cluster (3 nodes to start with).
Based on the documentation we did the following
Included hazelcast library in dependencies
io.vertx
vertx-hazelcast
3.3.0
Created a fat jar with the following manifest entries and added resources folder in classpath which has required configurations to load. We took hazelcast-default.xml from vertx-examples from github
log4j.properties
config.json
hazelcast-default.xml
io.vertx.core.Launcher
com.msg.verticles.RootVerticle
resources/
Created a script file to trigger the launcher
java -jar -Xmx2048m -Xms512m message-1.0-SNAPSHOT.jar -ha -D config=resources/config.json
Launcher fails to to pickup hazelcast-default.xml from resurce folder and stops with the following exception. Not sure what I am missing here.
$>java -jar -Xmx2048m -Xms512m message-1.0-SNAPSHOT.jar -ha -D config=resources/config.json
Jul 16, 2017 7:20:26 PM io.vertx.core.impl.launcher.commands.RunCommand
INFO: Starting clustering...
Jul 16, 2017 7:20:27 PM io.vertx.core.impl.launcher.commands.RunCommand
INFO: No cluster-host specified so using address 127.0.0.1
Jul 16, 2017 7:20:28 PM io.vertx.spi.cluster.hazelcast.HazelcastClusterManager
WARNING: Cannot find cluster configuration on 'vertx.hazelcast.config' system property, on the classpath, or specified programmatically. Using default hazelcast configuration
Jul 16, 2017 7:20:28 PM com.hazelcast.config.XmlConfigLocator
INFO: Loading 'hazelcast-default.xml' from classpath.
Jul 16, 2017 7:20:28 PM com.hazelcast.config.AbstractXmlConfigHelper
WARNING: Name of the hazelcast schema location incorrect using default
Jul 16, 2017 7:20:28 PM io.vertx.core.impl.VertxImpl
SEVERE: Failed to join cluster
com.hazelcast.core.HazelcastException: org.xml.sax.SAXParseException; schema_reference.4: Failed to read schema document 'null', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
at com.hazelcast.util.ExceptionUtil.peel(ExceptionUtil.java:73)

According to the documentation of Hazelcast cluster manager you need to specify your Hazelcast configuration in a file named cluster.xml in your classpath (either embedded in the root of your fatjar or in a directory that is in your classpath).

Solved the issue by configuring zookeeper as co-ordination service. Which worked like a champ!!
https://github.com/vert-x3/vertx-zookeeper

Related

Maven "Thin Jar" won't pull library from private gitlab repository

I have a java Spring Boot app which is being packaged into a "thin jar" using the spring boot maven thin jar plugin. I followed instructions from here https://www.baeldung.com/spring-boot-thin-jar and it's all working great. I can deploy new versions of my app in lightweight jars while the production server running the app maintains its own .m2 repository, updating if the new thin jar lists any new dependencies.
Recently I wanted to include my own external library. This is hosted in a gitlab-maven package repository and accessed via an access token. I set this up following instructions here: https://docs.gitlab.com/ee/user/packages/maven_repository/
I've written a settings.xml and saved to home/user/.m2/settings.xml which includes the access token.
After that any mvn ... command is pulling the library into the repository as expected. So far so good.
However when I create my thin jar and try to run with java -jar thin-jar.jar it fails to get the library. The error is as follows:
$ java -Dthin.trace=true -jar thin-jar.jar
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.ThinJarLauncher launch
INFO: Version: 1.0.28.RELEASE
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.PathResolver resolve
INFO: Extracting dependencies from: jar:file:/home/user/thin-jar.jar!/, with profiles []
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.PathResolver loadProperties
INFO: Searching for properties in: jar:file:/home/user/thin-jar.jar!/
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.PathResolver loadProperties
INFO: Searching for properties in: classpath:/
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.PathResolver loadProperties
INFO: Searching for properties in: file:./
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.PathResolver extract
INFO: Extracting dependencies from: URL [jar:file:/home/user/thin-jar.jar!/META-INF/maven/my.group/thin-jar/pom.xml], with profiles []
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.MavenSettingsReader loadSettings
INFO: Reading settings from: /home/user/.m2/settings.xml
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.DependencyResolver dependencies
INFO: Computing dependencies from pom and properties
Exception in thread "main" java.lang.reflect.InvocationTargetException
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:566)
at org.springframework.boot.loader.wrapper.ThinJarWrapper.launch(ThinJarWrapper.java:139)
at org.springframework.boot.loader.wrapper.ThinJarWrapper.main(ThinJarWrapper.java:107)
Caused by: java.lang.RuntimeException: Failed to read artifact descriptor for my.group:external-library:jar:0.0.1-dev
at org.springframework.boot.loader.thin.DependencyResolver.dependencies(DependencyResolver.java:239)
at org.springframework.boot.loader.thin.PathResolver.extract(PathResolver.java:259)
at org.springframework.boot.loader.thin.PathResolver.resolve(PathResolver.java:105)
at org.springframework.boot.loader.thin.ThinJarLauncher.getClassPathArchives(ThinJarLauncher.java:369)
at org.springframework.boot.loader.thin.ThinJarLauncher.getClassPathArchives(ThinJarLauncher.java:352)
at org.springframework.boot.loader.thin.ThinJarLauncher.getClassPathArchivesIterator(ThinJarLauncher.java:200)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:55)
at org.springframework.boot.loader.thin.ThinJarLauncher.launch(ThinJarLauncher.java:195)
at org.springframework.boot.loader.thin.ThinJarLauncher.main(ThinJarLauncher.java:141)
... 6 more
I'm assuming this is because the repository is private and somewhere along the way the authentication is failing while trying to pull that library? Looking at the trace it appears to load the settings file properly, so where is it going wrong?

GlassFish server core.jar is not contained in the list of the installed bundles

Launching GlassFish on Felix platform
gru 05, 2016 2:02:02 PM
com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner createBundleProvisioner
INFO: Create bundle provisioner class = class com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner.
gru 05, 2016 2:02:02 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner$DefaultCustomizer getLocations
**WARNING: Skipping entry because it is not an absolute URI.**
gru 05, 2016 2:02:02 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner$DefaultCustomizer getLocations
**WARNING: Skipping entry because it is not an absolute URI.**
gru 05, 2016 2:02:11 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner startBundles
**WARNING: Can not start bundle file:/C:/Users/MyName/Desktop/Servers/glassfish4/glassfish/modules/core.jar because it is not contained in the list of installed bundles.**
Registered com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishRuntime#294d3883 in service registry.
I can't run my project.
What already I did:
- clear&build
- tryed to change ports from 8080 to 9090
- closed connections in TCPView on localports
- closed Java Binary process in task menager and still not working.
When i running project i got this:
C:\Users\MyName\Desktop\Java Web Profile\MyProject\nbproject\build-impl.xml:1048: The module has not been deployed.
See the server log for details.
1047-1049 lines from build-impl.xml:
<target if="netbeans.home" name="-run-deploy-nb">
<nbdeploy clientUrlPart="${client.urlPart}" debugmode="false" forceRedeploy="${forceRedeploy}"/>
</target>
Any ideas? :)
I found this solution/cause on another site, didn't resolve the issue for me but hopefully it can help you:
Reasons: In mac OS Sierra ,the new update blocks the sites which uses system proxy settings, where localhost,127.0.0.1 all connections are blocked.
Solution:
Step 1: Go to system preference >Network>Select your wifi connection>Advanced>select proxies tab.
There check 3 options 1) Auto proxy Discovery 2)Automatic Proxy configuration 3) web proxy(http)
Step 2: Go to Netbeans>preferences>General> select use system proxy> reload> test connection
You may get connection successful.
If connection gets successful, Now Clean & build your Applications in netbeans and press run .
Hope it will work . In my case it works.
https://discussions.apple.com/message/30715103#message30715103
https://netbeans.org/bugzilla/show_bug.cgi?id=268076

RuntimeEnvironmentPropertiesConfigurer issue - when running broadleaf admin on tomcat

I have build the whole app using maven and tried to deploy admin.war it on a standalone tomcat7, during the server start-up, it is showing some error : but still the server starts up,
due to this , when i go to products->Inventory -> the Available Quantity field is missing. But the same field is available, when i am running through eclipse.
Dec 15, 2014 5:45:09 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive D:\apache-tomcat-7.0.42\webapps\admin.war
[ WARN] 17:46:12 RuntimeEnvironmentPropertiesConfigurer - Unable to determine runtime environment, using default environment 'development'
[ WARN] 17:46:20 MergePersistenceUnitManager - A BroadleafClassTransformer is configured for this persistence unit, but Spring reported a problem (likely that a LoadTimeWeaver is not registered). As a result, the Broadleaf Commerce ClassTransformer (org.broadleafcommerce.common.extensibility.jpa.cop
y.DirectCopyClassTransformer) is not being registered with the persistence unit.
[ WARN] 17:46:20 MergePersistenceUnitManager - A BroadleafClassTransformer is configured for this persistence unit, but Spring reported a problem (likely that a LoadTimeWeaver is not registered). As a result, the Broadleaf Commerce ClassTransformer (org.broadleafcommerce.common.extensibility.jpa.con
vert.EntityMarkerClassTransformer) is not being registered with the persistence unit.
[ WARN] 17:46:20 MergePersistenceUnitManager - A BroadleafClassTransformer is configured for this persistence unit, but Spring reported a problem (likely that a LoadTimeWeaver is not registered). As a result, the Broadleaf Commerce ClassTransformer (org.broadleafcommerce.common.extensibility.jpa.cop
y.DirectCopyClassTransformer) is not being registered with the persistence unit.
[ WARN] 17:46:31 AbstractEhcacheRegionFactory - HHH020003: Could not find a specific ehcache configuration for cache named [blSandBoxElements]; using defaults.
[ WARN] 17:47:14 DefaultFilterChainValidator - Possible error: Filters at position 12 and 13 are both instances of org.springframework.security.web.access.intercept.FilterSecurityInterceptor
[ WARN] 17:47:15 RuntimeEnvironmentPropertiesConfigurer - Unable to determine runtime environment, using default environment 'development'
Hibernate: select systemprop0_.BLC_SYSTEM_PROPERTY_ID as BLC1_167_, systemprop0_.FRIENDLY_GROUP as FRIENDLY2_167_, systemprop0_.FRIENDLY_NAME as FRIENDLY3_167_, systemprop0_.FRIENDLY_TAB as FRIENDLY4_167_, systemprop0_.PROPERTY_NAME as PROPERTY5_167_, systemprop0_.PROPERTY_TYPE as PROPERTY6_167_, sy
stemprop0_.PROPERTY_VALUE as PROPERTY7_167_ from BLC_SYSTEM_PROPERTY systemprop0_ where systemprop0_.PROPERTY_NAME=?
Dec 15, 2014 5:47:20 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Dec 15, 2014 5:47:20 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Dec 15, 2014 5:47:20 PM org.apache.catalina.startup.Catalina start
The inventory was added in version 3.1.3 make sure you are using this version or newer version.
It was added using
org.broadleafcommerce.common.extensibility.jpa.copy.DirectCopyClassTransformer
Which adds the field at run time, but this creates the dependency on "Spring Instruments", which needs to be added as javaagent
So you can edit your /path/to/tomcat/bin/setenv.sh and add following
JAVA_OPTS="-Djava.awt.headless=true -Xmx1024M -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n -javaagent:/path/to/spring-jar/spring-instrument-3.2.2.RELEASE.jar"
Adjust Xmx and other tomcat setting and replace /path/to/spring-jar/ with actual path.

Accessing newrelic API through my application

.I'm using Newrelic for java agent.I install the newrelic.yml file using the command "java -jar newrelic.jar install" in my prompt. When running, it shows the message as INSTALL SUCCESSFUL and some other information. I also find the newrelic.yml setup in running the run.bat file.But i'm not able to see the newrelic API in my browser when running the port as "localhost:8080/newrelic" . I'm started my server in the port 8080.
The log folder in newrelic diectory.My newrelic_agent.log containing the following lines...,
Feb 8, 2012 05:49:07 PM NewRelic INFO: Writing to New Relic log file: D:\work\software\jboss-6.0.0.Final\newrelic\logs\newrelic_agent.log
Feb 8, 2012 05:49:09 PM NewRelic INFO: Configured to connect to New Relic at collector.newrelic.com:80
Feb 8, 2012 05:49:09 PM NewRelic INFO: Setting protocol to "http"
Feb 8, 2012 05:49:09 PM NewRelic INFO: Configuration file is D:\work\software\jboss-6.0.0.Final\newrelic\.\newrelic.yml
Feb 8, 2012 05:49:09 PM NewRelic WARN: The apdex_t setting is obsolete and is ignored! Set the apdex_t value for an application in New Relic UI
Feb 8, 2012 05:49:09 PM NewRelic INFO: New Relic Agent v2.3.0 has started
Feb 8, 2012 05:49:09 PM NewRelic INFO: Java version: 1.6.0_12
Feb 8, 2012 05:49:30 PM NewRelic INFO: JVM is shutting down
Feb 8, 2012 05:49:30 PM NewRelic INFO: New Relic Agent has shutdown
I'm sure not yet started the newrelic API in my browser.It shows an error as "HTTP 404 the request resource /k12/newrelic is not available.I'm using j.d.k 1.6
Help me please..?
The New Relic Ruby agent has a Developer Mode that lives at the /newrelic path you're trying to reach, but the Java agent does not. Developer Mode would give you a detailed trace of each individual web request your app makes that's similar to what the normal New Relic product does with Transaction Traces.
To use New Relic and report performance data, it looks like you've got everything configured correctly. You should be able to log in to https://rpm.newrelic.com and see what your app is doing.
You mentioned "the newrelic API", but I'm not sure what you are looking for exactly. There is an API for the Java agent that lets you configure the agent. There's also a New Relic HTTP REST API that will let you retrieve data reported by your applications.

Google App Engine - How to get demos to work?

I'm embarrassed to have to ask this, but I can't for the life of me figure out what I'm doing wrong.
I've downloaded the appengine-java-sdk-1.4.2 via the eclipse 3.6 plugin as per the instructions on Installing the Java SDK page. I am running Mac OSX 10.5.8 with JRE version 1.5.0_26. I have made the dev_appserver.sh file executable (chmod u+x dev_appserver.sh) and when I attempt to start the app server with one of the demos via the command
bin/dev_appserver.sh demos/guestbook/war/
I get the following output, but the server does not start up:
2011-03-13 17:52:43.404 java[839:80f] [Java CocoaComponent compatibility mode]: Enabled
2011-03-13 17:52:43.405 java[839:80f] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000
********************************************************
Warning: Future versions of the Dev App Server will require Java 1.6 or later. Please upgrade your JRE.
********************************************************
Mar 13, 2011 9:52:44 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
Mar 13, 2011 9:52:44 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed /Applications/eclipse_3.6/plugins/com.google.appengine.eclipse.sdkbundle.1.4.2_1.4.2.v201102111811/appengine-java-sdk-1.4.2/demos/guestbook/war/WEB-INF/appengine-web.xml
Mar 13, 2011 9:52:44 PM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
INFO: Successfully processed /Applications/eclipse_3.6/plugins/com.google.appengine.eclipse.sdkbundle.1.4.2_1.4.2.v201102111811/appengine-java-sdk-1.4.2/demos/guestbook/war/WEB-INF/web.xml
I see the warning about upgrading the JRE, but I don't think this is the problem, as there are no exceptions reported. It just won't start up. I've tried creating a hello world app from within Eclipse using the plugin and running as Web server, but that also spits out the same text but does not start up the web server.
Any idea what I'm doing wrong and how to remedy the problem?
By changing the line in dev_appserver.sh to
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/java -ea -cp "$JAR_FILE" \
com.google.appengine.tools.KickStart \
com.google.appengine.tools.development.DevAppServerMain $*
instead of using the default java (which is set to 1.5.0_26 as I mentioned earlier) the web server starts up.
I had the same problem and simply tried running Eclipse as Administrator and then debugging worked fine.

Categories

Resources