I am trying to connect to JMX using my java code from JBoss EAp 6.4, but I am getting an error saying:
java.lang.IllegalArgumentException: MBeanServer argument must be MBean server where this server is registered, or an MBeanServerForwarder leading to that server
My standalone.xml file has:
<subsystem xmlns="urn:jboss:domain:jmx:1.3">
<expose-resolved-model/>
<expose-expression-model/>
<remoting-connector/>
</subsystem>
ports used are:
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="management-native" interface="management" port="${jboss.management.native.port:7204}"/>
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:7203}"/>
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:7205}"/>
<socket-binding name="http" port="7201"/>
<socket-binding name="https" port="7202"/>
<socket-binding name="ajp" port="7206"/>
<socket-binding name="remoting" port="7207"/>
<socket-binding name="txn-recovery-environment" port="7208"/>
<socket-binding name="txn-status-manager" port="7209"/>
<outbound-socket-binding name="mail-smtp">
<remote-destination host="localhost" port="25"/>
</outbound-socket-binding>
</socket-binding-group>
Java Code, I am using is:
_mbeanServer = ManagementFactory.getPlatformMBeanServer();
String domain = "HtmlAdaptor";
HtmlAdaptorServer adapter = new HtmlAdaptorServer();
String domain = "com.mn";
Hashtable<String,String> params = new Hashtable<String, String>();
params.put("name", "JMXHtmlAdaptor");
params.put("port", String.valueOf(_jmxHttpPort));
ObjectName adapterName = new ObjectName(domain, params);
adapter.setPort(_jmxHttpPort);
server.registerMBean(adapter, adapterName);
adapter.setMBeanServer(_mbeanServer);
// _jmxHttpPort = 10099
// ManagementFactory.getPlatformMBeanServer(); returns object of type org.jboss.as.jmx.PluggableMBeanServerImpl
// adapter.getMBeanServer() returns com.sun.jmx.mbeanserver.JmxMBeanServer
// server returns object of type org.jboss.as.jmx.PluggableMBeanServerImpl
I think the adapter getting created is of wrong type.
Any idea how to resolve this issue?
Related
I cant get google or stackoverflow to tell me how to load into my Fuseki server a named grapah from a ttl file.
My Java function is
public static void uploadTtl(String ttlFileLocation, String graphname) {
RDFConnection conn = RDFConnectionFactory.connect(serviceURL);
if (graphname == null)
conn.load(ttlFileLocation);
else
conn.load(graphname, ttlFileLocation);
conn.close();
}
If
graphname = null;
Then
loads fine
If
graphname = "graphname";
Then
Exception in thread "main" org.apache.jena.atlas.web.HttpException: 500 - Read-only block manager
at org.apache.jena.riot.web.HttpOp.exec(HttpOp.java:1093)
at org.apache.jena.riot.web.HttpOp.execHttpPost(HttpOp.java:721)
at org.apache.jena.riot.web.HttpOp.execHttpPost(HttpOp.java:665)
at org.apache.jena.rdfconnection.RDFConnectionRemote.lambda$doPutPost$3(RDFConnectionRemote.java:320)
at org.apache.jena.rdfconnection.RDFConnectionRemote.exec(RDFConnectionRemote.java:518)
at org.apache.jena.rdfconnection.RDFConnectionRemote.doPutPost(RDFConnectionRemote.java:315)
at org.apache.jena.rdfconnection.RDFConnectionRemote.upload(RDFConnectionRemote.java:297)
at org.apache.jena.rdfconnection.RDFConnectionRemote.load(RDFConnectionRemote.java:240)
at modelDTriplestore.MdFuseki_uploadFile.uploadTtl(MdFuseki_uploadFile.java:36)
at modelDTriplestore.MdFuseki_uploadFile.main(MdFuseki_uploadFile.java:15)
What is giving exception from?
conn.load(graphname, ttlFileLocation);
Envionment details include:
Fuseki Version 3.14.0
Running inside stain/jena-fuseki docker image
Jave 8
POM
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>apache-jena-libs</artifactId>
<type>pom</type>
<version>3.17.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.jena/jena -->
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-shaded-guava</artifactId>
<version>3.17.0</version>
<type>pom</type>
</dependency>
The calling code is fine.
The 500 error coming from the server and passed on by the client.
The server log file will have details but it looks like the server is running on an read-only file area for a TDB database.
I have a problem connecting to a neo4j server from Java EE.
I use :
- neo4j 3.0.1 in server mode on localhost
- Weblogic 12.1.3
- JEE 7
- neo4j-ogm-core 2.0.3
- neo4j-ogm-bolt-driver 2.0.3
My Maven dependencies :
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-core</artifactId>
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-bolt-driver</artifactId>
<version>2.0.3</version>
</dependency>
My ogm.properties in resources/META-INF :
#Driver, required
driver=org.neo4j.ogm.drivers.bolt.driver.BoltDriver
#URI of the Neo4j database, required. If no port is specified, the default port 7687 is used. Otherwise, a port can be specified with bolt://neo4j:password#localhost:1234
URI=bolt://neo4j:xxxxxx#localhost
#Connection pool size (the maximum number of sessions per URL), optional, defaults to 50
connection.pool.size=150
#Encryption level (TLS), optional, defaults to REQUIRED. Valid values are NONE,REQUIRED
encryption.level=NONE
#Trust strategy, optional, not used if not specified. Valid values are TRUST_ON_FIRST_USE,TRUST_SIGNED_CERTIFICATES
trust.strategy=TRUST_ON_FIRST_USE
I use a EJB Singleton to define Session Factory :
#Singleton
public class Neo4jSessionFactory {
private SessionFactory sessionFactory;
#PostConstruct
public void init() {
sessionFactory = new SessionFactory("com.toto.poc.ejb.data.access");
}
/**
* Get neo4j session
* #return the session
*/
public Session getNeo4jSession() {
return sessionFactory.openSession();
}
}
it is in "com.toto.poc.ejb.data.access" package.
I have a EJB to define the business method in want to call :
#Stateless
public class TopologyBusiness {
private #EJB Neo4jSessionFactory neo4jSessionFactory;
public Iterable<Map<String, Object>> getApplication(String irt) {
String query = "MATCH (a:Application) WHERE a.irt = '" + irt + "' RETURN a";
Session session = neo4jSessionFactory.getNeo4jSession();
return session.query(query, Collections.emptyMap());
}
}
But when my client call TopologyBusiness, the init (PostConstruct) method of Neo4jSessionFactory is called, and an error occur :
com.oracle.pitchfork.interfaces.LifecycleCallbackException: Failure to invoke public void com.toto.poc.ejb.data.access.Neo4jSessionFactory.init() on bean class class com.toto.poc.ejb.data.access.Neo4jSessionFactory_wi88u8_Impl with args: null
at com.oracle.pitchfork.inject.Jsr250Metadata.invokeLifecycleMethod(Jsr250Metadata.java:379)
at com.oracle.pitchfork.inject.Jsr250Metadata.invokeLifecycleMethods(Jsr250Metadata.java:352)
at com.oracle.pitchfork.intercept.InterceptionMetadata.invokeLifecycleMethods(InterceptionMetadata.java:399)
at weblogic.ejb.container.injection.EjbComponentCreatorImpl.invokePostConstruct(EjbComponentCreatorImpl.java:55)
at weblogic.ejb.container.manager.SingletonSessionManager.constructAndInitBean(SingletonSessionManager.java:330)
Truncated. see log file for complete stacktrace
Caused By: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.oracle.pitchfork.inject.Jsr250Metadata.invokeLifecycleMethod(Jsr250Metadata.java:377)
Truncated. see log file for complete stacktrace
Caused By: java.lang.RuntimeException: org.neo4j.ogm.exception.ServiceNotFoundException: Resource: zip:C:/oracle/wls/12.1.3/user_projects/domains/CMDB/servers/LocalServer/tmp/_WL_user/poc-cdb-ear_ear/a8qjfi/poc-cdb-ejb-1.0-SNAPSHOT.jar!/com/toto.poc/ejb/data/access
at org.neo4j.ogm.ClassUtils.getUniqueClasspathElements(ClassUtils.java:178)
at org.neo4j.ogm.scanner.ClassPathScanner.getUniqueClasspathElements(ClassPathScanner.java:158)
at org.neo4j.ogm.scanner.ClassPathScanner.scan(ClassPathScanner.java:130)
at org.neo4j.ogm.metadata.DomainInfo.load(DomainInfo.java:316)
at org.neo4j.ogm.metadata.DomainInfo.<init>(DomainInfo.java:67)
Truncated. see log file for complete stacktrace
Caused By: org.neo4j.ogm.exception.ServiceNotFoundException: Resource: zip:C:/oracle/wls/12.1.3/user_projects/domains/CMDB/servers/LocalServer/tmp/_WL_user/poc-cdb-ear_ear/a8qjfi/poc-cdb-ejb-1.0-SNAPSHOT.jar!/com/toto.poc/ejb/data/access
at org.neo4j.ogm.service.ResourceService.resolve(ResourceService.java:53)
at org.neo4j.ogm.ClassUtils.getUniqueClasspathElements(ClassUtils.java:175)
at org.neo4j.ogm.scanner.ClassPathScanner.getUniqueClasspathElements(ClassPathScanner.java:158)
at org.neo4j.ogm.scanner.ClassPathScanner.scan(ClassPathScanner.java:130)
at org.neo4j.ogm.metadata.DomainInfo.load(DomainInfo.java:316)
Truncated. see log file for complete stacktrace
The root cause seems to be :
Caused By: org.neo4j.ogm.exception.ServiceNotFoundException: Resource: zip:C:/oracle/wls/12.1.3/user_projects/domains/CMDB/servers/LocalServer/tmp/_WL_user/poc-cdb-ear_ear/a8qjfi/poc-cdb-ejb-1.0-SNAPSHOT.jar!/com/toto.poc/ejb/data/access
I have no idea why it wants to look into a zip in the classpath ...
Thank for your help !
I can finally resolve my problem, I browsed odd forums and found someone who had similar issue on JBoss.
So I managed to transpose this solution to Weblogic.
First, you need to create your own resource resolver to provide the way to deal with "zip".
Overwrite ResourceResolver and implements resolve method like below :
public class Neo4jResourceResolver implements ResourceResolver {
#Override
public File resolve(URL resource) throws Exception {
switch (resource.getProtocol()) {
case "file":
return new File(resource.toURI());
case "jar":
case "zip":
String jarPath = resource.getPath().substring(0, resource.getPath().indexOf("!"));
return new File(jarPath);
default:
return null;
}
}
}
Then create a file named "org.neo4j.ogm.classloader.ResourceResolver" in path "src/main/resources/META-INF/services".
This file contains only one line, the path to your custom ResourceResolver class :
com.toto.poc.core.access.ucmdb.Neo4jResourceResolver
And it's magic, it works !!!
Neo4j will now explore the jar archive, found your NodeEntities and map it to your graph :)
The following configuration is working when I deploy the wep app in my local machine (windows)
public void contextInitialized(ServletContextEvent sce) {
Logger logger = null;
ServletContext servletContext = sce.getServletContext();
String prefix = servletContext.getRealPath("/");
String log4jFile = servletContext.getInitParameter("log4j");
if (log4jFile != null) {
DOMConfigurator.configure(prefix + log4jFile);
logger = LogManager.getLogger(StartupListener.class.getName());
logger.info("LOG4J loaded successfully: " + log4jFile);
}
}
<context-param>
<param-name>log4j</param-name>
<param-value>WEB-INF/classes/com/domain/resources/log4j.xml</param-value>
</context-param>
<listener>
<listener-class>com.domain.util.StartupListener</listener-class>
</listener>
But when installing the web app in the Linux I get the following error message:
log4j:ERROR Could not parse file [nullWEB-INF/classes/com/domain/resources/log4j.xml].
java.io.FileNotFoundException: /app/home/wdmt3/AdminServer/nullWEB-INF/classes/com/domain/resources/log4j.xml (No such file or directory)
Any advice ?
<context-param>
<param-name>log4j</param-name>
<param-value>/WEB-INF/classes/com/domain/resources/log4j.xml</param-value>
</context-param>
Problem:
servletContext.getRealPath return null and you log file path become
nullWEB-INF/classes/com/domain/resources/log4j.xml
It's impossible to load this file and log4j just throws an error message you saw.
So why servletContext.getRealPath return null?
The API docs for ServletContext.getRealPath(String path) state:
This method returns null if the servlet container is unable to translate the given virtual path to a real path.
Different container may have quite different behavior.
Solution:
Try with the solution from spring mvc and make sure log4jFile starts with '/':
String log4jFile = servletContext.getInitParameter("log4j");
String fullPath = servletContext.getRealPath(log4jFile);
The issue resolve by configure properly the weblogic server in order to retrieve the path (domain -> Web Application -> Archived Real Path Enabled)
I'm trying to invoke business logic via JMX (using 'standard' MBeans) in a web application in Websphere Application Server 7 with JTA switched on and would like to know why this business logic can't see the JTA UserTransaction when invoked from an MBean (because it can when invoked via the web app's UI).
When hibernate attempts to look up the UserTransaction via 'java:comp/UserTransaction', the following exception is thrown:
org.hibernate.TransactionException: Could not find UserTransaction in JNDI [java:comp/UserTransaction]
at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:173)
at org.hibernate.transaction.JTATransactionFactory.createTransaction(JTATransactionFactory.java:149)
...
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 com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:105)
at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:39)
at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:220)
at com.sun.jmx.mbeanserver.PerInterface.getAttribute(PerInterface.java:77)
at com.sun.jmx.mbeanserver.MBeanSupport.getAttribute(MBeanSupport.java:228)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:678)
at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:650)
at com.ibm.ws.management.AdminServiceImpl.getAttribute(AdminServiceImpl.java:853)
at com.ibm.ws.management.remote.AdminServiceForwarder.getAttribute(AdminServiceForwarder.java:270)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1415)
at javax.management.remote.rmi.RMIConnectionImpl.access$200(RMIConnectionImpl.java:84)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1276)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1371)
at javax.management.remote.rmi.RMIConnectionImpl.getAttribute(RMIConnectionImpl.java:612)
at javax.management.remote.rmi._RMIConnectionImpl_Tie.getAttribute(_RMIConnectionImpl_Tie.java:578)
at javax.management.remote.rmi._RMIConnectionImpl_Tie._invoke(_RMIConnectionImpl_Tie.java:98)
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:1563)
Caused by: javax.naming.ConfigurationException: A JNDI operation on a "java:" name cannot be completed because the server runtime is not able to associate the operation's thread with any J2EE application component. This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request. Make sure that a J2EE application does not execute JNDI operations on "java:" names within static code blocks or in threads created by that J2EE application. Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on "java:" names. [Root exception is javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".]
at com.ibm.ws.naming.java.javaURLContextImpl.throwConfigurationExceptionWithDefaultJavaNS(javaURLContextImpl.java:428)
at com.ibm.ws.naming.java.javaURLContextImpl.lookup(javaURLContextImpl.java:399)
at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:214)
at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:154)
at javax.naming.InitialContext.lookup(InitialContext.java:455)
at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:163)
... 53 more
Caused by: javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".
at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1178)
at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:1095)
at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1233)
at com.ibm.ws.naming.java.javaURLContextImpl.lookup(javaURLContextImpl.java:395)
... 57 more
This problem looks like it's more than just a hibernate configuration problem - hibernate is looking for the UserTransaction at what IBM say is the correct UserTransaction JNDI location ('java:comp/UserTransaction') - see this infocenter document.
Furthermore, I can reproduce the problem in a simple web app that has an MBean that does the lookup:
public class JTALookup extends NotificationBroadcasterSupport implements JTALookupMBean {
Log log = LogFactory.getLog(JTALookup.class);
/**
* {#inheritDoc}
* #see JTALookupMBean#lookupUserTransaction()
*/
#Override
public void lookupUserTransaction() {
try {
log.info("Attempting 'java:comp/UserTransaction' lookup");
Object usrTxn = new InitialContext().lookup("java:comp/UserTransaction");
log.info("Successfully looked up 'java:comp/UserTransaction' [" + usrTxn + "]." );
} catch (NamingException e) {
log.info("'java:comp/UserTransaction' lookup failed");
throw new RuntimeException("Failed to lookup JTA user transaction", e);
}
}
and a context listener that invokes the lookup during start up and then registers the MBean:
public void contextInitialized(ServletContextEvent sce) {
log.info("Initialising context");
JTALookup jtaLookup = new JTALookup();
jtaLookup.lookupUserTransaction(); // This succeeds
log.info("Looked up JTA transaction");
MBeanServer mbServer = AdminServiceFactory.getMBeanFactory().getMBeanServer();
log.info("Got MBeanServer");
try {
mbServer.registerMBean(jtaLookup, new ObjectName("webJTALookupStub:type=JTALookup"));
log.info("Registered dummy MBean");
} catch (Exception e) {
log.info("Failed to register dummy MBean");
throw new RuntimeException("Failed to register dummy MBean", e);
}
}
The lookup on 'java:comp/UserTransaction' succeeds during context initialisation, but fails (with a similar stack trace to that above) when invoked via jmx, like so:
public static void main(String[] args) {
JMXServiceURL url = new JMXServiceURL(
"service:jmx:rmi://" + "your.server.name.co.uk" + ":" + "2809" + "/jndi/JMXConnector"
);
Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(Context.PROVIDER_URL, "corbaloc:iiop:gbbldd66.sys.chp.co.uk:2809/WsnAdminNameService");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
// Establish the JMX connection.
JMXConnector jmxc = JMXConnectorFactory.connect(url, env);
// Get the MBean server connection instance.
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
ObjectName mbeanName = new ObjectName("webJTALookupStub:type=JTALookup");
JTALookupMBean mBean = JMX.newMBeanProxy(mbsc, mbeanName, JTALookupMBean.class, true);
mBean.lookupUserTransaction(); // This fails
The 'Extending the WebSphere Application Server administrative system with custom MBeans' document in IBM's infocenter suggests that standard MBeans that have been tested in applications outside WAS should just work.
IBM do state that the UserTransaction lookup is not available to:
CMT Enterprise beans `http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/cjta_glotran.html
Async Beans created by EJBs `http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/topic/com.ibm.websphere.javadoc.doc/web/apidocs/com/ibm/websphere/asynchbeans/package-summary.html?resultof=%22%61%73%79%6e%63%68%62%65%61%6e%22%20%22%75%73%65%72%74%72%61%6e%73%61%63%74%69%6f%6e%22%20%22%75%73%65%72%74%72%61%6e%73%61%63%74%22%20
Apologies for the non-functional links - I'm a new user and so can only post two working links.
Do plain old MBeans fall into either of these categories from IBM's point of view?
Interestingly, the UserTransaction appears to be available on JNDI lookup 'jta/UserTransaction' and using that as a fallback option seems to work - but:
WAS 7 is Java EE 5 compliant and as of J2EE 1.3 'java:comp/UserTransaction' is the specified JNDI location for the UserTransaction - see the J2EE 1.3 spec `http://java.sun.com/j2ee/j2ee-1_3-fr-spec.pdf
Using a lookup from an earlier version of the EE specification seems like a potential source of other bugs, and might only be addressing part of my problem - the fact that WAS thinks my MBean's thread is not associated with an application could cause other issues.
One further point to note is that the UserTransaction is also hidden to threads for work submitted from the MBean to the application's work manager (an IBM work manager) - which could be because it's treating that work like it's an async bean submitted by an EJB?
Possible explanations that have occurred to me are:
There might issues with how IBM set up MBean threads in WAS 7 and associate then with the applications that register the MBeans.
There might be some additional configuration options for the MBean registration that would let WAS know that it should associate the MBean with the application that registered it. I have tried several alternative approaches but saw the same exception each time:
Registering the MBeans with UserCollaborators and xml descriptors
Registering them with ModelMBeanInfo
Registering them with the AdminService rather than the MBeanServer
Enhancing the ObjectName for the MBean with additional properties (Application, J2EEApplication) at registration
There might be some additional configuration options for the jmx client request that would let WAS know that it should associate the MBean invokation with the appropriate application. This forum post suggests it's possible to configure a client application to have access to the initial context: `http://www.ibm.com/developerworks/forums/thread.jspa?messageID=14021995
I might just not be supposed to try to use MBeans this way - despite IBM's statements that I should be able to. It's been suggested that EJBs are the appropriate solution for this kind of requirement.
Any light that can be shed on this problem would be greatly appreciated.
MBeans run on a separate thread than your application, so they don't have access to the application naming context in JNDI, and therefore they don't have access to your UserTransaction.
I think your final potential explanation is likely most accurate:
I might just not be supposed to try to use MBeans this way - despite IBM's statements that I should be able to. It's been suggested that EJBs are the appropriate solution for this kind of requirement.
MBeans may not be appropriate for this type of work. Rather, using EJBs or a web service might be more appropriate.
You have to set TransactionManagementType.BEAN on transactionManagement like so:
#TransactionManagement(TransactionManagementType.BEAN)
I am using JSF 2 ,myfaces, hibernate-validator-4.1.0.Final.jar.
I use hibernate-validator for validating values entered in form.
public class Client {
#Persistent
#Pattern(regexp = "|.+#.+\\.[a-z]+", message = "Email format is invalid.")
private String email;
//getter
}
I am developing bulk-upload module ,where i parse csv data and create database records.
...
try{
Client cl=new Client();
cl.setEmail("from_csv_data");
}catch( //validation failed
How do i reuse the same validator here?
Set> constraintViolations = validator.validate(nc);
throws this exception
SEVERE: Received 'java.lang.NoSuchMethodError' when invoking action listener '#{clientBean.bulkUpload}' for component 'j_idt86'
Jan 28, 2011 8:35:39 AM javax.faces.event.MethodExpressionActionListener processAction
SEVERE: java.lang.NoSuchMethodError: javax.persistence.Persistence.getPersistenceUtil()Ljavax/persistence/PersistenceUtil;
at
org.hibernate.validator.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:62)
I tried this solution link
I have hibernate-jpa-2.0-api-1.0.0.Final.jar,hibernate-validator-4.1.0.Final.jar
Do I need any other jar to make this work?
You can invoke the validator manually with something like:
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Client client = new Client();
Set<ConstraintViolation<Client>> constraintViolations = validator.validate(client);
You most likely have another incomplete JPA 2 jar file on the classpath. Unfortunately, some incomplete versions of this jar got released at some stage (TopLink for example). Check your classpath for any jar containing JPA classes. See also https://forum.hibernate.org/viewtopic.php?f=9&t=999855