Simple JSF with Managed Bean cannot be loaded by JBoss 7.1 (JBAS018210) - eclipse

I am getting a strange error in my JBoss log when i try to do a very simple JSF app via Eclipse. So i created a simple scenario to ask, if i have missed something fundamental in my JSF example. Alternatively, i suspect there might be a mis-configuration or bug in my particular tooling or environment.
I have created a very simple JSF app. It's just one JSF html page (hello.jsp) which collects a name via a ManagedBean and transitions to a second JSF html page (ok.jsp). The bean has 1 getter, 1 setter, and 1 action method (addContact).
I am not using annotations, just a simple faces-config.xml file with one ManagedBean entry and one navigation rule. The bean is named "contact" and the class is "com.mbeans.ContactBean". I believe that the mapping is all correct.
I am using JBoss 7.1 via Eclipse Juno SR2. It's a JSF 2.0 app. I have loaded the latest JBoss Tools 4.0 for Juno.
The app only consists of the following files:
web.xml
faces-config.xml
ContactBean.java
hello.jsp
ok.jsp
The file contents are below. But I'll add some colour commentary on how they were created via Eclipse (which you might want to skim or ignore):
I go into Eclipse and create a new project. I select "Dynamic Web Project" with the following settings:
Target runtime = JBoss 7.1 Runtime
Configuration = Dynamic Configuration for JBoss 7.1 Runtime
Generate a web.xml = CHECKED
I right-click WebContent and create a new JSP file (Filename = hello.jsp). I use JSP Template = New JSF Page (html).
I add a few lines representing a simple form accessing a ManagedBean named "contact" so that hello.jsp looks like this:
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%# taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%# taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Add Contact</title>
</head>
<body>
<f:view>
<h2>Add Contact</h2>
<h:form>
Name:<br>
<h:inputText value="#{contact.name}" />
<h:commandButton value="Add Contact"
action="#{contact.addContact}" type="submit" />
</h:form>
</f:view>
</body>
</html>
Similarly, I add the following JSP file (ok.jsp):
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%# taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%# taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>OK - Added New Contact</title>
</head>
<body>
<f:view>
<p>
The address for
<h:outputText value="#{contact.name}" />
was successfully added.
</p>
</f:view>
</body>
</html>
I right-click on the project (JSFTest) and add a class with the following settings:
Package = com.mbeans
Name = ContactBean
and I edit the class to appear like so:
package com.mbeans;
public class ContactBean {
public ContactBean() {super();}
String name;
public String getName() {return name;}
public void setName(String name) {this.name = name;}
public String addContact() {
System.out.println("Name: " + getName());
return "success";
}
}
Then I right-clicked the WEB-INF folder and selected New->Other->JBoss Tools Web->JSF->Faces Config with the following settings:
Folder:* = /JSFTest
Name:* = faces-config
Version: 2.0
Register in web.xml = CHECKED
In the new faces-config.xml that is created, I right-click Managed Beans->New->Managed Bean... and set the following:
Scope = application
Class:* = com.mbeans.ContactBean
Name:* = contactBean
Then I right-clicked Navigation Rules->New->Rule ... and left the dialog box blank and clicked Finish.
I right-clicked "[any]"->New->Case... and set the following:
From Outcome: = success
From Action: = #{contact.addContact}
ToView ID:* = /ok.jsp
this, finally, yields the following faces-config.xml file in the WEB-INF folder:
<?xml version="1.0"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
<managed-bean>
<managed-bean-name>contact</managed-bean-name>
<managed-bean-class>com.mbeans.ContactBean</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
<navigation-rule>
<navigation-case>
<from-action>#{contact.addContact}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/ok.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
Then I right-clicked the hello.jsp and selected Run As->Run On Server
I selected the JBoss 7.1 Runtime Server (it's the only one). The server starts successfully. (I know this JBoss server correctly runs other stuff outside of Eclipse.)
I get a 500 error and in particular, I see the following message in the log which I think is the root of the problem:
23:33:08,612 ERROR [org.jboss.web] (MSC service thread 1-3) JBAS018211: Could not load JSF managed bean class: com.mbeans.ContactBean
I think the NullPointerException may be caused by something else which I did wrong unrelated to that error message above. I am most concerned about the above error. But if anyone can point out my mistake which clears this NullPointerException, I would appreciate it so that I can eliminate it. Previously I got a different 500 error without the NPE but still had that JBAS018211 in the log. In other words, I think the NPE is annoying but irrelevant.
The full log is:
23:33:06,543 INFO [org.jboss.modules] JBoss Modules version 1.1.1.GA
23:33:06,761 INFO [org.jboss.msc] JBoss MSC version 1.0.2.GA
23:33:06,824 INFO [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting
23:33:07,636 INFO [org.xnio] XNIO Version 3.0.3.GA
23:33:07,638 INFO [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
23:33:07,647 INFO [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
23:33:07,655 INFO [org.jboss.remoting] JBoss Remoting version 3.2.3.GA
23:33:07,678 INFO [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
23:33:07,686 INFO [org.jboss.as.configadmin] (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem
23:33:07,689 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem.
23:33:07,717 INFO [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem
23:33:07,725 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
23:33:07,749 INFO [org.jboss.as.security] (MSC service thread 1-10) JBAS013100: Current PicketBox version=4.0.7.Final
23:33:07,749 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
23:33:07,752 INFO [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem
23:33:07,789 INFO [org.jboss.as.connector] (MSC service thread 1-7) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
23:33:07,797 INFO [org.jboss.as.naming] (MSC service thread 1-4) JBAS011802: Starting Naming Service
23:33:07,825 INFO [org.jboss.as.mail.extension] (MSC service thread 1-12) JBAS015400: Bound mail session [java:jboss/mail/Default]
23:33:07,844 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
23:33:07,971 INFO [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-7) JBoss Web Services - Stack CXF Server 4.0.2.GA
23:33:07,982 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-5) Starting Coyote HTTP/1.1 on http--127.0.0.1-7070
23:33:08,341 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
23:33:08,352 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-4) JBAS015012: Started FileSystemDeploymentService for directory /usr/local/jboss-as-7.1.1.Final/standalone/deployments
23:33:08,358 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found JSFTest.war in deployment directory. To trigger deployment create a file called JSFTest.war.dodeploy
23:33:08,360 INFO [org.jboss.as.remoting] (MSC service thread 1-10) JBAS017100: Listening on /127.0.0.1:9999
23:33:08,362 INFO [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on /127.0.0.1:4447
23:33:08,475 INFO [org.jboss.as.server.deployment] (MSC service thread 1-12) JBAS015876: Starting deployment of "JSFTest.war"
23:33:08,612 ERROR [org.jboss.web] (MSC service thread 1-3) JBAS018211: Could not load JSF managed bean class: com.mbeans.ContactBean
23:33:08,792 INFO [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-10) Initializing Mojarra 2.1.7-jbossorg-1 (20120227-1401) for context '/JSFTest'
23:33:09,663 INFO [org.hibernate.validator.util.Version] (MSC service thread 1-10) Hibernate Validator 4.2.0.Final
23:33:09,805 INFO [org.jboss.web] (MSC service thread 1-10) JBAS018210: Registering web context: /JSFTest
23:33:09,818 INFO [org.jboss.as] (MSC service thread 1-2) JBAS015951: Admin console listening on http://127.0.0.1:9990
23:33:09,819 INFO [org.jboss.as] (MSC service thread 1-2) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 3541ms - Started 172 of 249 services (76 services are passive or on-demand)
23:33:09,873 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "JSFTest.war"
23:33:29,683 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/JSFTest].[jsp]] (http--127.0.0.1-7070-1) Servlet.service() for servlet jsp threw exception: java.lang.NullPointerException
at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1858) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at org.apache.jsp.hello_jsp._jspx_meth_f_005fview_005f0(hello_jsp.java:103)
at org.apache.jsp.hello_jsp._jspService(hello_jsp.java:78)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) [jbossweb-7.0.13.Final.jar:]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369) [jbossweb-7.0.13.Final.jar:]
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326) [jbossweb-7.0.13.Final.jar:]
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253) [jbossweb-7.0.13.Final.jar:]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_17]
That's it. That's the problem.
(as an aside, Eclipse also does not display the hover-over tag descriptions for JSF. HTML tags are OK. This makes me wonder if there's some deeper JBoss Tools misconfiguration.)
Thank you for any time spent reviewing my problem.

Try to do the following in addition to what you did:
Right click the project → Properties → Project Facets
Add the Java Server Faces facet with the correct version (yours was 2.0)
Click the additional configuration link at the bottom, select "Library provided by server runtime" (the default) and check the option to configure web.xml. Map the Faces Servlet at /faces/* (for the sake of this answer; you can change it later but remember to change the URLs accordingly)
(may be optional, but try it this way first) I prefer to deploy my applications by openning the server tab, right clicking on the server → Add/Remove... → select your application and deploy
After the app is successfully deployed (check the console) get the URL: http://localhost:8080/JSFTest/faces/hello.jsp
Remember the Faces Servlet mapping - /faces/*? You have to include it in the URL.
This works for me.
By the way, prefer Facelets (the XHTML option) over JSP.

Related

org.hibernate.integrator.spi.Integrator: Provider org.hibernate.search.hcore.impl.HibernateSearchIntegrator not a subtype

My on-going quest to migrate to Hibernate OGM 5.4 on JBoss WildFly 14.0.0.Final to use with MongoDB.
Had it working fine in WildFly 12 & 13 using earlier versions of OGM.
Using OGM 5.4, JPA 2.2, Hibernate ORM 5.3 & Hibernate Search 5.10
as per the: Compatibility matrix
My 'provision' in the Gradle Build is:
provision {
//Optional destination directory:
destinationDir = file("wildfly-custom")
configuration = file( 'wildfly-server-provisioning.xml' )
// Define variables which need replacing in the provisioning configuration!
variables['wildfly.version'] = '14.0.0.Final'
variables['hibernate-orm.version'] = '5.3.7.Final'
variables['hibernate-search.version'] = '5.10.4.Final'
variables['hibernate-ogm.version'] = '5.4.0.CR1'
}
which is used by:
<server-provisioning xmlns="urn:wildfly:server-provisioning:1.1" copy-module-artifacts="true">
<feature-packs>
<feature-pack
groupId="org.wildfly"
artifactId="wildfly-feature-pack"
version="${wildfly.version}"/>
<feature-pack
groupId="org.hibernate"
artifactId="hibernate-orm-jbossmodules"
version="${hibernate-orm.version}"/>
<feature-pack
groupId="org.hibernate"
artifactId="hibernate-search-jbossmodules-orm"
version="${hibernate-search.version}"/>
<feature-pack
groupId="org.hibernate.ogm"
artifactId="hibernate-ogm-featurepack-mongodb"
version="${hibernate-ogm.version}"/>
</feature-packs>
</server-provisioning>
The MongoDB persistence unit in my persistence.xml:
<persistence-unit name="nOTiFYwellMongoDBPersistenceUnit" transaction-type="JTA">
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<properties>
<!-- <property name="jboss.as.jpa.providerModule" value="org.hibernate:5.2"/> -->
<property name="jboss.as.jpa.providerModule" value="org.hibernate:5.3"/>
<!-- <property name="wildfly.jpa.hibernate.search.module" value="org.hibernate.search.orm:5.8"/> -->
<property name="wildfly.jpa.hibernate.search.module" value="org.hibernate.search.orm:5.10.4.Final"/>
<!-- <property name="hibernate.transaction.jta.platform" value="JBossTS"/> -->
<!-- <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAS"/> -->
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform"/>
<property name="hibernate.ogm.datastore.provider" value="org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider"/>
<property name="hibernate.ogm.datastore.grid_dialect" value="org.hibernate.ogm.datastore.mongodb.MongoDBDialect"/>
<property name="hibernate.ogm.datastore.database" value="notifyWellDB"/>
<property name="hibernate.ogm.mongodb.host" value="127.0.0.1"/>
</properties>
</persistence-unit>
I've copied the relevant modules from the generated WildFly 14.0.0.Final to my Home Brew installed one.
When I enable my deployed EAR I get:
21:52:42,808 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0027: Starting deployment of "NOTiFYwell.ear" (runtime-name: "NOTiFYwell.ear")
21:52:43,318 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0207: Starting subdeployment (runtime-name: "NOTiFYwellJAR.jar")
21:52:43,318 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0207: Starting subdeployment (runtime-name: "NOTiFYwellWAR.war")
21:52:44,373 INFO [org.jboss.as.jpa] (MSC service thread 1-5) WFLYJPA0002: Read persistence.xml for nOTiFYwellMySQLPersistenceUnit
21:52:44,373 INFO [org.jboss.as.jpa] (MSC service thread 1-5) WFLYJPA0002: Read persistence.xml for nOTiFYwellMongoDBPersistenceUnit
21:52:44,585 WARN [org.jboss.as.jsf] (MSC service thread 1-6) WFLYJSF0005: Unknown JSF version 'NONE'. Default version 'main' will be used instead.
21:52:44,841 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 20) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'NOTiFYwell.ear/NOTiFYwellJAR.jar#nOTiFYwellMongoDBPersistenceUnit'
21:52:44,861 INFO [org.jboss.weld.deployer] (MSC service thread 1-2) WFLYWELD0003: Processing weld deployment NOTiFYwell.ear
21:52:44,911 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 20) MSC000001: Failed to start service jboss.persistenceunit."NOTiFYwell.ear/NOTiFYwellJAR.jar#nOTiFYwellMongoDBPersistenceUnit".__FIRST_PHASE__: org.jboss.msc.service.StartException in service jboss.persistenceunit."NOTiFYwell.ear/NOTiFYwellJAR.jar#nOTiFYwellMongoDBPersistenceUnit".__FIRST_PHASE__: java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.envers.boot.internal.EnversIntegrator not a subtype
at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:128)
at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:104)
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:650)
at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1.run(PhaseOnePersistenceUnitServiceImpl.java:137)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:485)
Caused by: java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.envers.boot.internal.EnversIntegrator not a subtype
at java.util.ServiceLoader.fail(ServiceLoader.java:239)
at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.loadJavaServices(ClassLoaderServiceImpl.java:465)
at org.hibernate.integrator.internal.IntegratorServiceImpl.<init>(IntegratorServiceImpl.java:40)
at org.hibernate.boot.registry.BootstrapServiceRegistryBuilder.build(BootstrapServiceRegistryBuilder.java:224)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildBootstrapServiceRegistry(EntityManagerFactoryBuilderImpl.java:455)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:199)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:167)
at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:32)
at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:89)
at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.<init>(TwoPhaseBootstrapImpl.java:39)
at org.jboss.as.jpa.hibernate5.HibernatePersistenceProviderAdaptor.getBootstrap(HibernatePersistenceProviderAdaptor.java:199)
at org.wildfly.jpa.hibernateogm5.HibernateOGMPersistenceProviderAdaptor.getBootstrap(HibernateOGMPersistenceProviderAdaptor.java:87)
at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl.createContainerEntityManagerFactoryBuilder(PhaseOnePersistenceUnitServiceImpl.java:254)
at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl.access$900(PhaseOnePersistenceUnitServiceImpl.java:59)
at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:125)
... 9 more
Seen a few other questions with the same error, but none of the suggestions help.
Thanks.
I’m sorry but actually the hibernate-ogm-featurepack-* modules of Hibernate OGM 5.4.0.CR1 work only with WildFly 13.x. There is open issue for WildFly 14.x: https://hibernate.atlassian.net/browse/OGM-1523.
The workaround here is to install just the Hibernate OGM modules without overriding the Hibernate ORM and Hibernate Search modules. Since the versions already provided of Hibernate ORM and Hibernate Search by WildFly 14.0.x are fully compatible with Hibernate OGM 5.4.0.CR1 (or 5.4.0.Final by the way).
I hope that will help you.
Fabio

Changing Liferay war file context root on JBoss EAP

I am trying to deploy Liferay 6.2 CE GA4 WAR file on my JBoss EAP 6.4 server with a specified context root. We already have an application with the context defined as "/" and this is what Liferay defaults to. I have tried following with no luck:
Specifying /liferay as the context root in jboss-web.xml
Creating portal-ext.properties in WEB-INF/classes and including portal.ctx=/liferay
Adding -
<context-param>
<param-name>root_path</param-name>
<param-value>/liferay</param-value>
</context-param>
to web.xml
Ultimately I want http://localhost:8080/liferay to bring me to the Liferay application, not http://localhost:8080. Does anyone have any other suggestions or things that worked for them? I can post full file contents if it would shed more light on my problem.
UPDATE: Here is my JBoss server.log where it is trying to register the context:
16:15:52,652 INFO [org.jboss.as.server.deployment] (MSC service thread 1-9) JBAS015876: Starting deployment of "liferay.war" (runtime-name: "liferay.war")
16:16:04,500 INFO [org.jboss.web] (ServerService Thread Pool -- 324) JBAS018210: Register web context: /liferay
16:16:04,547 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015859: Deployed "liferay.war" (runtime-name : "liferay.war")
16:16:04,547 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014776: Newly corrected services:
service jboss.deployment.unit."liferay-fresh.war".component."com.liferay.alloy.taglib.alloy.AioTag".START (no longer required)
service jboss.deployment.unit."liferay-fresh.war".component."com.liferay.alloy.taglib.alloy.AutoCompleteTag".START (no longer required)
service jboss.deployment.unit."liferay-fresh.war".component."com.liferay.alloy.taglib.alloy.ButtonItemTag".START (no longer required)

EJB's not being injected in JAX-RS

I am using JBoss 6.2.0 EAP, I am trying to get my EJB's injected into my JAX-RS classes but I am getting a NullPointerEXception. It's definitely the CUstomerDAO class, because the error at line 29 is the printOut method being called on a null object. I added beans.xml to my WEB-INF. I am wondering if the servlet I added, or the web.xml configuration I added is giving me an error. I declared a datasource on the jboss server and its working fine. It's just the new stuff I added seems to throw the error. If anyone wants the project I can put it up.
Here are my files
Error stack trace
10:11:32,834 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "mysql-connector-java-5.1.29-bin.jar" (runtime-name: "mysql-connector-java-5.1.29-bin.jar")
10:11:32,835 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-4) JBAS015012: Started FileSystemDeploymentService for directory /opt/jboss-eap-6.2/standalone/deployments
10:11:33,508 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
10:11:33,536 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) JBAS010400: Bound data source [java:/tutorial]
10:11:33,769 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS018559: Deployed "mysql-connector-java-5.1.29-bin.jar" (runtime-name : "mysql-connector-java-5.1.29-bin.jar")
10:11:33,852 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
10:11:33,852 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
10:11:33,853 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss EAP 6.2.0.GA (AS 7.3.0.Final-redhat-14) started in 6615ms - Started 160 of 220 services (58 services are passive or on-demand)
10:12:44,006 INFO [org.jboss.as.repository] (HttpManagementService-threads - 2) JBAS014900: Content added at location /opt/jboss-eap-6.2/standalone/data/content/bc/c99f85aabe406819b2f1f6d5c660b3fcb0d231/content
10:12:51,778 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "webproject.war" (runtime-name: "webproject.war")
10:12:52,031 WARN [org.jboss.weld.deployer] (MSC service thread 1-2) JBAS016010: Warning while parsing vfs:/content/webproject.war/WEB-INF/beans.xml:6 SchemaLocation: schemaLocation value = ' http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd' must have even number of URI's.
10:12:52,103 INFO [org.jboss.as.jpa] (MSC service thread 1-2) JBAS011401: Read persistence.xml for tutorial
10:12:52,239 INFO [org.jboss.weld.deployer] (MSC service thread 1-2) JBAS016002: Processing weld deployment webproject.war
10:12:52,267 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean named WebProject in deployment unit deployment "webproject.war" are as follows:
java:global/webproject/WebProject!com.example.ejbrest.WebProject
java:app/webproject/WebProject!com.example.ejbrest.WebProject
java:module/WebProject!com.example.ejbrest.WebProject
java:global/webproject/WebProject
java:app/webproject/WebProject
java:module/WebProject
10:12:52,268 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean named CustomerDAO in deployment unit deployment "webproject.war" are as follows:
java:global/webproject/CustomerDAO!com.example.ejbrest.CustomerDAO
java:app/webproject/CustomerDAO!com.example.ejbrest.CustomerDAO
java:module/CustomerDAO!com.example.ejbrest.CustomerDAO
java:global/webproject/CustomerDAO
java:app/webproject/CustomerDAO
java:module/CustomerDAO
10:12:52,270 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean named CustomerWS in deployment unit deployment "webproject.war" are as follows:
java:global/webproject/CustomerWS!com.example.ejbrest.CustomerWS
java:app/webproject/CustomerWS!com.example.ejbrest.CustomerWS
java:module/CustomerWS!com.example.ejbrest.CustomerWS
java:global/webproject/CustomerWS
java:app/webproject/CustomerWS
java:module/CustomerWS
10:12:52,514 INFO [org.jboss.weld.deployer] (MSC service thread 1-3) JBAS016005: Starting Services for CDI deployment: webproject.war
10:12:52,598 INFO [org.jboss.weld.Version] (MSC service thread 1-3) WELD-000900 1.1.16 (redhat)
10:12:52,657 INFO [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016008: Starting weld service for deployment webproject.war
10:12:52,658 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 48) JBAS011402: Starting Persistence Unit Service 'webproject.war#tutorial'
10:12:52,879 INFO [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 48) HCANN000001: Hibernate Commons Annotations {4.0.1.Final-redhat-2}
10:12:52,897 INFO [org.hibernate.Version] (ServerService Thread Pool -- 48) HHH000412: Hibernate Core {4.2.7.SP1-redhat-3}
10:12:52,900 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 48) HHH000206: hibernate.properties not found
10:12:52,912 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 48) HHH000021: Bytecode provider name : javassist
10:12:52,937 INFO [org.hibernate.ejb.Ejb3Configuration] (ServerService Thread Pool -- 48) HHH000204: Processing PersistenceUnitInfo [
name: tutorial
...]
10:12:53,042 INFO [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (ServerService Thread Pool -- 48) HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
10:12:53,377 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 48) HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
10:12:53,496 INFO [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (ServerService Thread Pool -- 48) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory
10:12:53,502 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ServerService Thread Pool -- 48) HHH000397: Using ASTQueryTranslatorFactory
10:12:53,563 INFO [org.hibernate.validator.internal.util.Version] (ServerService Thread Pool -- 48) HV000001: Hibernate Validator 4.3.1.Final-redhat-1
10:12:54,400 INFO [org.jboss.web] (ServerService Thread Pool -- 49) JBAS018210: Register web context: /webproject
10:12:54,476 INFO [org.jboss.resteasy.cdi.CdiInjectorFactory] (ServerService Thread Pool -- 49) Found BeanManager at java:comp/BeanManager
10:12:55,057 INFO [org.jboss.as.server] (HttpManagementService-threads - 2) JBAS018559: Deployed "webproject.war" (runtime-name : "webproject.war")
10:13:08,430 INFO [org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher] (http-localhost/127.0.0.1:8080-1) Deploying javax.ws.rs.core.Application: class com.example.ejbrest.RestApplication$Proxy$_$$_WeldClientProxy
10:13:08,441 INFO [org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher] (http-localhost/127.0.0.1:8080-1) Adding singleton resource com.example.ejbrest.CustomerWS from Application javax.ws.rs.core.Application
10:13:08,649 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/webproject].[Resteasy]] (http-localhost/127.0.0.1:8080-1) JBWEB000236: Servlet.service() for servlet Resteasy threw exception: org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
at org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:365) [resteasy-jaxrs-2.3.7.Final-redhat-2.jar:2.3.7.Final-redhat-2]
at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:233) [resteasy-jaxrs-2.3.7.Final-redhat-2.jar:2.3.7.Final-redhat-2]
at org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:209) [resteasy-jaxrs-2.3.7.Final-redhat-2.jar:2.3.7.Final-redhat-2]
at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:557) [resteasy-jaxrs-2.3.7.Final-redhat-2.jar:2.3.7.Final-redhat-2]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524) [resteasy-jaxrs-2.3.7.Final-redhat-2.jar:2.3.7.Final-redhat-2]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126) [resteasy-jaxrs-2.3.7.Final-redhat-2.jar:2.3.7.Final-redhat-2]
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.7.Final-redhat-2.jar:2.3.7.Final-redhat-2]
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.3.7.Final-redhat-2.jar:2.3.7.Final-redhat-2]
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.3.7.Final-redhat-2.jar:2.3.7.Final-redhat-2]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
Caused by: java.lang.NullPointerException
at com.example.ejbrest.CustomerWS.getCustomer(CustomerWS.java:29) [classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_51]
at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_51]
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167) [resteasy-jaxrs-2.3.7.Final-redhat-2.jar:2.3.7.Final-redhat-2]
at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:269) [resteasy-jaxrs-2.3.7.Final-redhat-2.jar:2.3.7.Final-redhat-2]
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:227) [resteasy-jaxrs-2.3.7.Final-redhat-2.jar:2.3.7.Final-redhat-2]
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:216) [resteasy-jaxrs-2.3.7.Final-redhat-2.jar:2.3.7.Final-redhat-2]
at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542) [resteasy-jaxrs-2.3.7.Final-redhat-2.jar:2.3.7.Final-redhat-2]
... 21 more
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<display-name>RestEasy sample Web Application</display-name>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.example.ejbrest.RestApplication</param-value>
</init-param>
<!-- <load-on-startup>1</load-on-startup>-->
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/customers/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ControllerServlet</servlet-name>
<servlet-class>com.example.ejbrest.ControllerServlet</servlet-class>
<!-- <load-on-startup>0</load-on-startup>-->
</servlet>
<servlet-mapping>
<servlet-name>ControllerServlet</servlet-name>
<!-- <url-pattern>/tutorial/*</url-pattern>-->
<url-pattern>/application/*</url-pattern>
</servlet-mapping>
</web-app>
beans.xml
<!-- Marker file indicating CDI should be enabled -->
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd">
</beans>
<!-- http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"
http://java.sun.com/xml/ns/javaee -->
persistence.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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"
version="1.0">
<persistence-unit name="tutorial">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/tutorial</jta-data-source>
<properties>
<property name="hibernate.archive.autodetection" value="class" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit>
</persistence>
Java classes:
package com.example.ejbrest;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import org.jboss.resteasy.plugins.providers.html.View;
#Path("/customers")
#Stateless
#LocalBean
public class CustomerWS {
#EJB
private CustomerDAO customersDao;
#GET
#Path("/first/{id}")
public Customer getCustomer(#PathParam("id") int id) {
customersDao.printOut();
return customersDao.getCustomer(id);
}
#GET
#Path("/second/{id}")
public View getCustomer() {
System.out.println("Got in here! ! ! ");
View v = new View("/application");
//v.render(arg0, arg1);
//System.out.println("path " + v.getPath());
return v;
}
#POST
public void addCustomers(List<Customer> customers) {
customersDao.addCustomers(customers);
}
}
CustomerDAO:
package com.example.ejbrest;
import java.util.List;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
#Stateless
#LocalBean
public class CustomerDAO {
#PersistenceContext
private EntityManager em;
public Customer getCustomer(int id) {
return em.find(Customer.class, id);
}
public void printOut(){
System.out.println("AGGGGGH!");
}
#TransactionAttribute(TransactionAttributeType.REQUIRED)
public void addCustomers(List<Customer> customers) {
for (Customer customer : customers) {
em.persist(customer);
}
}
}
CustomerWS
package com.example.ejbrest;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import org.jboss.resteasy.plugins.providers.html.View;
#Path("/customers")
#Stateless
#LocalBean
public class CustomerWS {
#EJB
private CustomerDAO customersDao;
#GET
#Path("/first/{id}")
public Customer getCustomer(#PathParam("id") int id) {
customersDao.printOut();
return customersDao.getCustomer(id);
}
#GET
#Path("/second/{id}")
public View getCustomer() {
System.out.println("Got in here! ! ! ");
View v = new View("/application");
//v.render(arg0, arg1);
//System.out.println("path " + v.getPath());
return v;
}
#POST
public void addCustomers(List<Customer> customers) {
customersDao.addCustomers(customers);
}
}
Directory Structure
First of all several notes for your code:
you don't need beans.xml file in the project because use don't use CDI annotations but only EJB3 annotations
#LocalBean annotation is not required, #Stateless is enough to define local bean, detailed explanation could be found in EJB 3.1 #LocalBean vs no annotation
definition of listener,servlet and servlet-mapping elements for resteasy in web.xml is not required, JBoss/RestEasy(JAX-RS implementation library) adds this definitions automatically for you. Empty web.xml with root web-app element is sufficient.
Now to your problem:
Attribute CustomerWS.customersDao is not injected by EJB container because CustomerWS is not deployed as EJB bean by container, but only as JAX-RS resource by RestEasy. It's known drawback of RestEasy 2.x used in JBoss EAP 6.x, that restfull resource could not become EJB bean out of the box: https://docs.jboss.org/resteasy/docs/2.3.6.Final/userguide/html/RESTEasy_EJB_Integration.html
All you need to do is define special context parameter in web.xml with comma separated jndi names of EJB beans which are also restfull resources managed by RestEasy. So in your case, you need to insert into web.xml following snippet:
<context-param>
<param-name>resteasy.jndi.resources</param-name>
<param-value>java:module/CustomerWS</param-value>
</context-param>
And that's all. Now CustomerWS class will be handled as EJB bean with working injections.
I see a few issues, some of them might be red herrings so I figure I'll list them all out.
Don't include all of this resteasy configuration in your web.xml. It's probably confusing the app server if nothing else. You should have a JAX-RS application that looks like this:
#ApplicationPath("/customers")
public class RestApplication extends Application {
// nothing needed ...
}
and that's all that's needed. Remove the resteasy listener and servlet from your config.
You're using a CDI 1.1 beans.xml. EAP 6.2 is CDI 1.0 compliant. Either make the file empty or use a CDI 1.0 tag in your file.
Do you in fact have two different CustomerWS classes? or was that a copy and paste issue?

JBoss AS 7 simple hello world application

I am trying to get a simple JMS "Hello world" application to run. I would like to try it out on JBoss Application Server 7 but i am not able to run it. Jboss as HornetQ embedden in it and i started it using the following command:
standalone.bat --server-config=standalone-preview.xml
I think the problem is most likely to the way i have configured the queue within JBoss. Here are the steps i did.
Configure queue
Quene name: testQueue
JNDI name: queue/test
The queue configuration has an option for "Selector". Can this be left blank and if not, what goes in this field?
Code
Here is the code i am using as the Sender. I am not worried of the receiver for now as i just want to start sending a message first.
package jms.ex3;
import javax.naming.InitialContext;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.QueueSender;
import javax.jms.DeliveryMode;
import javax.jms.QueueSession;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
public class Sender
{
public static void main(String[] args) throws Exception
{
// get the initial context
InitialContext ctx = new InitialContext();
// lookup the queue object
Queue queue = (Queue) ctx.lookup("queue/test");
// lookup the queue connection factory
QueueConnectionFactory connFactory = (QueueConnectionFactory) ctx.
lookup("queue/connectionFactory");
// create a queue connection
QueueConnection queueConn = connFactory.createQueueConnection();
// create a queue session
QueueSession queueSession = queueConn.createQueueSession(false,
Session.DUPS_OK_ACKNOWLEDGE);
// create a queue sender
QueueSender queueSender = queueSession.createSender(queue);
queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
// create a simple message to say "Hello"
TextMessage message = queueSession.createTextMessage("Hello");
// send the message
queueSender.send(message);
// print what we did
System.out.println("sent: " + message.getText());
// close the queue connection
queueConn.close();
}
}
When i run the above class i get the following error:
java -classpath C:\Users\702723344\Downloads\glassfish-3.1.1\glassfish3\glassfish\lib\javaee.jar;. jms.ex3.Sender
Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at jms.ex3.Sender.main(Sender.java:22)
How exactly does the above class know that the Provider(JBoss) is running on the localhost machine? Dont i need to specify an IP address somewhere? Any ideas?
Edit
Most of the documentation seem to refer to JBoss AS 6. I have updated the code snippet to include the following:
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory" );
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
env.put(Context.PROVIDER_URL, "jnp://localhost:1199");
ctx = new InitialContext(env);
I am now getting classNotFound exception. I think it needs an additional jar file to be added to the classpath but which one???
java -classpath C:\Users\702723344\Downloads\glassfish-3.1.1\glassfish3\glassfish\lib\javaee.jar;. jms.ex3.Sender
Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at jms.ex3.Sender.main(Sender.java:27)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
... 5 more
Answering on ClassNotFoundException.
org.jnp.interfaces.NamingContextFactory can be located in jboss-as-7.0.0.Final\modules\org\jboss\as\naming\main\jboss-as-naming-7.0.0.Final.jar.
Also noticed glassfish\lib\javaee.jar in your classpath and wanted to give an advice on how to easily include in classpath multiple jars from jboss/client folder.
But oups - there's no such folder in JBoss AS 7.0.
It appears that JBoss AS 7.0 doesn't support remote clients at all (at least for EJB).
Take a look at this thread: http://community.jboss.org/message/613171. It's very interesting.
There is a chance you'll further get some ClassCastExceptions with using glassfish\lib\javaee.jar.
I do not agree with the last answer from Vadzim
I know I am answering a very old question but this info miss-led me for a day, It was the first time I was trying to setup JMS remote queue on JBOSS 7 , hence had to answer, which got me working.
It appears that JBoss AS 7.0 doesn't support remote clients at all (at least for EJB)...??
It is possible to call remote queue. below are the following steps ..
Make sure to add the queues in standalone.xml or (full.xml) , in below I have got myRemoteStatusQueue set up , if you observe, exported option is must, so that the jboss knows it will consumed by the external jms client
<jms-destinations>
<jms-queue name="testQueue">
<entry name="queue/test"/>
<entry name="java:jboss/exported/jms/queue/test"/>
</jms-queue>
<jms-queue name="ddsStatusQueue">
<entry name="java:jboss/exported/jms/queue/myRemoteStatusQueue"/><!--Exported key necessary -->
</jms-queue>
<jms-topic name="testTopic">
<entry name="topic/test"/>
<entry name="java:jboss/exported/jms/topic/test"/>
</jms-topic>
</jms-destinations>
Make sure to add a role to an application user : such as remote-role , after adding the role make sure to include them in the Jboss's standalone.xml.
<jms-destinations>
<jms-queue name="testQueue">
<entry name="queue/test"/>
<entry name="java:jboss/exported/jms/queue/test"/>
</jms-queue>
<jms-queue name="ddsStatusQueue">
<entry name="java:jboss/exported/jms/queue/myRemoteStatusQueue"/> <!--Exported key necessary -->
</jms-queue>
<jms-topic name="testTopic">
<entry name="topic/test"/>
<entry name="java:jboss/exported/jms/topic/test"/>
</jms-topic>
</jms-destinations>
<security-settings>
<security-setting match="#">
<permission type="send" roles="remote-role guest"/>
<permission type="consume" roles="remote-role guest"/>
<permission type="createNonDurableQueue" roles="guest"/>
<permission type="deleteNonDurableQueue" roles="guest"/>
</security-setting>
</security-settings>
Make sure to use below code ,you can see I have used remote:/ as part of URL for remoting
private static final String DEFAULT_MESSAGE = " Dummy message local Client Message At"+new Date();
private static final String DEFAULT_CONNECTION_FACTORY = "/jms/ConnectionFactory";
private static final String DEFAULT_DESTINATION = "jms/queue/myRemoteStatusQueue";
private static final String DEFAULT_MESSAGE_COUNT = "1";
private static final String DEFAULT_USERNAME = "abhijith";
private static final String DEFAULT_PASSWORD = "password";
private static final String INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
private static final String PROVIDER_URL = "remote://localhost:4447";
Make sure to use the right jars, for the Above example , I used hornetq-core-2.2.14.Final.jar and the usage of correct JBOSS client jar , go to the client folder of the bin directory of JBOSS, you will have readme.txt, there you will have reference for Maven version to use, if you are using as a standalone application then you can reference the given jar in the directory.
Deploy your app on JBOSS , During the start up you should see the configured Queue without any error. You can see for example in my server startup log, java:jboss/exported/jms/queue/myRemoteStatusQueue. If the above entry has come up with out error, now you are good to go ...
16:24:46,527 INFO [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011601: Bound messaging object to jndi name java:/queue/test
16:24:46,533 INFO [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/queue/test
16:24:46,545 INFO [org.jboss.as.messaging] (MSC service thread 1-8) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory
16:24:46,548 INFO [org.jboss.as.messaging] (MSC service thread 1-8) JBAS011601: Bound messaging object to jndi name java:/RemoteConnectionFactory
16:24:46,551 INFO [org.jboss.as.messaging] (MSC service thread 1-3) JBAS011601: Bound messaging object to jndi name java:/ConnectionFactory
16:24:46,552 INFO [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-4) trying to deploy queue jms.topic.testTopic
16:24:46,569 INFO [org.jboss.as.deployment.connector] (MSC service thread 1-6) JBAS010406: Registered connection factory java:/JmsXA
16:24:46,607 INFO [org.hornetq.ra.HornetQResourceAdapter] (MSC service thread 1-6) HornetQ resource adaptor started
16:24:46,609 INFO [org.jboss.as.connector.services.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-6) IJ020002: Deployed: file://RaActivatorhornetq-ra
16:24:46,612 INFO [org.jboss.as.deployment.connector] (MSC service thread 1-6) JBAS010401: Bound JCA ConnectionFactory [java:/JmsXA]
16:24:46,638 INFO [org.jboss.as.messaging] (MSC service thread 1-4) JBAS011601: Bound messaging object to jndi name java:/topic/test
16:24:46,641 INFO [org.jboss.as.messaging] (MSC service thread 1-4) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/topic/test
16:24:46,642 INFO [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-7) trying to deploy queue jms.queue.myRemoteStatusQueue
16:24:46,645 INFO [org.jboss.as.messaging] (MSC service thread 1-7) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/queue/myRemoteStatusQueue
16:24:47,211 INFO [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-1) JBoss Web Services - Stack CXF Server 4.0.2.GA
(-1 / -1) (org/jboss/as/network/ManagedBinding$Factory/org/jboss/as/network/ManagedBinding$Factory)
Happy coding,
Regards,
Abhijith

Orbeon deployment on JBoss AS 7

We are trying to deploy Orbeon Forms 3.9 on JBoss AS 7 and getting the following errors:
15:34:36,621 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/adg-xforms]] (MSC service thread 1-2) Exception sending context initialized event to listener instance of class org.orbeon.oxf.webapp.OrbeonServletContextListenerDelegate: org.orbeon.oxf.common.OXFException: no implementation of regexp was found.
at org.orbeon.oxf.webapp.OrbeonServletContextListenerDelegate.contextInitialized(OrbeonServletContextListenerDelegate.java:43) [orbeon.jar:]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3368) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3821) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_25]
at java.lang.Thread.run(Thread.java:662) [:1.6.0_25]
15:34:36,670 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-2) Error listenerStart
15:34:36,670 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-2) Context [/adg-xforms] startup failed due to previous errors
15:34:36,682 ERROR [stderr] (MSC service thread 1-2) Starting Orbeon Forms 3.8.0.201005141856 CE
15:34:36,693 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/adg-xforms]] (MSC service thread 1-2) Exception sending context destroyed event to listener instance of class org.orbeon.oxf.webapp.OrbeonServletContextListenerDelegate: org.orbeon.oxf.common.OXFException: Could not initialize class com.sun.msv.datatype.xsd.AnyURIType
at org.orbeon.oxf.webapp.OrbeonServletContextListenerDelegate.contextDestroyed(OrbeonServletContextListenerDelegate.java:52) [orbeon.jar:]
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3465) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:3970) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3888) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_25]
at java.lang.Thread.run(Thread.java:662) [:1.6.0_25]
Do you support JBoss AS 7 or anyone tried deploying orbeon on this app server.
I just added xsdlib-20030225.jar to lib directory (It's just one I had to hand ;-O). This is a HACK, I don't know what it affects and don't know if there are any side effects...but it works so far ;-)
This was tested with JBoss AS 7.1.1.Final "Brontes".
Follow the following steps:
for Orbeon Forms PE
unzip orbeon.war
place your license.xml file under WEB-INF/resources/config/license.xml
re-zip orbeon.war
start a standalone server with bin/standalone.sh
drop orbeon.war into the JBoss standalone/deployments folder
(source)
The joy of class loaders. Some code in MSV tries to load com.sun.msv.datatype.xsd.AnyURIType, which shouldn't fail as this class is in WEB-INF/lib/msv-xsdlib-20070407_orbeon_20100309.jar. I suspect that because of the way the class loaders is structured in JBoss, Orbeon ends up using a version of MSV coming from JBoss which is unable to load AnyURIType which is a jar that only comes with Orbeon. But I might be wrong on this.
This type of application-server specific question can be rather time consuming to resolve. So I would recommend you to use Tomcat or to get Orbeon to resolve this for you under a Development Support subscription.