My SFSB Seam component is bound to JNDI on deployment, as evidenced by this log message:
Component: example, scope: CONVERSATION, type: STATEFUL_SESSION_BEAN,
class:com.purecharger.action.ExampleAction, JNDI: purecharger/ExampleAction/local
My interface:
#Local
public interface Example {
public List<String> getExample();
public void destroy();
}
and my implementation:
#Stateful
#Scope(ScopeType.CONVERSATION)
#Name("example")
#Restrict("#{identity.loggedIn}")
public class ExampleAction implements Example, Serializable {
....
}
However, when I access the voting component in an xhtml page like, I get the following error:
javax.el.ELException: /home.xhtml: Could not instantiate Seam component: example
....
Caused by: javax.naming.NameNotFoundException: ExampleAction not bound
If Seam was smart enough to install my component using the JNDI pattern in components.xml (purecharger/#{ejbName}/local), why does it not also apply the pattern when looking up components?
Thank you.
UPDATE:
Looking at the JNDIView in JBoss, the name purecharger/ExampleAction/local is not bound anywhere. So I guess my question now becomes, why is Seam not adding this SFSB to JNDI?
Why is Seam not adding this SFSB to JNDI ?
Well,
As shown in your question, i think you have a ear application, because of its JNDI global address
purecharger/ExampleAction/local
which is mapped according to
<EAR_APPLICATION>/<STATEFUL_BEAN>/local
When you deploy a single EJB module, its JNDI global address in JBoss looks like
<STATEFUL_BEAN>/local
Bacause you have a ear application, each EJB module should be declared in application.xml (The file that describes your ear) as follows
So your ear app looks like
pureCharger.ear
META-INF
application.xml
pureCharger-ejb.jar
pureCharger-war.war
jboss-seam.jar
lib
// libraries shared by your modules goes here
And your application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application version="5" xmlns="http://java.sun.com/xml/ns/javaee" 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/application_5.xsd">
<display-name>pureCharger</display-name>
<module>
<ejb>pureCharger-ejb.jar</ejb>
</module>
<module>
<ejb>jboss-seam.jar</ejb>
</module>
<module>
<web>
<web-uri>pureCharger-war.war</web-uri>
<context-root>pureCharger</context-root>
</web>
</module>
</application>
Notice jboss-seam.jar is a EJB module, so it should also be declared in application.xml file
If possible, use Seam-gen to generate your project. It takes care includes all libraries needed by your project and can be opened without restriction in NetBeans, for instance.
regards,
Related
I’m facing a problem when trying do deploy on TomEE (using OWB).
I’m getting the following exception:
javax.enterprise.inject.UnsatisfiedResolutionException: Api type [org.apache.wicket.cdi.AutoConversation] is not found with the qualifiers
Qualifiers: [#javax.enterprise.inject.Default()]
for injection into Field Injection Point, field name : autoConversation, Bean Owner : [null]
at org.apache.webbeans.util.InjectionExceptionUtil.throwUnsatisfiedResolutionException(InjectionExceptionUtil.java:60)
at org.apache.webbeans.container.InjectionResolver.getInjectionPointBean(InjectionResolver.java:250)
at org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:76)
at org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
at org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:372)
at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:358)
at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:342)
at org.apache.wicket.cdi.NonContextual.postConstruct(NonContextual.java:129)
at org.apache.wicket.cdi.NonContextualManager.postConstruct(NonContextualManager.java:65)
at org.apache.wicket.cdi.ConversationPropagator.(ConversationPropagator.java:122)
at org.apache.wicket.cdi.CdiConfiguration.configure(CdiConfiguration.java:188)
…
I’ve been looking for information online, but there seems to be nothing on it. I have the seam-conversation-spi and seam-conversation-owb jars on my classpath, so that’s not a dependency issue (had some of those, but got over them).
I understand from other people that deploying an EAR with wicket-cdi on other application servers is very easy and straightforward. However, I really like TomEE (the whole "based on TomCat" concept), and wouldn't want to have to switch.
I'm at a loss here, does anyone have a clue on what's going on ?
Edit 1:
This is the contents of my application class init method:
public void init() {
super.init();
BeanManager manager = (BeanManager)new InitialContext().lookup(“java:comp/BeanManager”);
new CdiConfiguration(manager).configure(this);
}
There's really nothing more in the class.
Edit 2:
Here's the code of my application.xml file used to create the EAR file I deploy:
<application xmlns="http://java.sun.com/xml/ns/javaee"
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/application_6.xsd"
version="6">
<initialize-in-order>true</initialize-in-order>
<module>
<ejb>integration.jar</ejb>
</module>
<module>
<ejb>application.jar</ejb>
</module>
<module>
<web>
<web-uri>presentation.war</web-uri>
<context-root>app</context-root>
</web>
</module>
</application>
Edit 3:
From what I read in the code of wicket-cdi and openwebbeans, I think it has to be one of these scenarios:
OWB doesn't find the AutoConversation class (i.e. the wicket-cdi JAR) - I bundle the class inside the WAR in the lib directory using Ant's standard task, so that seems strange
OWB doesn't recognize that the wicket-cdi JAR is a beans JAR - That sounds almost impossible, especially since there's a beans.xml and MANIFEST.MF in the JAR under META-INF as request by the cdi spec
Still at a loss, any help would be appreciated.
Edit 4:
Here's the list of JARs I have in the WAR file, in case it helps:
seam-conversation-spi-3.0.0.Final.jar
velocity-1.7-dep.jar
velocity-1.7.jar
wicket-auth-roles-6.15.0.jar
wicket-bean-validation-6.15.0.jar
wicket-bootstrap-0.17.jar
wicket-cdi-6.15.0.jar
wicket-core-6.15.0.jar
wicket-datetime-6.15.0.jar
wicket-devutils-6.15.0.jar
wicket-extensions-6.15.0.jar
wicket-guice-6.15.0.jar
wicket-ioc-6.15.0.jar
wicket-jmx-6.15.0.jar
wicket-request-6.15.0.jar
wicket-spring-6.15.0.jar
wicket-util-6.15.0.jar
wicket-velocity-6.15.0.jar
Wicket expects AutoConversion bean to inject into ConversationPropagator.
See the fragment of the source of org.apache.wicket.cdi.ConversationPropagator:
#Inject
Conversation conversation_;
#Inject
AutoConversation autoConversation;
Solutions:
Add a bean of type org.apache.wicket.cdi.AutoConversation to your bean definitions.
Disable ConversationPropagator
See your modified code, how to disable ConversationPropagator
new CdiConfiguration(manager).setPropagation(ConversationPropagation.NONE).configure(this);
We have a webservice which is included in an ejb-jar within an ear. That jar is then deployed to a JBoss 7.2.0.Final instance.
According to this JBoss documentation using webservice annotations on the session bean should be sufficient.
Thus the webservice looks like this:
#WebService(name = "TestWS", targetNamespace="http://test.com/ws")
#WebContext(contextRoot="/test-ws", urlPattern="/*", transportGuarantee="NONE", secureWSDLAccess=false)
#Stateless
public class TestWS
{
#WebMethod
public String sayHello()
{
return "hello";
}
}
When the ear is deployed exploded everything works fine. The problem is, when deploying the packaged ear (.ear-file) the service doesn't seem to be available.
Management console displays this information in both cases:
Context: test-ws
Type: JAXWS_EJB3
WSDL Url: http://localhost:8080/test-ws?wsdl
During startup the following is logged in both cases:
[org.jboss.ws.cxf.metadata] (MSC service thread 1-4) JBWS024061: Adding service
endpoint metadata: id=TestWS
address=http://localhost:8080/test-ws
implementor=com.test.TestWS
serviceName={http://test.com/ws}TestWSService
portName={http://test.com/ws}TestWSPort
annotationWsdlLocation=null
wsdlLocationOverride=null
mtomEnabled=false
...
[org.apache.cxf.endpoint.ServerImpl] (MSC service thread 1-9) Setting the server's publish address to be http://localhost:8080/test-ws
When the ear is exploded opening http://localhost:8080/test-ws?wsdl retrieves the wsdl, when the ear is packaged, I get the following result:
JBWEB000065: HTTP Status 404 - /test-ws
JBWEB000309: type JBWEB000067: Status report
JBWEB000068: message /test-ws
JBWEB000069: description JBWEB000124: The requested resource is not available.
Any ideas what might be missing?
I too faced this in many projects. Any one of the below ways might work :)
1.) Package a WAR within the EAR and have web.xml which will give a kick-start to your webservices
2.) Try to load the jar in META-INF/application.xml which will perfectly include your JAR file.
The application.xml will look like this
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" 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/application_5.xsd" version="5">
<display-name>project-name</display-name>
<module>
<java>your_jar_file_name</java>
</module>
</application>
I have created a EJB, created a jar of it( containing required ejb-jar.xml and weblogic-ejb-jar.xml files).
when i add this jar to weblogic server 12c, using admin console, i get following issue-
Issues were encountered while parsing this deployment to determine module type. Assuming this is a library deployment.
Due to this my ejb is not shown in jndi tree view. So I am not able to do my jndi lookup. Please rectify my error.
ejb-jar.xml-
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar id="ejb-jar_ID">
<display-name>ProductManager</display-name>
<enterprise-beans>
<session>
<ejb-name>Product</ejb-name>
<home>rohit.ProductHome</home>
<remote>rohit.ProductRemote</remote>
<ejb-class>rohit.ProductBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<ejb-client-jar>ProductManagerClient.jar</ejb-client-jar>
</ejb-jar>
weblogic-ejb-jar.xml-
<?xml version=“1.0? encoding=“UTF-8??>
<weblogic-ejb-jar
xmlns=“http://www.bea.com/ns/weblogic/90? xmlns:j2ee=“http://java.sun.com/xml/ns/j2ee” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic-ejb-jar.xsd”>
<welogic-enterprise-bean>
<ejb-name>Product</ejb-name>
<jndi-name>Product</jndi-name>
<stateless-session-descriptor></stateless-session-descriptor>
</welogic-enterprise-bean>
</weblogic-ejb-jar>
Contrary to what you seem to be thinking, the ejb-jar.xml and weblogic-ejb-jar.xml files are not required. As primary deployment descriptors they are ancient artifacts from 2004.
Your ProductHome class should also be removed if you value your sanity. This is an EJB2 artifact that's completely and utterly unnecessary this time of age.
To get started with EJB, all you need is a POJO with an #Stateless annotation:
#Stateless
public class ProductBean {
// ...
}
Jar this up and deploy it. That's all. You don't have to explicitly name your bean (it will get a name) and you certainly don't have to declare its existence in some XML file.
The ejb-jar.xml is mandatory when deploying an application as a jar file. The correct place to put it is in the META-INF in the jar.
Yes, annotations are definitely nice and easier to maintain. Try this by leaving the ejb-jar.xml minimal.
I always package my applications in EAR with the jars inside. In this case an application.xml file is needed.
It sounds like the container does not recognize the jar as an application. Check the position of the ejb-jar.xml or use EAR packaging.
Oracle recommends that even standalone EJBs be packed as an EAR file. The EJB descriptors should be inside the META-INF of the ejb-module.
See this link for the EAR structure for more details.
http://docs.oracle.com/cd/E24329_01/web.1211/e24368/splitcreate.htm#i1103260
I have a WAR file with the following structure:
The JSF managed bean BusinessObjectTypeListController is located in commons-web-1.0.jar in /WEB-INF/lib and referenced in BusinessObjectTypeListView.xhtml. When I run my web application and I call that view, I get the following error:
javax.servlet.ServletException: /view/common/businessObjectTypeListView.xhtml #34,94 listener="#{businessObjectTypeListController.selectData}": Target Unreachable, identifier 'businessObjectTypeListController' resolved to null
Why isn't the controller class found? It should be in the classpath, is it?
You need to have a JSF 2.0 compliant /META-INF/faces-config.xml file in the commons-web-1.0.jar file in order to get JSF to scan the JAR file for classes with JSF annotations like #ManagedBean and auto-register them.
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
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"
version="2.0">
</faces-config>
JSF does namely not scan every class of every single JAR file in the classpath, that would have been too expensive. Only JARs with the above /META-INF/faces-config.xml file will be scanned.
You should also ensure that you do not have the metadata-complete="true" attribute in the <faces-config> declaration of webapp's own /WEB-INF/faces-config.xml file, otherwise JSF will assume that this faces config is complete and therefore won't auto-scan JAR files for annotations.
If none of those conditions are (or can be) met, then you need to manually register the bean as <managed-bean> in webapp's own /WEB-INF/faces-config.xml instead of relying on annotations.
See also chapter 11.4.2 of JSF 2.0 specification (emphasis mine).
11.4.2 Application Startup Behavior
...
This algorithm provides considerable flexibility for developers that are assembling the components of a JSF-based web
application. For example, an application might include one or more custom UIComponent implementations, along with
associated Renderers, so it can declare them in an application resource named “/WEB-INF/faces-config.xml”
with no need to programmatically register them with Application instance. In addition, the application might choose
to include a component library (packaged as a JAR file) that includes a “META-INF/faces-config.xml” resource.
The existence of this resource causes components, renderers, and other JSF implementation classes that are stored in this
library JAR file to be automatically registered, with no action required by the application.
I have same problem with CDI beans in my case.
I have common.jar project where i placed the CDI beans. (without beans.xml)
and
I have webapp.war that contains common.jar in it`s lib and beans.xml.
when i call a cdi bean from jsf, i get it is not reachable exception:/
project structure is created using maven :
- maven-archetype-quickstart for common.jar
- maven-archetype-webapp for webapp.war
I am using eclipse/juno en deploy to Glassfish 3.1.x.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Resolved:
For EJB and JAR packaging you should place the beans.xml in src/main/resources/META-INF/.
For WAR packaging you should place the beans.xml in src/main/webapp/WEB-INF/.
Remember that only .java files should be put in the src/main/java and src/test/java directories. Resources like .xml files should be in src/main/resources.
from topic:
CDI: beans.xml, where do I put you?
In my opinion the class BusinessObjectTypeListController is founded properly but does not instantiated.
How you create the instance of class on a view? If you use a BeanFactory review the config xml files
I have an EJB3 project to be deployed on JBoss 5.1.0 GA. I have Stateless EJBs being injected into other Stateless beans and Servlets.
I'm using the #EJB annotation without any parameters to inject the EJB beans, (i have a test project just to simulate the injection, which works).
When i try deploying i get the error below.
"Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: Resolution should not happen via injection container"
I have searched but can't seem to find/pinpoint the cause of the error.
Update: 1
Both the EJB jar and WAR are deployed in the same EAR. I'm using the JEE5 archtype, http://code.google.com/p/javaee5-maven-archetype/ to create both the main project and test. The default code generated by the archtype works, and there is no need to specify the JNDI name in the #EJB injection.
Update: 2
The full deployment stacktrace, http://pastebin.com/CknXie13
Here's an oft overlooked gotcha: Make sure that you use the name of the Local Interface and not the implementation when declaring the class type of the EJB in the servlet or web service. So, the mappedName in JBOSS will point to the jndi binding for the implementation while the class type in the declaration will point to the interface. For example:
#EJB(mappedName="Foo/EmployeeManagerBean/local")
EmployeeManagerLocal manager;
Gotcha #2: Make sure that you are compiling with Java 1.6 or higher. This can be tricky in Eclipse. You have to check three places in Project->Properties to make sure: Project Facets, compiler compliance settings, and the build path.
Use the mappedName attribute of #EJB annotation, while injecting into the servlet
The attribute should contain the jndi name of the ejb.
Please check your web.xml version. Version 2.4 or earlier does not support dependency injection.
Here is the sample excerpt of version="2.5"
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 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-app_2_5.xsd">
Are you putting your servlet in .WAR file? Put your servlet in .WAR file and your bean in .JAR file. Create and ear file and then deploy it
Known Issue;
http://community.jboss.org/message/8196#8196
https://jira.jboss.org/browse/JBAS-6332