We are trying to configure infinispan as the 2nd level cache for Hibernate in Jboss EAP 7.1 and run the jboss in clustered two node setup.
Lookup for cache elements works, but if we update hibernate entities, then update cache step triggered by infinispan fails on both nodes with marshaling error ( caused by class not found exception ) of that entity we are trying to update.
Here is the configuration :
In hibernate-cfg.xml
org.hibernate.cache.infinispan.InfinispanRegionFactory
in sample-entity-hbm.xml
<class name="com.business.standard.StandardCode" table="csc011">
<cache usage="read-write"/>
in jboss standalone-ha.xml
<cache-container name="hibernate" module="org.hibernate.infinispan">
<transport channel="hibernate-channel" lock-timeout="60000"/>
<local-cache name="local-query">
<eviction strategy="LRU" max-entries="10000"/>
<expiration max-idle="100000"/>
</local-cache>
<replicated-cache name="timestamps" mode="ASYNC"/>
<invalidation-cache name="entity">
<transaction mode="NON_XA"/>
<eviction strategy="LRU" max-entries="10000"/>
<expiration max-idle="100000"/>
</invalidation-cache>
</cache-container>
Error :
15:02:45,974 WARN [org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher] (OOB-20,XXX-53994) ISPN000220: Problems un-marshalling remote command from byte buffer: java.lang.ClassNotFoundException: com.business.standard.StandardCode from [Module "org.hibernate.infinispan" from local module loader #64d2d351 (finder: local module finder #1b68b9a4 (roots: C:\jboss-eap-7.1\NodeA\modules,C:\jboss-eap-7.1\NodeA\modules\system\layers\base.overlays\layer-base-jboss-eap-7.1.5.CP,C:\jboss-eap-7.1\NodeA\modules\system\layers\base,C:\jboss-eap-7.1\DEV\modules))]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:412)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:400)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.jboss.marshalling.AbstractClassResolver.loadClass(AbstractClassResolver.java:123)
at org.jboss.marshalling.AbstractClassResolver.resolveClass(AbstractClassResolver.java:104)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadClassDescriptor(RiverUnmarshaller.java:1022)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1355)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:272)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:220)
at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1853)
at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1767)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1395)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:272)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:205)
at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:41)
at org.infinispan.commons.marshall.MarshallUtil.unmarshallArray(MarshallUtil.java:159)
at org.infinispan.commands.write.InvalidateCommand.readFrom(InvalidateCommand.java:109)
at org.hibernate.cache.infinispan.util.BeginInvalidationCommand.readFrom(BeginInvalidationCommand.java:47)
at org.infinispan.marshall.exts.ReplicableCommandExternalizer.readCommandParameters(ReplicableCommandExternalizer.java:113)
at org.infinispan.marshall.exts.ReplicableCommandExternalizer.readObject(ReplicableCommandExternalizer.java:89)
at org.infinispan.marshall.exts.ReplicableCommandExternalizer.readObject(ReplicableCommandExternalizer.java:41)
at org.infinispan.marshall.core.ExternalizerTable$ExternalizerAdapter.readObject(ExternalizerTable.java:479)
at org.infinispan.marshall.core.ExternalizerTable.readObject(ExternalizerTable.java:236)
at org.infinispan.marshall.core.JBossMarshaller$ExternalizerTableProxy.readObject(JBossMarshaller.java:149)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:350)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:205)
at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:41)
at org.infinispan.commands.remote.SingleRpcCommand.readFrom(SingleRpcCommand.java:46)
at org.infinispan.marshall.exts.ReplicableCommandExternalizer.readCommandParameters(ReplicableCommandExternalizer.java:113)
at org.infinispan.marshall.exts.CacheRpcCommandExternalizer.readObject(CacheRpcCommandExternalizer.java:173)
at org.infinispan.marshall.exts.CacheRpcCommandExternalizer.readObject(CacheRpcCommandExternalizer.java:68)
at org.infinispan.marshall.core.ExternalizerTable$ExternalizerAdapter.readObject(ExternalizerTable.java:479)
at org.infinispan.marshall.core.ExternalizerTable.readObject(ExternalizerTable.java:236)
at org.infinispan.marshall.core.JBossMarshaller$ExternalizerTableProxy.readObject(JBossMarshaller.java:149)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:350)
at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:205)
at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:41)
at org.infinispan.commons.marshall.jboss.AbstractJBossMarshaller.objectFromObjectStream(AbstractJBossMarshaller.java:134)
at org.infinispan.marshall.core.VersionAwareMarshaller.objectFromByteBuffer(VersionAwareMarshaller.java:101)
at org.infinispan.commons.marshall.AbstractDelegatingMarshaller.objectFromByteBuffer(AbstractDelegatingMarshaller.java:80)
at org.infinispan.remoting.transport.jgroups.MarshallerAdapter.objectFromBuffer(MarshallerAdapter.java:28)
at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.handle(CommandAwareRpcDispatcher.java:163)
at org.jgroups.blocks.RequestCorrelator.handleRequest(RequestCorrelator.java:455)
at org.jgroups.blocks.RequestCorrelator.dispatch(RequestCorrelator.java:406)
at org.jgroups.blocks.RequestCorrelator.receiveMessage(RequestCorrelator.java:357)
at org.jgroups.blocks.RequestCorrelator.receive(RequestCorrelator.java:245)
at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.up(MessageDispatcher.java:664)
at org.jgroups.JChannel.up(JChannel.java:738)
at org.jgroups.stack.ProtocolStack.up(ProtocolStack.java:1030)
at org.jgroups.protocols.FRAG2.up(FRAG2.java:165)
at org.jgroups.protocols.FlowControl.up(FlowControl.java:390)
at org.jgroups.protocols.pbcast.GMS.up(GMS.java:1037)
at org.jgroups.protocols.pbcast.STABLE.up(STABLE.java:234)
at org.jgroups.protocols.UNICAST3.deliverMessage(UNICAST3.java:1077)
at org.jgroups.protocols.UNICAST3.handleDataReceived(UNICAST3.java:792)
at org.jgroups.protocols.UNICAST3.up(UNICAST3.java:433)
at org.jgroups.protocols.pbcast.NAKACK2.up(NAKACK2.java:649)
at org.jgroups.protocols.VERIFY_SUSPECT.up(VERIFY_SUSPECT.java:155)
at org.jgroups.protocols.FD_ALL.up(FD_ALL.java:200)
at org.jgroups.protocols.FD_SOCK.up(FD_SOCK.java:325)
at org.jgroups.protocols.MERGE3.up(MERGE3.java:292)
at org.jgroups.protocols.Discovery.up(Discovery.java:296)
at org.jgroups.protocols.MPING.up(MPING.java:178)
at org.jgroups.protocols.TP.passMessageUp(TP.java:1658)
at org.jgroups.protocols.TP$SingleMessageHandler.run(TP.java:1876)
Thanks
Santhosh S
Related
I have a deployed queue on JBoss EAP 7.1 (defined in standalone.xml) that is managed by ActiveMQ Artemis (name of the module xmlns="urn:jboss:domain:messaging-activemq:2.0") and at the same time I want to connect to that queue with the JMS plugin in logstash (with JNDI) for consuming the messages that are sent by the deployed app on my JBoss server, but when I try I get a NameNotFoundException for the connection factory (the property jndi_name in the logstash conf file).
I tried to find the default connection factories JNDI entries but even then it didn't work.
So i want to know if the connection factories are created by the message broker or exist by default for the client? Because if I'm not mistaken, the connection factory is the only way to connect to the broker and the queue and correct if I'm wrong please but they have to exist by default for the client.
I hope you can help me guys here is my logstash conf file:
input {
jms {
# Logstash Configuration Settings.
include_header => false
include_properties => false
include_body => true
use_jms_timestamp => false
destination => "AuditTrailMDB"
pub_sub => false
# JNDI Settings
jndi_name => 'queueConnectionFactory'
jndi_context => {
'java.naming.factory.initial' => 'org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory'
'java.naming.security.principal' => 'admin'
'java.naming.provider.url' => 'tcp://localhost:5445?type=QUEUE_CF'
'java.naming.security.credentials' => 'admin'
}
# Jar files to be imported
require_jars=> ['/home/Alternant/logstash/dependencies/jboss-client.jar',
'/home/Alternant/logstash/dependencies/artemis-ra.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-core-impl.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-core-api.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-common-api.jar']
}
}output{
stdout{}
}
and here is my queue definition in the standalone.xml:
<subsystem xmlns="urn:jboss:domain:messaging-activemq:2.0">
<server name="default">
<security-setting name="#">
<role consume="true" create-non-durable-queue="true" delete-non-durable-queue="true" name="guest" send="true"/>
</security-setting>
<address-setting dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-size-bytes="10485760" message-counter-history-day-limit="10" name="#" page-size-bytes="2097152"/>
<http-connector endpoint="http-acceptor" name="http-connector" socket-binding="http"/>
<http-connector endpoint="http-acceptor-throughput" name="http-connector-throughput" socket-binding="http">
<param name="batch-delay" value="50"/>
</http-connector>
<in-vm-connector name="in-vm" server-id="0">
<param name="buffer-pooling" value="false"/>
</in-vm-connector>
<remote-connector name="netty" socket-binding="remote-messaging"/>
<http-acceptor http-listener="default" name="http-acceptor"/>
<http-acceptor http-listener="default" name="http-acceptor-throughput">
<param name="batch-delay" value="50"/>
<param name="direct-deliver" value="false"/>
</http-acceptor>
<in-vm-acceptor name="in-vm" server-id="0">
<param name="buffer-pooling" value="false"/>
</in-vm-acceptor>
<remote-acceptor name="netty" socket-binding="messaging"/>
<jms-queue entries="java:/jms/queue/ExpiryQueue" name="ExpiryQueue"/>
<jms-queue entries="java:/jms/queue/DLQ" name="DLQ"/>
<jms-queue entries="queue/clientPending" name="clientPending"/>
<jms-queue name="AuditTrailMDB" entries="queue/AuditTrailMDB"/>
<connection-factory connectors="in-vm" entries="java:/ConnectionFactory" name="InVmConnectionFactory"/>
<pooled-connection-factory connectors="netty" entries="java:jboss/exported/jms/RemoteConnectionFactory" name="RemoteConnectionFactory" user="admin" password="admin"/>
<pooled-connection-factory connectors="in-vm" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" name="activemq-ra" transaction="xa"/>
<connection-factory connectors="in-vm" entries="/ApplicationsQueueConnectionFactory" name="ApplicationsQueueConnectionFactory"/>
</server>
</subsystem>
...
<socket-binding name="messaging" port="5445"/>
...
log:
[WARN ][logstash.inputs.jms ][main] JMS Consumer Died {:exception=>"Java::JavaxNaming::NameNotFoundException", :exception_message=>"queueConnectionFactory", :backtrace=>["org.apache.activemq.artemis.jndi.ReadOnlyContext.lookup(org/apache/activemq/artemis/jndi/ReadOnlyContext.java:236)", "javax.naming.InitialContext.lookup(javax/naming/InitialContext.java:417)", "java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:498)", "org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(org/jruby/javasupport/JavaMethod.java:455)", "org.jruby.javasupport.JavaMethod.invokeDirect(org/jruby/javasupport/JavaMethod.java:316)", "home.Alternant.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.jruby_minus_jms_minus_1_dot_3_dot_0_minus_java.lib.jms.connection.initialize
There's a handful of things wrong with your configuration both for JBoss EAP and for Logstash.
Let's start with JBoss EAP...
First, you changed the default configuration of RemoteConnectionFactory to this:
<pooled-connection-factory connectors="netty" entries="java:jboss/exported/jms/RemoteConnectionFactory" name="RemoteConnectionFactory" user="admin" password="admin"/>
This is incorrect. A remote client cannot use a pooled-connection-factory, only a client in the same JVM as the application server can (e.g. an MDB which needs to send a message). You should use the default configuration instead:
<connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
Second, your AuditTrailMDB queue will not be available to remote clients. Here's its configuration:
<jms-queue name="AuditTrailMDB" entries="queue/AuditTrailMDB"/>
It needs a new JNDI entry in the java:jboss/exported/ namespace in order to be available to remote clients (e.g. like RemoteConnectionFactory has). Therefore you should use this:
<jms-queue name="AuditTrailMDB" entries="queue/AuditTrailMDB java:jboss/exported/AuditTrailMDB"/>
Now for Logstash...
First, you're using the wrong JNDI properties. The properties you're using are for the ActiveMQ Artemis JNDI implementation. Here's your current configuration:
jndi_context => {
'java.naming.factory.initial' => 'org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory'
'java.naming.security.principal' => 'admin'
'java.naming.provider.url' => 'tcp://localhost:5445?type=QUEUE_CF'
'java.naming.security.credentials' => 'admin'
}
This is incorrect. When ActiveMQ Artemis is embedded into JBoss EAP then EAP itself handles all the JNDI lookups. Therefore you should be using this configuration instead:
jndi_context => {
'java.naming.factory.initial' => 'org.wildfly.naming.client.WildFlyInitialContextFactory'
'java.naming.security.principal' => 'admin'
'java.naming.provider.url' => 'http-remoting://127.0.0.1:8080'
'java.naming.security.credentials' => 'admin'
}
This assumes, of course, that you've added the proper admin user to EAP.
Second, your connection factory JNDI name is incorrect. You're currently using this:
jndi_name => 'queueConnectionFactory'
You should be using this instead:
jndi_name => 'jms/RemoteConnectionFactory'
Third, the jars you're using are incorrect. Here's your current configuration:
require_jars=> ['/home/Alternant/logstash/dependencies/jboss-client.jar',
'/home/Alternant/logstash/dependencies/artemis-ra.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-core-impl.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-core-api.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-common-api.jar']
You don't need most of these at all. You can simplify your configuration by using the wildfly-client-all "uber" jar which is available here. Then your configuration would look like this:
require_jars=> ['/home/Alternant/logstash/dependencies/wildfly-client-all-7.1.0.GA-redhat-11.jar']
after migrating from jboss as 7 to wildfly 15 jndi-name of infinispan cache container is not valid anymore with wildfly 15.
OPVDX001: Validierungsfehler in standalone.xml ---------------------------------
|
| 344:
| 345: <subsystem xmlns="urn:jboss:domain:infinispan:7.0">
| 346: <cache-container jndi-name="java:jboss/infinispan/my-container" name="my-container" module="org.infinispan.hibernate-cache">
| "cache-container"
| ^^^^ "jndi-name" ist kein zulässiges Attribut für das Element
|
| Die folgenden Attribute sind hier zulässig: aliases, default-cache,
| module, name, statistics-enabled
|
| 347: <local-cache name="my-other-container">
| 348: <expiration lifespan="900000" />
| 349: </local-cache>
|
| "jndi-name" ist zulässig bei Elementen:
is there a replacement for jndi-name?
Property "jndi-name" is deleted. Just declare the property "name".
Then you can lookup the container using the pattern below. The container is available in JDNI context with this lookup path: java:jboss/infinispan/container/<your-container-name>/
Sample config:
<cache-container name="my-container" module="org.infinispan.hibernate-cache">
<local-cache name="lala" >
<object-memory size="10000"/>
<expiration max-idle="100000"/>
</local-cache>
</cache-container>
instead of
#Resource(lookup = "java:jboss/infinispan/my-container")
private EmbeddedCacheManager cacheManager;
use
#Resource(lookup = "java:jboss/infinispan/container/my-container/"
private EmbeddedCacheManager cacheManager;
or direct inject cache
// java:jboss/infinispan/cache/<name-of-container>/<name-of-cache>
#Resource(lookup = "java:jboss/infinispan/cache/my-container/lala")
private Cache<String, PrincipalEntity> userCache;
see also:
wildscribe subsystem infinispan
related issue
I'm trying to setup client side thread management on a Wildlfy 10 AS for JMS using ActiveMQ, I have a queue setup in standalone-full.xml DemoQueue currently the AS is creating endless threads eating up memory till eventual it crashes
<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
<server name="default">
<security-setting name="#">
<role name="guest" delete-non-durable-queue="true" create-non-durable-queue="true" consume="true" send="true"/>
</security-setting>
<address-setting name="#" message-counter-history-day-limit="10" page-size-bytes="2097152" max-size-bytes="10485760" expiry-address="jms.queue.ExpiryQueue" dead-letter-address="jms.queue.DLQ"/>
<http-connector name="http-connector" endpoint="http-acceptor" socket-binding="http"/>
<http-connector name="http-connector-throughput" endpoint="http-acceptor-throughput" socket-binding="http">
<param name="batch-delay" value="50"/>
</http-connector>
<in-vm-connector name="in-vm" server-id="0"/>
<http-acceptor name="http-acceptor" http-listener="default"/>
<http-acceptor name="http-acceptor-throughput" http-listener="default">
<param name="batch-delay" value="50"/>
<param name="direct-deliver" value="false"/>
</http-acceptor>
<in-vm-acceptor name="in-vm" server-id="0"/>
<jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
<jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>
<jms-queue name="demoQueue" entries="java:/jms/queue/demoQueue java:jboss/exported/jms/queue/demoQueue"/>
<connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
<connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
<pooled-connection-factory name="activemq-ra" transaction="xa" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm"/>
</server>
</subsystem>
I have it working with server side thread management.
I'v been trying to follow the instructions found here so currently I'm using :
DEFAULT_CONNECTION_FACTORY=jms/RemoteConnectionFactory
DEFAULT_DESTINATION=java:/jms/queue/demoQueue
DEFAULT_USERNAME=mUserName
DEFAULT_PASSWORD=myPassword
INITIAL_CONTEXT_FACTORY=org.jboss.naming.remote.client.InitialContextFactory
PROVIDER_URL=http-remoting://myURL.com:8082
/** Lookup the queue object */
Queue queue = (Queue) context.lookup(props.getProperty("DEFAULT_DESTINATION"));
/** Lookup the queue connection factory */
ConnectionFactory connFactory = (ConnectionFactory) context.lookup(props.getProperty("DEFAULT_CONNECTION_FACTORY"));
try (javax.jms.Connection connection = connFactory.createConnection(props.getProperty("DEFAULT_USERNAME"), props.getProperty("DEFAULT_PASSWORD"));
/** Create a queue session */
Session queueSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
/** Create a queue consumer */
MessageConsumer msgConsumer = queueSession.createConsumer(queue)) {
/** Set an asynchronous message listener */
msgConsumer.setMessageListener(asyncReceiver);
/** Set an asynchronous exception listener on the connection */
connection.setExceptionListener(asyncReceiver);
/** Start connection */
connection.start();
}
Do I need to add the ClientSessionFactory configuration to my "standalone-full.xml" for client side thread management?
I can't access the .setUseGlobalPools(falase); from the RemoteConnectionFactory.
I've tried adding:
ConnectionFactory myConnectionFactory = ActiveMQJMSClient.createConnectionFactory(myFactory);
I can't seem to access the needed methods from my code.
.useGlobalPools=false
scheduledThreadPoolMaxSize=10
I was using Wildfly 9 which implemented HornetQ so some of my configuration may need changing to work properly with ActiveMQ
I was showin a solution to this by a helpful user over on the Jboss forums I used server side thread management by modifying my XML configuration
<connection-factory name="RemoteConnectionFactory"
entries="java:jboss/exported/jms/RemoteConnectionFactory"
connectors="http-connector" use-global-pools="false"
thread-pool-max-size="10"/>
Another Stack user has pointed out on another question I had, that there may be an issue with this and other Wildfly version where this setting will not solve the problem, it did solve it for me, but there is another work around, by passing in the setting as a param during launch:
sh standalone.sh -c standalone-full.xml -Dactivemq.artemis.client.global.thread.pool.max.size=30
As i have already worked JPA 2.1 with eclipselink 2.5.1 everything fine in that configuration. but due to some requirements i have came to JPA 2.0 with eclipselink 2.4.2 and now i am struggling to persist entities into database. as i am running my application while registering a user the data is getting stored some where and it is retrieved fine. but it is not getting persisted into database (MySql). Even i cant figure out the actual usage of JTA and RESOURCE LOCAL could someone help me here is my code
Create.java (register method)
public static int register(String first, String last, String email,
String date, String phone, String address, String pin, Login login) {
try {
System.out.println("registering persisting the entity");
EntityManagerFactory emf = Persistence
.createEntityManagerFactory("FirstEE");
EntityManager manager = emf.createEntityManager();
manager.getTransaction().begin();
//
// Query query = manager
// .createQuery("select l from Truck l");
Login log = login;
System.out.println(log.getUsername() + "username"
+ log.getPassword() + "password");
User reg = new User();
reg.setLogin(log);
reg.setDate(date);
reg.setEmail(email);
reg.setFirst(first);
reg.setLast(last);
reg.setPhone(phone);
reg.setAddress(address);
reg.setPin(pin);
manager.flush();
manager.persist(reg);
manager.getTransaction().commit();
manager.close();
emf.close();
// FacesContext.getCurrentInstance().addMessage("reg:result",
// new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error Message",
// "Registered Successfully"));
FacesContext facesContext = FacesContext.getCurrentInstance();
FacesMessage facesMessage = new FacesMessage(
"Registered Successfully");
facesContext.addMessage(null, facesMessage);
System.out.println("after message global");
return 1;
} catch (Exception e) {
System.out.println("hai this is exception caught:" + e);
System.out.println("hai" + e.getMessage());
FacesContext.getCurrentInstance().addMessage(
"reg:result",
new FacesMessage("Something went wrong",
"\tSomething went wrong\t"));
// FacesContext facesContext = FacesContext.getCurrentInstance();
// FacesMessage facesMessage = new
// FacesMessage("Something went wrong");
// facesContext.addMessage(null, facesMessage);
}
return 0;
}
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="FirstEE" transaction-type="RESOURCE_LOCAL">
<!-- <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> -->
<!-- <non-jta-data-source>FirstEE</non-jta-data-source> -->
<!-- <exclude-unlisted-classes>false</exclude-unlisted-classes> -->
<class>com.jason.Entity.User</class>
<class>com.jason.ManagedBean.Login</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/yash" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="root" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="eclipselink.logging.level" value="FINEST" />
<property name="eclipselink.ddl-generation" value="create-tables" />
</properties>
</persistence-unit>
</persistence>
error log:
<openjpa-2.4.0-r422266:1674604 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "
com.jason.Entity.User
com.jason.ManagedBean.Login".
at org.apache.openjpa.enhance.ManagedClassSubclasser.prepareUnenhancedClasses(ManagedClassSubclasser.java:115)
at org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:311)
at org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:235)
at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:211)
at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:154)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:226)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:153)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:59)
at com.jason.service.GetUser.get(GetUser.java:45)
at com.jason.ManagedBean.Register.getAllUser(Register.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:183)
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:161)
at org.apache.el.parser.AstValue.getValue(AstValue.java:173)
at org.apache.el.parser.AstEmpty.getValue(AstEmpty.java:46)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
at org.apache.webbeans.el22.WrappedValueExpression.getValue(WrappedValueExpression.java:70)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:462)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1850)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:894)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:443)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
at org.apache.myfaces.tomahawk.application.ResourceViewHandlerWrapper.renderView(ResourceViewHandlerWrapper.java:169)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.jason.Filter.Adminfilter.doFilter(Adminfilter.java:62)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
even i restart the eclipse IDE the values are still there. I am so confused. Is there any configuration issue existing here?
I got it i wanted others to know the exact problem. As i am using TomEE which is JavaEE server it is having openJPA as a default persistence provider.
If you want to use Other persistence providers we need to specify the <provider>your provider</provider> explicitly in persistence .xml
TomEE uses JTA as a default Transaction Manager. If you want to use RESOURCE_LOCAL you need to specify the transaction-type="RESOURCE_LOCAL" and also you need to specify the <non-jta-data-source>to be used by the application. otherwise the server will use JTA even though you specified the transaction type as RESOURCE_LOCAL
In order to configure JNDI Datasource refer this link.
Now the values are getting stored into the local database... remember you need to have all the libraries into your lib folder, also the jdbc connector into the server's lib folder so that that it would go well with the JNDI Datasource.
Have you tried to flush the em after persist?
Are you sure you are using eclipselink libraries? Maybe your server has it's own openjpa libraries and you have not override them.
If you look for similar problems on the net (like this, or this), people that have those problems are using openjpa.
I'm using Websphere, JSF 1.2, JPA (Eclipselink)
On my project I have the following structure:
-APHP0000_EJB
.APHP0000FacadeEJB.java
.Controllers (Managers)
.persistence.xml
-APHP0000_EJBClient
.APHP0000FacadeEJBLocal.java
.APHP0000FacadeEJBRemote.java
.Entyties
.TO
-APHP0000_EJBEAR
-APHP0000_Web (depends on APHP0000_EJBClient )
.jsp
.ManageBeans
-APHP0000_WebEAR
-->persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="APHP0000_EJB" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>java:comp/env/ds_aphp_web</jta-data-source>
<jar-file>APHP0000_EJBClient.jar</jar-file>
<class>su.aphpweb.jpa.entities.UnidadeProdutiva</class>
<class>su.aphpweb.jpa.entities.TipoParadaN4</class>
...
<class>su.aphpweb.jpa.entities.MaquinaProdutiva</class>
<properties>
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.target-server" value="org.eclipse.persistence.platform.server.was.WebSphere_7_Platform" />
<property name="javax.persistence.jtaDataSource" value="jdbc/ds_aphp_web" />
<property name="eclipselink.cache.shared.default" value="false" />
<property name="eclipselink.logging.parameters" value="true" />
</properties>
</persistence-unit>
</persistence>
When I Start my container, my APHP0000_EJBEAR is deployed, but my APHP0000_WebEAR is not. and get the following exception. Please, I'm stuck on this thing since last week.
[19/12/12 13:33:49:898 BRST] 00000006 JPAPUnitInfo E CWWJP0015E: Ocorreu um erro no provedor de persistência org.eclipse.persistence.jpa.PersistenceProvider quando ele tentou criar factory de gerenciador de entidade do contêiner para a unidade de persistência APHP0000_EJB. Ocorreu o seguinte erro: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [APHP0000_EJB] failed.
Internal Exception: java.lang.RuntimeException: java.io.FileNotFoundException: D:\Equipe\APHP\APHP0000_EJB\ejbModule\APHP0000_EJBClient.jar (O sistema não pode encontrar o arquivo especificado.)
[19/12/12 13:33:49:898 BRST] 00000006 JPAPUnitInfo E CWWJP0009E: O servidor não pode criar um depósito de informações EntityManagerFactory para a unidade persistente APHP0000_EJB do provedor org.eclipse.persistence.jpa.PersistenceProvider no módulo file:/D:/Equipe/APHP/APHP0000_EJB/ejbModule/.
[19/12/12 13:33:49:914 BRST] 00000006 EJBContainerI I WSVR0037I: Iniciando o jar do EJB: APHP0000_EJB.jar
[19/12/12 13:33:49:914 BRST] 00000006 EJBContainerI I CNTR0167I: O servidor está ligando a interface su.aphpweb.jpa.entities.controller.ResponsParadaUnidManagerRemote do enterprise bean ResponsParadaUnidManager no módulo APHP0000_EJB.jar do aplicativo APHP0000_WebEAR. O local de ligação é: ejb/APHP0000_WebEAR/APHP0000_EJB.jar/ResponsParadaUnidManager#su.aphpweb.jpa.entities.controller.ResponsParadaUnidManagerRemote
[19/12/12 13:33:49:914 BRST] 00000006 EJBContainerI I CNTR0167I: O servidor está ligando a interface su.aphpweb.jpa.entities.controller.UnidadeMotivoTipoManagerRemote do enterprise bean UnidadeMotivoTipoManager no módulo APHP0000_EJB.jar do aplicativo APHP0000_WebEAR. O local de ligação é: ejb/APHP0000_WebEAR/APHP0000_EJB.jar/UnidadeMotivoTipoManager#su.aphpweb.jpa.entities.controller.UnidadeMotivoTipoManagerRemote
[19/12/12 13:33:49:914 BRST] 00000006 ComponentData E CWMDF0015E: O carregador de classes não pode carregar a interface su.aphpweb.negocio.ejb.APHP0000FacadeEJBRemote no arquivo su.aphpweb.negocio.ejb.APHP0000FacadeEJB Enterprise JavaBeans (EJB).
[19/12/12 13:33:49:914 BRST] 00000006 EJBContainerI E WSVR0040E: Falha no addEjbModule para APHP0000_EJB.jar [class com.ibm.ws.runtime.component.DeployedEJBModuleImpl]
com.ibm.ejs.container.EJBConfigurationException: CWMDF0015E: O carregador de classes não pode carregar a interface su.aphpweb.negocio.ejb.APHP0000FacadeEJBRemote no arquivo su.aphpweb.negocio.ejb.APHP0000FacadeEJB Enterprise JavaBeans (EJB).
at com.ibm.ws.metadata.ComponentDataObject.setInterfacesFromImplements(ComponentDataObject.java:783)
at com.ibm.ws.metadata.ComponentDataObject.finishCDO(ComponentDataObject.java:424)
at com.ibm.ws.runtime.component.EJBContainerImpl.startModule(EJBContainerImpl.java:2609)
at com.ibm.ws.runtime.component.EJBContainerImpl.start(EJBContainerImpl.java:3827)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1120)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1313)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:619)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:938)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:723)
at com.ibm.ws.runtime.component.ApplicationMgrImpl$1.run(ApplicationMgrImpl.java:1264)
at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:4476)
at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:4654)
at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplicationDynamically(ApplicationMgrImpl.java:1269)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2041)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:437)
at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:122)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:380)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:651)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:613)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:1175)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:600)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:600)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:243)
at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1086)
at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:967)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:848)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:773)
at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1320)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:1213)
at com.ibm.ws.management.application.AppManagementImpl._startApplication(AppManagementImpl.java:1284)
at com.ibm.ws.management.application.AppManagementImpl.startApplication(AppManagementImpl.java:1180)
at com.ibm.ws.management.application.AppManagementImpl.startApplication(AppManagementImpl.java:1140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:600)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:600)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:243)
at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1086)
at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:967)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:848)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:773)
at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1320)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:1213)
at com.ibm.ws.management.connector.AdminServiceDelegator.invoke(AdminServiceDelegator.java:181)
at com.ibm.ws.management.connector.rmi.RMIConnectorService.invoke(RMIConnectorService.java:282)
at com.ibm.ws.management.connector.rmi._RMIConnectorService_Tie.invoke(_RMIConnectorService_Tie.java:395)
at com.ibm.ws.management.connector.rmi._RMIConnectorService_Tie._invoke(_RMIConnectorService_Tie.java:160)
at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:622)
at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:475)
at com.ibm.rmi.iiop.ORB.process(ORB.java:513)
at com.ibm.CORBA.iiop.ORB.process(ORB.java:1574)
at com.ibm.rmi.iiop.Connection.respondTo(Connection.java:2841)
at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2714)
at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:63)
at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:118)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)
The error seems to indicate that it can't find the jar file, APHP0000_EJBClient.jar. Is the jar in the ear? It needs to be.
You could try removing the tag, and just list the entity classes (as long as there are on the classpath they will be found).
For EJB Exception :CWMDF0015E
It is necessary to click in the paramètrage of publication for WebSphere Application Server of Eclipse IDE "to execute the server and the resources on the server"
and run a server