-
1. Re: EJB.3.1: persisting objekts containing http-keys not possible
jaikiran Jun 21, 2017 12:08 AM (in response to grazyna)Are you saying the client hangs on that EJB invocation? Or do you see the client return back without any errors?
Furthermore, the code you pasted shows that you just log warn messages for exception blocks and return back. Have you checked the server log files to see if there's some error?
-
2. Re: EJB.3.1: persisting objekts containing http-keys not possible
grazyna Jun 22, 2017 3:53 AM (in response to jaikiran)Yes, my client hangs on that EJB invocation and does NOT retur.
In server log files is no trace.
Because of this behavior I mean the client call goes into nirvana:
the client call does not reach the server, if the objekt to be persist contains http-keys.
-
3. Re: EJB.3.1: persisting objekts containing http-keys not possible
grazyna Aug 22, 2017 6:03 AM (in response to grazyna)I abstract the problem: it is not possible to persist an entity with HTTP-Key as content.
(HTTP-keys: POST | GET | HEAD | DELETE | TRACE | OPTIONS | CONNECT)
How to reproduce this error:
- Create Stateless Bean „SimpleEJB“ with the following content and deploy it in wildfly-10.1.0.Final:
package bean4persistence.tbean;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import bean4persistence.ebean.JpaEntity4Http;
@Remote
public interface SaveJpaEntityRemote {
public void addJpaEntity4Http (JpaEntity4Http e) throws RemoteException;
} // end-of-SaveJpaEntityRemote
package bean4persistence.tbean;
import java.rmi.RemoteException;
import java.util.logging.Logger;
import javax.annotation.Resource;import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
import javax.sql.DataSource;
import bean4persistence.ebean.JpaEntity4Http;
/**
* Session Bean implementation class SaveJpaEntity
*/
@Stateless
@LocalBean
public class SaveJpaEntity implements SaveJpaEntityRemote {
@Resource(name = "MySqlApDS")
private DataSource apDS;
@PersistenceUnit(name = "bean4save")
EntityManagerFactory emf;
private static final Logger log = Logger.getLogger(SaveJpaEntity.class.getName());
public SaveJpaEntity() {
}
@Override
public void addJpaEntity4Http(JpaEntity4Http e) throws RemoteException {
EntityManager em = emf.createEntityManager();
try {
log.info("Persist JpaEntity4Http="+ e.toString());
em.persist(e);
log.info("JpaEntity4Http saved in the database:-)");
} catch (SecurityException ex) {
log.warning("SecurityException ex=" + ex);
} catch (IllegalStateException ex) {
log.warning("IllegalStateException ex=" + ex);
} finally {
em.close();
}
} // end-of-addJpaEntity4Http
} // end-of-SaveJpaEntity
package bean4persistence.ebean;import java.io.Serializable;
import java.lang.String;
import javax.persistence.*;
/**
* Entity implementation class for Entity: JpaEntity4Http
*
*/
@Entity
@Table(name="JPAENTITY4HTTP")
public class JpaEntity4Http implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@Column(name = "nameWithHttp", nullable = false, length = 120)
private String nameWithHttp;
public JpaEntity4Http() {
super();
}
public String getNameWithHttp() {
return nameWithHttp;
}
public void setNameWithHttp(String nameWithHttp) {
this.nameWithHttp = nameWithHttp;
}
@Override
public String toString() {
return "JpaEntity4Http [nameWithHttp=" + nameWithHttp + "]";
}
} // end-of-JpaEntity4Http
Additionally, persistence.xml:<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="bean4save">
<jta-data-source>java:jboss/jdbc/MySqlApDS</jta-data-source>
<properties>
<property name="jboss.entity.manager.jndi.name" value="java:/bean4save" />
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="hibernate.jdbc.use_streams_for_binary" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
</properties>
</persistence-unit>
</persistence>
- Create the client for the following function:
“Create Entity with content from args[0], perist this entity in the MySQL database using Stateless Bean “SimpleEJB”(deployed in wildfly-10.1.0.Final)"
package client;
import java.rmi.RemoteException;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.apache.log4j.Logger;
import bean4persistence.ebean.JpaEntity4Http;
import bean4persistence.tbean.SaveJpaEntityRemote;
public class SaveOneEntity {
private static final Logger log = Logger.getRootLogger();
SaveJpaEntityRemote se;
public static SaveJpaEntityRemote lookupRemoteStatelessApDb() {
log.info("lookupRemoteStatelessApDb()");
try {
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
prop.put(Context.PROVIDER_URL, "http-remoting://127.0.0.1:8080");
prop.put(Context.SECURITY_AUTHENTICATION, "none");
// create in WildFly the application user
// (with add-user.bat, e.g. appUser, appUser9#)
// and enter the user here:
prop.put(Context.SECURITY_PRINCIPAL, "appUser");
prop.put(Context.SECURITY_CREDENTIALS, "appUser9#");
Context context = new InitialContext(prop);
// for remote access lookupName has to be
// in namespace "java:jboss/exported" (wildfly-jndi)
String lookupName = "SimpleEJB/SaveJpaEntity!bean4persistence.tbean.SaveJpaEntityRemote";if ((SaveJpaEntityRemote) context.lookup(lookupName) != null) {
log.info("OK, context.lookup(lookupName) is not null :-)");
return (SaveJpaEntityRemote) context.lookup(lookupName);
} else {
log.warn("NotOK: context.lookup(lookupName) is null!");
return null;
}
} catch (NamingException ex) {
log.warn("NotOK: NamingException in lookupRemoteStatelessApDb(), exception=" + ex);
}
return null;
} // end-of-lookupRemoteStatelessApDbpublic static void main(String[] args) {
if (args.length != 1) {
log.info( "\nStart the programm with one parameter, e.g. SaveOneEntity BLA\n");
} else {
log.info("Create Entity with content from args[0]="+args[0] + ", perist this entity in the MySQL database using Stateless Bean");
String name4JpaEntity4Http = args[0];
JpaEntity4Http e = new JpaEntity4Http();
e.setNameWithHttp(name4JpaEntity4Http);
try {
lookupRemoteStatelessApDb().addJpaEntity4Http(e);
} catch (RemoteException ex) {
log.warn("RemoteException: " + ex);
}
}
} // enf-of-main
} // end-of-SaveOneEntity
Additionally, jboss-ejb-client.xml:#########################################################################
# This file contains remoting connections configuration for EJB receiver
#########################################################################
endpoint.name=client-endpoint
remote.connections=default
remote.connection.default.host=127.0.0.1
remote.connection.default.port=8080
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
# create in WildFly the application user (with add-user.bat, e.g. appUser, appUser9#) and enter the user here:
remote.connection.default.username=appUser
remote.connection.default.password=appUser9#
remote.connection.default.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false
remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS=JBOSS-LOCAL-USER
- Call the client, e.g.
- SaveOneEntity GRACE
- SaveOneEntity post
- SaveOneEntity POST <-- The Problem!
- My Traces (inside of JBoss Developer Studio):
- Client: ( after the last call “SaveOneEntity POST")
2017-08-21 16:47:46,818 INFO [main] root: Create Entity with content from args[0]=POST, perist this entity in the MySQL database using Stateless Bean
2017-08-21 16:47:46,818 INFO [main] root: lookupRemoteStatelessApDb()
2017-08-21 16:47:46,864 DEBUG [main] org.jboss.logging: Logging Provider: org.jboss.logging.Log4jLoggerProvider
2017-08-21 16:47:46,896 DEBUG [main] org.jboss.naming.remote.client.InitialContextFactory: Looking for jboss-naming-client.properties using classloader sun.misc.Launcher$AppClassLoader@73d16e93
2017-08-21 16:47:46,896 DEBUG [main] org.jboss.naming.remote.client.InitialContextFactory: jboss.naming.client.endpoint.create.options. has the following options {}
2017-08-21 16:47:46,896 DEBUG [main] org.jboss.naming.remote.client.InitialContextFactory: jboss.naming.client.remote.connectionprovider.create.options. has the following options {}
2017-08-21 16:47:46,927 INFO [main] org.xnio: XNIO version 3.4.0.Final
2017-08-21 16:47:46,942 INFO [main] org.xnio.nio: XNIO NIO Implementation Version 3.4.0.Final
2017-08-21 16:47:47,098 DEBUG [Remoting "config-based-naming-client-endpoint" I/O-1] org.xnio.nio: Started channel thread 'Remoting "config-based-naming-client-endpoint" I/O-1', selector sun.nio.ch.WindowsSelectorImpl@15ea860b
2017-08-21 16:47:47,098 DEBUG [Remoting "config-based-naming-client-endpoint" Accept] org.xnio.nio: Started channel thread 'Remoting "config-based-naming-client-endpoint" Accept', selector sun.nio.ch.WindowsSelectorImpl@d8cf766
2017-08-21 16:47:47,098 INFO [main] org.jboss.remoting: JBoss Remoting version 4.0.21.Final
2017-08-21 16:47:47,130 DEBUG [main] org.jboss.naming.remote.client.InitialContextFactory: jboss.naming.client.connect.options. has the following options {}
2017-08-21 16:47:50,608 INFO [main] root: OK, context.lookup(lookupName) is not null :-)
2017-08-21 16:47:50,608 DEBUG [main] org.jboss.ejb.client.EJBClientPropertiesLoader: Looking for jboss-ejb-client.properties using classloader sun.misc.Launcher$AppClassLoader@73d16e93
2017-08-21 16:47:50,608 DEBUG [main] org.jboss.ejb.client.EJBClientPropertiesLoader: Found jboss-ejb-client.properties using classloader sun.misc.Launcher$AppClassLoader@73d16e93
2017-08-21 16:47:50,609 DEBUG [main] org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration: endpoint.create.options. has the following options {}
2017-08-21 16:47:50,609 DEBUG [main] org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration: remote.connectionprovider.create.options. has the following options {org.xnio.Options.SSL_ENABLED=>false}
2017-08-21 16:47:50,609 DEBUG [main] org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration: remote.connection.default.connect.options. has the following options {org.xnio.Options.SASL_POLICY_NOANONYMOUS=>false,org.xnio.Options.SASL_DISALLOWED_MECHANISMS=>[JBOSS-LOCAL-USER],org.xnio.Options.SASL_POLICY_NOPLAINTEXT=>false}
2017-08-21 16:47:50,609 DEBUG [main] org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration: remote.connection.default.channel.options. has the following options {}
2017-08-21 16:47:50,609 DEBUG [main] org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration: Connection org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration$RemotingConnectionConfigurationImpl@6ec8211c successfully created for connection named default
2017-08-21 16:47:50,609 DEBUG [main] org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration: No clusters configured in properties
2017-08-21 16:47:50,646 DEBUG [Remoting "client-endpoint" I/O-1] org.xnio.nio: Started channel thread 'Remoting "client-endpoint" I/O-1', selector sun.nio.ch.WindowsSelectorImpl@3583e550
2017-08-21 16:47:50,646 DEBUG [Remoting "client-endpoint" Accept] org.xnio.nio: Started channel thread 'Remoting "client-endpoint" Accept', selector sun.nio.ch.WindowsSelectorImpl@5bf7dd81
2017-08-21 16:47:52,393 DEBUG [Remoting "client-endpoint" task-5] org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver: Channel Channel ID ba3e6da0 (outbound) of Remoting connection 23e62195 to /127.0.0.1:8080 of endpoint "client-endpoint" <29b2db84> opened for context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@27fe3806, receiver=Remoting connection EJB receiver [connection=org.jboss.ejb.client.remoting.ConnectionPool$PooledConnection@5f71c76a,channel=jboss.ejb,nodename=gda-pc-544]} Waiting for version handshake message from server
2017-08-21 16:47:52,394 INFO [Remoting "client-endpoint" task-6] org.jboss.ejb.client.remoting: EJBCLIENT000017: Received server version 2 and marshalling strategies [river]
2017-08-21 16:47:52,394 INFO [main] org.jboss.ejb.client.remoting: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@27fe3806, receiver=Remoting connection EJB receiver [connection=org.jboss.ejb.client.remoting.ConnectionPool$PooledConnection@5f71c76a,channel=jboss.ejb,nodename=gda-pc-544]} on channel Channel ID ba3e6da0 (outbound) of Remoting connection 23e62195 to /127.0.0.1:8080 of endpoint "client-endpoint" <29b2db84>
2017-08-21 16:47:52,394 DEBUG [Remoting "client-endpoint" task-7] org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver: Received module availability report for 1 modules
2017-08-21 16:47:52,394 DEBUG [Remoting "client-endpoint" task-7] org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver: Registering module EJBModuleIdentifier{appName='', moduleName='SimpleEJB', distinctName=''} availability for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@27fe3806, receiver=Remoting connection EJB receiver [connection=org.jboss.ejb.client.remoting.ConnectionPool$PooledConnection@5f71c76a,channel=jboss.ejb,nodename=gda-pc-544]}
2017-08-21 16:47:52,394 DEBUG [main] org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector: Registered 1 remoting EJB receivers for EJB client context org.jboss.ejb.client.EJBClientContext@27fe3806
2017-08-21 16:47:52,425 DEBUG [main] org.jboss.ejb.client.EJBClientContext: org.jboss.ejb.client.RandomDeploymentNodeSelector@71a794e5 deployment node selector selected gda-pc-544 node for appname=,modulename=SimpleEJB,distinctname=
2017-08-21 16:47:52,425 DEBUG [main] org.jboss.ejb.client.ReceiverInterceptor: Sending invocation to node gda-pc-544
2. wildfly-10.1.0.Final-Traces:
16:45:09,052 INFO [org.jboss.as.ejb3.deployment] (MSC service thread 1-2) WFLYEJB0473: JNDI bindings for session bean named 'SaveJpaEntity' in deployment unit 'deployment "SimpleEJB.jar"' are as follows:
java:global/SimpleEJB/SaveJpaEntity!bean4persistence.tbean.SaveJpaEntityRemote
java:app/SimpleEJB/SaveJpaEntity!bean4persistence.tbean.SaveJpaEntityRemote
java:module/SaveJpaEntity!bean4persistence.tbean.SaveJpaEntityRemote
java:jboss/exported/SimpleEJB/SaveJpaEntity!bean4persistence.tbean.SaveJpaEntityRemote
java:global/SimpleEJB/SaveJpaEntity!bean4persistence.tbean.SaveJpaEntity
java:app/SimpleEJB/SaveJpaEntity!bean4persistence.tbean.SaveJpaEntity
java:module/SaveJpaEntity!bean4persistence.tbean.SaveJpaEntity
16:45:09,208 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 65) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:45:09,208 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 65) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:45:09,255 INFO [org.jboss.weld.Version] (MSC service thread 1-5) WELD-000900: 2.3.5 (Final)
16:45:09,614 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 65) WFLYCLINF0002: Started client-mappings cache from ejb container
16:45:09,693 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 65) WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'SimpleEJB.jar#bean4save'
16:45:10,036 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 65) HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
16:45:10,098 INFO [org.hibernate.envers.boot.internal.EnversServiceImpl] (ServerService Thread Pool -- 65) Envers integration enabled? : true
16:45:10,488 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 65) HHH000227: Running hbm2ddl schema export
16:45:11,128 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 65) HHH000230: Schema export complete
16:45:11,597 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0010: Deployed "SimpleEJB.jar" (runtime-name : "SimpleEJB.jar")
16:46:34,494 INFO [org.jboss.ejb.client] (pool-1-thread-1) JBoss EJB Client version 2.1.4.Final
16:46:36,463 INFO [bean4persistence.tbean.SaveJpaEntity] (default task-12) Persist JpaEntity4Http=JpaEntity4Http [nameWithHttp=GRACE]
16:46:36,573 INFO [bean4persistence.tbean.SaveJpaEntity] (default task-12) JpaEntity4Http saved in the database:-)
16:47:12,381 INFO [bean4persistence.tbean.SaveJpaEntity] (default task-27) Persist JpaEntity4Http=JpaEntity4Http [nameWithHttp=post]
16:47:12,429 INFO [bean4persistence.tbean.SaveJpaEntity] (default task-27) JpaEntity4Http saved in the database:-)
-
4. Re: EJB.3.1: persisting objekts containing http-keys not possible
ctomc Aug 22, 2017 9:33 AM (in response to grazyna)what is the problem? any stacktrace?
-
5. Re: EJB.3.1: persisting objekts containing http-keys not possible
grazyna Aug 22, 2017 10:21 AM (in response to ctomc)No stacktrace, no error.
The problem is, the client make a call:
2017-08-21 16:47:52,425 DEBUG [main] org.jboss.ejb.client.ReceiverInterceptor: Sending invocation to node gda-pc-544
and does not return! You have to finish the client with ctrl+C.
The wildfly does not know about any action of client and the entity is not persisted.
-
6. Re: EJB.3.1: persisting objekts containing http-keys not possible
jaikiran Aug 22, 2017 11:59 AM (in response to grazyna)Can you attach thread dumps of both the server side as well as the client side when this hangs? You can use jstack or any other method to generate the thread dumps.
I actually gave your sample application a try with a modified quickstart against 10.1.0.Final of WildFly and haven't been able to reproduce this issue.
-
7. Re: EJB.3.1: persisting objekts containing http-keys not possible
grazyna Aug 23, 2017 9:00 AM (in response to jaikiran)Here you are!
I used the jstack tool.
-
ThreadDumpClient.log.zip 1.9 KB
-
ThreadDump-Wildfly.log.zip 4.1 KB
-
-
8. Re: EJB.3.1: persisting objekts containing http-keys not possible
jaikiran Aug 23, 2017 11:23 AM (in response to grazyna)The thread dump that you attached for the WildFly server is actually a thread dump for the Eclipse/JBoss Tools process and doesn't have anything relevant. The one you attached for the client is relevant and does show that the client is waiting for the server to respond with a result.
Can you identify the WildFly server JVM process and get us the thread dump of that when this hangs?
-
9. Re: EJB.3.1: persisting objekts containing http-keys not possible
grazyna Aug 23, 2017 11:53 AM (in response to jaikiran)One more try:-)
-
WildflyThreadDump1.log.zip 5.4 KB
-
-
10. Re: EJB.3.1: persisting objekts containing http-keys not possible
jaikiran Aug 25, 2017 11:26 AM (in response to grazyna)No matter what I try, I haven't been able to reproduce this issue. I used all the same code that you have in your post (including using MySQL database) but I get back successful responses.
Having said that, I do believe you are running into this issue and given that you are running into issue with HTTP method names, there's definitely something at play. Which operating system are you on? Windows? Is any firewall enabled or any anti-virus (which probably are doing some kind of packet checks to the HTTP port)? If any of that is enabled, can you try disabling them and see how it goes? Are you client and server on different systems? If so, try disabling any of these firewall/anti-virus on both the systems while testing.
As for the thread dumps, what it tells me is that the client side sent a message, representing the EJB invocation, to the server and is waiting on a response. The server side thread dump shows no sign of currently processing that request, which can mean either of 2 things - the request either never reached the server side or the request did reach the server side, ran into some exception and that exception wasn't propagated back to the client. The latter one is hard to imagine/believe, given that we have extensive tests and code which make me think there isn't a bug in that part. So I'm suspecting the request isn't reaching the WildFly server JVM at all - which brings us to the firewall/anti-virus question.
-
11. Re: EJB.3.1: persisting objekts containing http-keys not possible
grazyna Aug 28, 2017 7:03 AM (in response to jaikiran)Yes, you are right: the anti-virus was enabled. I disabled it and it works.
Thanks:-)