socket io for java maven eclipse is not working because it's not recognizing socket io - sockets

this is my dependency
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>a</groupId>
<artifactId>a</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>io.socket</groupId>
<artifactId>socket.io-client</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
this is my client (main)
import io.socket.client.Socket;
import io.socket.emitter.Emitter;
public class client {
public static void main(String[] args) {
socket = IO.socket("http://145.24.222.151::8085");
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
public void call(Object... args) {
Socket.emit("foo", "hi");
Socket.disconnect();
}
}).on("event", new Emitter.Listener() {
public void call(Object... args) {}
}).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
public void call(Object... args) {}
});
Socket.connect();
}
}
it is not recognzigng any of the socket functions only like 2 i already did maven clean maven install and i tried to shut down and open eclipse again its not doing anything anyone know why?
the errors i get are:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
socket cannot be resolved to a variable
IO cannot be resolved
socket cannot be resolved
Socket cannot be resolved to a variable
Emitter cannot be resolved to a type
socket cannot be resolved
socket cannot be resolved
Emitter cannot be resolved to a type
The method call(Object...) of type new Listener(){} must override a superclass method
Socket cannot be resolved to a variable
Emitter cannot be resolved to a type
The method call(Object...) of type new Listener(){} must override a superclass method
socket cannot be resolved
at client.main(client.java:3)

Related

NoClassDefFoundError: Failed to link conditional authenticator keycloak 11

I'm using keycloak 11.0.3 (jboss distribution) with Docker. I'm also writing my custom conditional authenticator for user attribute condition (actually I copied the one from newer keycloak distribution):
Factory class
package org.example;
import org.keycloak.Config;
import org.keycloak.authentication.authenticators.conditional.ConditionalAuthenticator;
import org.keycloak.authentication.authenticators.conditional.ConditionalAuthenticatorFactory;
import org.keycloak.models.AuthenticationExecutionModel;
import org.keycloak.models.KeycloakSessionFactory;
import org.keycloak.provider.ProviderConfigProperty;
import java.util.Arrays;
import java.util.List;
public class ConditionalUserAttributeValueFactory implements ConditionalAuthenticatorFactory {
public static final String PROVIDER_ID = "conditional-user-attribute";
public static final String CONF_ATTRIBUTE_NAME = "attribute_name";
public static final String CONF_ATTRIBUTE_EXPECTED_VALUE = "attribute_expected_value";
public static final String CONF_NOT = "not";
private static final AuthenticationExecutionModel.Requirement[] REQUIREMENT_CHOICES = {
AuthenticationExecutionModel.Requirement.REQUIRED, AuthenticationExecutionModel.Requirement.DISABLED
};
#Override
public void init(Config.Scope config) {
// no-op
}
#Override
public void postInit(KeycloakSessionFactory factory) {
// no-op
}
#Override
public void close() {
// no-op
}
#Override
public String getId() {
return PROVIDER_ID;
}
#Override
public String getDisplayType() {
return "Condition - user attribute";
}
#Override
public String getReferenceCategory() {
return null;
}
#Override
public boolean isConfigurable() {
return true;
}
#Override
public AuthenticationExecutionModel.Requirement[] getRequirementChoices() {
return REQUIREMENT_CHOICES;
}
#Override
public boolean isUserSetupAllowed() {
return false;
}
#Override
public String getHelpText() {
return "Flow is executed only if the user attribute exists and has the expected value";
}
#Override
public List<ProviderConfigProperty> getConfigProperties() {
ProviderConfigProperty authNoteName = new ProviderConfigProperty();
authNoteName.setType(ProviderConfigProperty.STRING_TYPE);
authNoteName.setName(CONF_ATTRIBUTE_NAME);
authNoteName.setLabel("Attribute name");
authNoteName.setHelpText("Name of the attribute to check");
ProviderConfigProperty authNoteExpectedValue = new ProviderConfigProperty();
authNoteExpectedValue.setType(ProviderConfigProperty.STRING_TYPE);
authNoteExpectedValue.setName(CONF_ATTRIBUTE_EXPECTED_VALUE);
authNoteExpectedValue.setLabel("Expected attribute value");
authNoteExpectedValue.setHelpText("Expected value in the attribute");
ProviderConfigProperty negateOutput = new ProviderConfigProperty();
negateOutput.setType(ProviderConfigProperty.BOOLEAN_TYPE);
negateOutput.setName(CONF_NOT);
negateOutput.setLabel("Negate output");
negateOutput.setHelpText("Apply a not to the check result");
return Arrays.asList(authNoteName, authNoteExpectedValue, negateOutput);
}
#Override
public ConditionalAuthenticator getSingleton() {
return ConditionalUserAttributeValue.SINGLETON;
}
}
Authenticator class:
package org.example;
import org.keycloak.authentication.AuthenticationFlowContext;
import org.keycloak.authentication.AuthenticationFlowError;
import org.keycloak.authentication.AuthenticationFlowException;
import org.keycloak.authentication.authenticators.conditional.ConditionalAuthenticator;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;
import org.keycloak.models.UserModel;
import java.util.Map;
import java.util.Objects;
public class ConditionalUserAttributeValue implements ConditionalAuthenticator {
static final ConditionalUserAttributeValue SINGLETON = new ConditionalUserAttributeValue();
#Override
public boolean matchCondition(AuthenticationFlowContext context) {
System.out.println("START MATCH CONDITION");
Map<String, String> config = context.getAuthenticatorConfig().getConfig();
System.out.println("Map<String, String> config = " + config);
String attributeName = config.get(ConditionalUserAttributeValueFactory.CONF_ATTRIBUTE_NAME);
String attributeValue = config.get(ConditionalUserAttributeValueFactory.CONF_ATTRIBUTE_EXPECTED_VALUE);
System.out.println("attributeName = " + attributeName);
System.out.println("attributeValue = " + attributeName);
UserModel user = context.getUser();
if (user == null) {
throw new AuthenticationFlowException("Cannot find user for obtaining particular user attributes. Authenticator: " +
ConditionalUserAttributeValueFactory.PROVIDER_ID, AuthenticationFlowError.UNKNOWN_USER);
}
System.out.println("USER ATTRIBUTES :" + user.getAttributes());
return user.getAttribute(attributeName).stream()
.anyMatch(attr -> Objects.equals(attr, attributeValue));
}
#Override
public void action(AuthenticationFlowContext context) {
}
#Override
public boolean requiresUser() {
return true;
}
#Override
public void setRequiredActions(KeycloakSession session, RealmModel realm, UserModel user) {
}
#Override
public void close() {
}
}
And I added a file named
org.keycloak.authentication.AuthenticatorFactory
to resources/META-INF/services folder with the following content
org.example.ConditionalUserAttributeValueFactory
pom.xml file:
<?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>org.example</groupId>
<artifactId>conditional-authenticator</artifactId>
<version>1.0-SNAPSHOT</version>
<name>conditional-authenticator</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<keycloak.version>11.0.3</keycloak.version>
</properties>
<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
<version>${keycloak.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-services</artifactId>
<version>${keycloak.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-server-spi</artifactId>
<version>${keycloak.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-server-spi-private</artifactId>
<version>${keycloak.version}</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Dockerfile:
FROM jboss/keycloak:11.0.3
COPY ./deployments /opt/jboss/keycloak/standalone/deployments
ENTRYPOINT [ "/opt/jboss/tools/docker-entrypoint.sh" ]
CMD ["-b", "0.0.0.0"]
But after I run the container I recieve the following error:
16:42:07,288 WARN [org.jboss.modules.define] (ServerService Thread Pool -- 62) Failed to define class org.example.ConditionalUserAttributeValueFactory in Module "deployment.conditional-authenticator-1.0-SNAPSHOT.jar" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link org/example/ConditionalUserAttributeValueFactory (Module "deployment.conditional-authenticator-1.0-SNAPSHOT.jar" from Service Module Loader): org/keycloak/authentication/authenticators/conditional/ConditionalAuthenticatorFactory
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1096)
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:424)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:555)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:339)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:126)
at org.jboss.modules.Module.loadModuleClass(Module.java:731)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:247)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1209)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1220)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1264)
at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1299)
at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1384)
at org.keycloak.keycloak-services#11.0.3//org.keycloak.provider.DefaultProviderLoader.load(DefaultProviderLoader.java:60)
at org.keycloak.keycloak-services#11.0.3//org.keycloak.provider.ProviderManager.load(ProviderManager.java:95)
at org.keycloak.keycloak-services#11.0.3//org.keycloak.services.DefaultKeycloakSessionFactory.loadFactories(DefaultKeycloakSessionFactory.java:248)
at org.keycloak.keycloak-services#11.0.3//org.keycloak.services.DefaultKeycloakSessionFactory.init(DefaultKeycloakSessionFactory.java:88)
at org.keycloak.keycloak-services#11.0.3//org.keycloak.services.resources.KeycloakApplication.createSessionFactory(KeycloakApplication.java:260)
at org.keycloak.keycloak-services#11.0.3//org.keycloak.services.resources.KeycloakApplication.startup(KeycloakApplication.java:124)
at org.keycloak.keycloak-wildfly-extensions#11.0.3//org.keycloak.provider.wildfly.WildflyPlatform.onStartup(WildflyPlatform.java:29)
at org.keycloak.keycloak-services#11.0.3//org.keycloak.services.resources.KeycloakApplication.<init>(KeycloakApplication.java:114)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
It worth noting that preciously I managed to successfully deploy custom SMS Authenticator the same way. But I ran intro such troubles with the conditional one.
Any ideas?

my activemq plugin not work

I write an ActiveMQ plugin, but it does not work.
The code:
package cn.ennwifi.mqttplugin;
import org.apache.activemq.broker.Broker;
import org.apache.activemq.broker.BrokerPlugin;
public class MqttPlugin implements BrokerPlugin {
public Broker installPlugin(Broker broker) throws Exception {
return new MqttFilter(broker);
}
}
package cn.ennwifi.mqttplugin;
import org.apache.activemq.broker.Broker;
import org.apache.activemq.broker.BrokerFilter;
import org.apache.activemq.broker.ConnectionContext;
import org.apache.activemq.command.ConnectionInfo;
public class MqttFilter extends BrokerFilter {
public MqttFilter(Broker broker) {
super(broker);
System.out.println("mqtt插件");
}
#Override
public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception {
System.out.println("mqtt连接信息:" + info.getClientId());
if (info.getUserName() != "123") {
return;
}
super.addConnection(context, info);
}
}
The configure:
<plugins>
<bean xmlns="http://www.springframework.org/schema/beans" id="myplugin" class="cn.ennwifi.mqttplugin.MqttPlugin"/>
</plugins>
I used mvn:clean package pack a jar,put it to activemq/lib
The version is 5.14.1
I change my code
if (info.getUserName() == null) {
throw new Exception("用户名不能为空");
}
I used throw an exception replace return.
Use Log4j to be able to see what's happening.
Do something like below:
private static Logger LOG = LoggerFactory.getLogger(MqttFilter.class);
LOG.info("my message");
Hope this helps.

Portico RTI + Java WEB Application = NoClassDefFoundError

I'm trying to start a Federate (HLA RTI) from a Java Web application, but I'm receiving the error java.lang.NoClassDefFoundError: hla/rti1516/FederateAmbassador.
The same Federate is starting well from an ordinary java application.
My goal is to start the RTI and a Federation by starting a Federate when the web application is started. So I create a WebListener class to start my Federate:
#WebListener
public class Startup implements ServletContextListener {
#Override
public void contextDestroyed(ServletContextEvent arg0) {
//
}
#Override
public void contextInitialized(ServletContextEvent arg0) {
Federate fed = new Federate();
fed.start();
}
}
This is the Federate start() code. I'll not put all code because this is not even reached:
public class Federate {
public void start() {
System.out.println("start");
try {
RTIambassador rtiAmb = RtiFactoryFactory.getRtiFactory().getRtiAmbassador();
MyFederateAmbassador fedAmb = new MyFederateAmbassador();
...
}
When my webserver is starting, I never see the System.out.println("start") output, just only this error :
Grave: Exception sending context initialized event to listener instance of class cmabreu.scorpio.startup.Startup
java.lang.NoClassDefFoundError: hla/rti1516/FederateAmbassador
at cmabreu.scorpio.startup.Startup.contextInitialized(Startup.java:29)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
My portico.jar is configured in Build Path and the Federate imports are pretty fine ( no errors ):
import hla.rti1516.AttributeHandle;
import hla.rti1516.AttributeHandleSet;
import hla.rti1516.AttributeHandleValueMap;
import hla.rti1516.LogicalTime;
import hla.rti1516.ObjectClassHandle;
import hla.rti1516.ObjectInstanceHandle;
import hla.rti1516.RTIambassador;
import hla.rti1516.ResignAction;
import hla.rti1516.jlc.RtiFactoryFactory;
What I'm doing wrong?
After contact Portico creator, Tim Pokorny, I solved the problem changing some code in Portico source. The Portico's Log4j is in conflict with catalina's Log4J and a few other things more.

Spring data gemfire support for subregion cache listener

I am trying to port my existing application code to startup Gemfire using the Spring-data-gemfire. So I am basically moving my region configurations from the cache.xml to spring context.
Versions used:
Gemfire 6.6.3.2
Spring-data-gemfire-1.3.4
Jdk 7
It all works fine upto the point where I need to configure Cache Listeners. A simple Cache listener on a region works but I cant get a cache listener to work on subregions.
As an example I have the below regions. I want the CacheUpdateListener (implements the CacheListener interface) notified when the /User/Details/Address region is updated. I know Gemfire supports it because I already have it working with cache.xml way. But does anyone know if I can get this to work with Spring-data-gemfire. This is what I tried and didnt work.
<gfe:replicated-region id="VCCache" name="User" scope="distributed-no-ack">
<gfe:replicated-region name="Details" scope="distributed-no-ack">
<gfe:replicated-region name="Address" scope="distributed-ack">
<gfe:cache-listener>
<bean class="com.vc.cache.CacheUpdateListener" />
</gfe:cache-listener>
</gfe:replicated-region>
</gfe:replicated-region>
</gfe:replicated-region>
** EDIT: Added the listener code
Here is the listener. I haven't put all the over ridden functions here just to be concise.
public class CacheUpdateListener implements CacheListener<Object, Object>
{
private static final Logger LOGGER = LoggerFactory.getLogger(CacheUpdateListener.class);
private String name = "defaultName";
#Override
public void afterCreate(EntryEvent<Object, Object> event)
{
LOGGER.info("[afterCreate] region [{}] key [{}] created remote [{}] with value [{}]",
new Object[] { event.getRegion().getFullPath(), event.getKey(), event.isOriginRemote(), event.getNewValue() });
}
#Override
public void afterUpdate(EntryEvent<Object, Object> event)
{
LOGGER.info("[afterUpdate] region [{}] key [{}] updated remote [{}] with value [{}] old value [{}]",
new Object[] { event.getRegion().getFullPath(), event.getKey(), event.isOriginRemote(), event.getNewValue(), event.getOldValue() });
}
}
I created a simple test with a Peer Cache Subregion having a registered CacheListener configured with SDG and the listener was called back as expected. It is possible there are other factors or reasons why this does not work for you...
Not knowing your entire SDG XML configuration, but perhaps if there were competing GemFire configuration in play, such as using native GemFire cache.xml with Spring config with conflicting Region definitions (but you do state afterRegionCreate is being called), e.g. ...
2.I was using SDG 1.4.0.RELEASE and both GemFire 7.0.2.12 and 8 in my testing. However, you should be able to use both my test and example SDG XML config to test with your setup...
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration("/subRegionCacheListener.xml")
#SuppressWarnings("unused")
public class SubRegionCacheListenerTest {
private static final Stack<EntryEvent<Integer, String>> entryEvents = new Stack<EntryEvent<Integer, String>>();
#Resource(name = "/Parent/Child")
private Region<Integer, String> child;
#Test
public void testCacheListenerCallback() {
assertNotNull("The '/Parent/Child' Cache Sub-Region was not properly configured and initialized!", child);
assertEquals("Child", child.getName());
assertEquals("/Parent/Child", child.getFullPath());
assertTrue(child.isEmpty());
assertTrue(entryEvents.isEmpty());
child.put(1, "TEST");
assertFalse(child.isEmpty());
assertEquals(1, child.size());
assertEquals("TEST", child.get(1));
assertFalse(entryEvents.isEmpty());
EntryEvent event = entryEvents.pop();
assertNotNull(event);
assertEquals(1, event.getKey());
assertNull(event.getOldValue());
assertEquals("TEST", event.getNewValue());
assertTrue(entryEvents.isEmpty());
child.put(1, "TESTING");
assertFalse(child.isEmpty());
assertEquals(1, child.size());
assertEquals("TESTING", child.get(1));
assertFalse(entryEvents.isEmpty());
event = entryEvents.pop();
assertNotNull(event);
assertEquals(1, event.getKey());
assertEquals("TEST", event.getOldValue());
assertEquals("TESTING", event.getNewValue());
assertTrue(entryEvents.isEmpty());
child.remove(1);
assertTrue(child.isEmpty());
event = entryEvents.pop();
assertNotNull(event);
assertEquals(1, event.getKey());
assertEquals("TESTING", event.getOldValue());
assertNull(event.getNewValue());
}
public static final class SubRegionCacheListener extends CacheListenerAdapter<Integer, String> {
#Override
public void afterCreate(final EntryEvent<Integer, String> event) {
entryEvents.push(event);
}
#Override
public void afterDestroy(final EntryEvent<Integer, String> event) {
entryEvents.push(event);
}
#Override
public void afterUpdate(final EntryEvent<Integer, String> event) {
entryEvents.push(event);
}
}
}
And the corresponding SDG XML config...
<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
">
<util:properties id="gemfireProperties">
<prop key="name">SpringGemFirePeerCacheSubRegionCacheListenerTest</prop>
<prop key="mcast-port">0</prop>
<prop key="log-level">config</prop>
</util:properties>
<gfe:cache properties-ref="gemfireProperties"/>
<gfe:replicated-region id="Parent">
<gfe:replicated-region name="Child">
<gfe:cache-listener>
<bean class="org.spring.data.gemfire.cache.SubRegionCacheListenerTest$SubRegionCacheListener"/>
</gfe:cache-listener>
</gfe:replicated-region>
</gfe:replicated-region>
</beans>
Hope this helps.
Most likely, there maybe a configuration issue here, or possibly a problem with GemFire 6.x (though you state it works with GemFire's cache.xml?).
This should work as of 1.3.3, see https://jira.spring.io/browse/SGF-219. If you're certain it doesn't work, please add a comment to that JIRA.

jBoss deployment of message-driven bean spec violation

I have an java EE application which has one message-driven bean and it runs fine on JBoss 4, however when I configure the project for JBoss 6 and deploy on it, I get this error;
WARN [org.jboss.ejb.deployers.EjbDeployer.verifier] EJB spec violation:
...
The message driven bean must declare one onMessage() method.
...
org.jboss.deployers.spi.DeploymentException: Verification of Enterprise Beans failed, see above for error messages.
But my bean HAS the onMessage method! It would not have worked on jboss 4 either then.
Why do I get this error!?
Edit:
The class in question looks like this
package ...
imports ...
public class MyMDB implements MessageDrivenBean, MessageListener {
AnotherSessionBean a;
OneMoreSessionBean b;
public MyMDB() {}
public void onMessage(Message message) {
if (message instanceof TextMessage) {
try {
//Lookup sessionBeans by jndi, create them
lookupABean();
// check message-type, then invokie
a.handle(message);
// else
b.handle(message);
} catch (SomeException e) {
//handling it
}
}
}
public void lookupABean() {
try {
// code to lookup session beans and create.
} catch (CreateException e) { // handling it and catching NamingException too }
}
}
Edit 2:
And this is the jboss.xml relevant parts
<message-driven>
<ejb-name>MyMDB</ejb-name>
<destination-jndi-name>topic/A_Topic</destination-jndi-name>
<local-jndi-name>A_Topic</local-jndi-name>
<mdb-user>user</mdb-user>
<mdb-passwd>pass</mdb-passwd>
<mdb-client-id>MyMessageBean</mdb-client-id>
<mdb-subscription-id>subid</mdb-subscription-id>
<resource-ref>
<res-ref-name>jms/TopicFactory</res-ref-name>
<jndi-name>jms/TopicFactory</jndi-name>
</resource-ref>
</message-driven>
Edit 3:
I just removed all my jars from the project, and only re-added relevant ones (from new versions also) to put out NoClassDefFound errors.
Still the problem remains.
Edit:
Any directions, what area should I look at? My project, or jboss-configration, or the deployment settings??
org.jboss.ejb.deployers.EjbDeployer.verifier
looks for
public void onMessage(javax.jms.Message)
via some code like this (this is from JBoss5):
/**
* Check if the given message is the onMessage() method
*/
public boolean isOnMessageMethod(Method m)
{
if ("onMessage".equals(m.getName()))
{
Class[] paramTypes = m.getParameterTypes();
if (paramTypes.length == 1)
{
if (Message.class.equals(paramTypes[0]))
return true;
}
}
return false;
}
It is important that the parameter type is javax.jms.Message and nothing else, for example some subclass or superclass or some implementing class.
Your signature is public void onMessage(Message message) which looks ok on first sight.
A Class is equal only in its ClassLoader. If for some reasons javax.jms.Message is available in different classloaders in the same JVM, strange things can happen, depending on the ClassLoader of the EjbDeployer.verifier. Maybe the EjbDeployer.verifer has a access to javax.jms.Message in another ClassLoader as MyMDB. As result, both javax.jms.Message are not equal to each other, although they are the same byte-code and literally exists. The EjbVerifier will warn about missing onMessage, because javax.jms.Message on ClassLoader A is not equal to javax.jms.Message on ClassLoader B.
This can happen when libraries with javax.jms.Message is copied on wrong places on the JBoss AS. So I guess - from a distance - that there is some jars containing javax.jms.Message in wrong places on the JBoss or the EAR. For example some wrong jbossallclient.jar in the EAR.
Make sure your EAR does not contain its own copies of the javax.ejb classes (or any javax classes at all, for that matter). JBoss 4 and 6 have rather different classloading semantics, and what works on one may not work on the other. For example, if your EAR's lib contained its own copies of Message or MessageListener, then it may no longer work.
I tried it out on "JBossAS [6.0.0.20100911-M5 "Neo"]" and Eclipse Helios
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.ejb.MessageDrivenBean;
import javax.ejb.MessageDrivenContext;
import javax.jms.Message;
import javax.jms.MessageListener;
#MessageDriven(
activationConfig = { #ActivationConfigProperty(
propertyName = "destinationType", propertyValue = "javax.jms.Topic"
) },
mappedName = "topic/A_Topic",
messageListenerInterface = MessageListener.class)
public class MyMDB implements MessageListener, MessageDrivenBean {
private static final long serialVersionUID = -4923389997501209506L;
public MyMDB() {
// TODO Auto-generated constructor stub
}
#Override
public void ejbRemove() {
// TODO Auto-generated method stub
}
#Override
public void setMessageDrivenContext(MessageDrivenContext arg0) {
// TODO Auto-generated method stub
}
#Override
public void onMessage(Message message) {
// TODO Auto-generated method stub
}
}
And this setting works. Do you have the same imports for your bean (perhaps there was an automatic import gone wrong???)