How make Seam3 Solder with CDI work in WebSphere 7? - jsf-2

I want to use Seam Solder and Seam Faces 3 in WebSphere 7 with JSF 2.0 (RI is Mojarra 2.0.4) and CDI. I Included all required dependencies (Weld 1.1, JBoss Logging), but the server doesn't start saying:
Failed to locate BeanManager using any of these providers:
org.jboss.seam.solder.beanManager.DefaultJndiBeanManagerProvider(11),
org.jboss.seam.solder.beanManager.ServletContainerJndiBeanManagerProvider(10)`
I followed the Seam configuration instruction for pre-servlet 3.0 environment
It seemed to me a resource (the BeanMananger) is missing and I tried to set up the BeanManager as a jndi resource in Websphere, following this Weld instruction for Servlet Container, which also did not work.
The source code causing the exception during server startup, tries to lookup the bean manager like this:
class ServletContainerJndiBeanManagerProvider extends AbstractJndiBeanManagerProvider {
#Override
protected String getLocation() {
return "java:comp/env/BeanManager";
}
public int getPrecedence(){
return 10;
}
Did anyone get Seam 3 and CDI 1.0 (resp. Weld 1.1) running on Websphere 7 so far? What am I missing here?
P.S.: JSF 2.0 is running fine.

Here's a link to a thread on the seam-dev mailist about trying to get Seam 3 to work in Websphere 8. Maybe some tidbits in there will be helpful for you.
http://seam-framework.2283336.n4.nabble.com/seam-booking-from-CR3-preliminary-testing-results-on-WebSphere-v8-beta-td3395111.html

Related

Simple Dropwizard 0.7.1 App Failing over Optional QueryParam w/ Java 8

I decided to return to Dropwizard after a very long affair with Spring. I quickly got the absolute barebones REST service built, and it runs without any problems.
Using Dropwizard 0.7.1 and Java 1.8, only POM entries are the dropwizard-core dependency and the maven compiler plugin to enforce Java 1.8, as recommended by the Dropwizard user manual
However, as soon as I try to add an Optional QueryParam to the basic controller, the application fails to start with the following error (cut for brevity):
INFO [2015-01-03 17:44:58,059] io.dropwizard.jersey.DropwizardResourceConfig: The following paths were found for the configured resources:
GET / (edge.dw.sample.controllers.IndexController)
ERROR [2015-01-03 17:44:58,158] com.sun.jersey.spi.inject.Errors: The following errors and warnings have been detected with resource and/or provider classes:
SEVERE: Missing dependency for method public java.lang.String edge.dw.sample.controllers.IndexController.index(java.util.Optional) at parameter at index 0
Exception in thread "main" javax.servlet.ServletException: com.sun.jersey.spi.container.servlet.ServletContainer-6c2ed0cd#330103b7==com.sun.jersey.spi.container.servlet.ServletContainer,1,false
The code for the controller is as follows:
#Path("/")
public class IndexController {
#GET
#Timed
public String index(#QueryParam("name") Optional<String> name) {
String saying = "Hi";
if(name != null && name.isPresent()) {
saying += " " + name.get();
}
return saying;
}
}
If I remove Optional from the mix, the application runs just fine. I replace the Optional-specific code with null checks and it works perfectly.
Am I missing something fundamental here? Both Google Guava Optional and java.util.Optional fail with the same error. (And yes, I did narrow it down to the Optional object)
A quick Google/SO search yielded nothing useful, but feel free to point me to a resource I may have missed
Thanks in advance!
Moments after posting this, I found that the issue was my use of Java 1.8. If using Java 1.8, I have to add the Java8Bundle to my app:
POM Entry:
<dependency>
<groupId>io.dropwizard.modules</groupId>
<artifactId>dropwizard-java8</artifactId>
<version>0.7.0-1</version>
</dependency>
And code in the Application class:
#Override
public void initialize(Bootstrap<SampleConfiguration> bootstrap) {
bootstrap.addBundle(new Java8Bundle());
}
See: https://github.com/dropwizard/dropwizard-java8
This enables both Google Guava Optional and java.util.Optional to work just fine.
If I revert to Java 1.7 and use the Google Guava Optional, it works just fine as well and I don't have to include the Java8Bundle. I'll opt for the Java8Bundle for now, though, as using Java8 features is lucrative for me :)
Cheers!

Can't find omnifaces.GenericEnumConverter after migrating to Tomcat 7 and MyFaces 2.2

For some reason after upgrading from Tomcat 6 -> Tomcat 7 and from MyFaces 2.0 -> MyFaces 2.2 (Using OmniFaces 1.7)
I began to get the following error
javax.faces.FacesException: Could not find any registered
converter-class by converterId : omnifaces.GenericEnumConverter
at org.apache.myfaces.application.ApplicationImpl.createConverter(ApplicationImpl.java:1533)
at org.omnifaces.application.OmniApplication.createConverter(OmniApplication.java:77)
at org.apache.myfaces.view.facelets.tag.jsf.ValueHolderRule$LiteralConverterMetadata.applyMetadata(ValueHolderRule.java:50)
at org.apache.myfaces.view.facelets.tag.MetadataImpl.applyMetadata(MetadataImpl.java:45)
at javax.faces.view.facelets.MetaTagHandler.setAttributes(MetaTagHandler.java:63)
at javax.faces.view.facelets.DelegatingMetaTagHandler.setAttributes(DelegatingMetaTagHandler.java:90)
at org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:290)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:50)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:46)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:55)
The only way that I can use the omnifaces.GenericEnumConverter right now is by adding it manually to the faces-config.xml , like this:
<converter>
<converter-id>omnifaces.GenericEnumConverter</converter-id>
<converter-class>org.omnifaces.converter.GenericEnumConverter</converter-class>
</converter>
Any ideas why? and how can I resolve it?
Thanks.
This will happen if you have
<faces-config ... metadata-complete="true">
in your webapp's /WEB-INF/faces-config.xml. This way JSF won't scan JARs for additional JSF artifacts such as #FacesConverter and so on.
Jsut remove the whole metadata-complete attribute, it defaults to false already.
Unrelated to the concrete problem, MyFaces 2.2 has internally already fixed the problem for which the OmniFaces GenericEnumConverter was been introduced as the solution. You can actually safely remove it from your code.

java.lang.LinkageError: "javax/activation/DataHandler"

So, I recently upgraded our Grails app from version 1.3.7 to 2.3.4. I'm now getting an exception in a SOAP handler that attempts to extract the message content and log it to the DB. This worked in 1.3.7, but I'm assuming that some new dependency or something has messed with the classpath.
The code looks like this:
private String extractSOAPMessage(SOAPMessageContext smc) {
Source source = smc.getMessage().getSOAPPart().getContent()
TransformerFactory factory = TransformerFactory.newInstance()
Transformer transformer = factory.newTransformer()
transformer.setOutputProperty( OutputKeys.METHOD, "xml" )
java.io.StringWriter writer = new StringWriter()
Result result = new StreamResult( writer )
transformer.transform( source, result )
return writer.toString()
}
The exception I'm seeing is:
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "javax/activation/DataHandler"
It happens on this line:
Source source = smc.getMessage().getSOAPPart().getContent()
It looks like the culprit is the getSOAPart() call.
Note that I am using the 1.1.1 version of the cxf plugin for Grails. Any help on this would be greatly appreciated. I've found several similar issues with solutions, but none of them have been for the "javax/activation/DataHandler", so I am not sure what's going on here.
I suspect something has a transitive dependency on the activation library which you need to exclude - try running a dependency-report. Since Java 6 that JAR has been un-necessary as it's built in to the core Java class library, but many things still have dependencies on it so they can work on Java 5 (or date back to when Java 5 was still in widespread use).

Grails 2.3.0 Restful Service Runtime Exception

I´m currently running Grails 2.3.0 and Java jdk1.7.0_40 on a Windows 7 machine, no IDE. I wanted to see how the new Rest functionality looks like. So I created the domain class as follows:
package fergara
import grails.rest.*
#Resource(uri='/Cars', formats=['json', 'xml'])
class Car {
String model
static constraints = {
}
}
The error I got when open the url:
URI
/FergaraTest/Cars/1 Class
org.codehaus.groovy.runtime.typehandling.GroovyCastException
Message
Cannot cast object 'fergara.CarController#12c43f7' with class 'fergara.CarController' to class 'org.codehaus.groovy.grails.plugins.web.api.CommonWebApi'
I feel that the Oracle´s Java SDK is the problem. To make the app run I have to pass "no-reloading" to the grails run-app command, otherwise I get an error saying that it could not start the VM and cannot open the springloaded-core-1.1.3.jar.
A have the Grails 2.3.0 installed on an Ubuntu 13.04 with OpenJDK6 and it is working good.
Hope someone can shed a light on this. Thank you.

Upgrade from richfaces 3.3 to 4.2 and primefaces from 1.1 to 2.2.1

I try to upgrade from richfaces 3.3 to 4.2 and primefaces from 1.1 to 2.2.1
I have these jars:
jsf-api-2.0.3.jar (was 1.2 before)
jsf-facelets-1.1.9.jar
jsf-impl-2.0.3.jar (was 1.2 before)
richfaces-components-api-4.2.0.Final
richfaces-components-ui-4.2.0.Final.jar
richfaces-core-api-4.2.0.Final.jar
richfaces-core-impl-4.2.0.Final.jar
myfaces-orchestra-core-1.4.jar
myfaces-orchestra-core20-1.4.jar
primefaces-2.2.1.jar
guava-11.0.2.jar
slf4j-api-1.6.1.jar
quartz-1.6.0.jar
servlet-api.jar (85.287 Bytes) (28.01.2008)
el-impl-1.0.jar
el-messages.jar
facelets-taglib-jsf12-spring-3-0.4.jar
and some Spring 3.1.0 jars
but I get:
Error Loading Library: jar:file:/C:/Users/XXX/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/XXX/WEB-INF/lib/richfaces-components-ui-4.2.0.Final.jar!/META-INF/rich.taglib.xml
java.io.IOException: Error parsing [jar:file:/C:/Users/XXX/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/XXX/WEB-INF/lib/richfaces-components-ui-4.2.0.Final.jar!/META-INF/rich.taglib.xml]:
when i remove jsf-facelets-1.1.9.jar, i get
com.sun.faces.config.ConfigurationException:
Source Document: jndi:/localhost/XXX/WEB-INF/faces-config.xml
Cause: Unable to find class 'com.sun.facelets.FaceletViewHandler'
<application>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>en</supported-locale>
</locale-config>
<message-bundle>messages</message-bundle>
</application>
after removing this tag I get
Schwerwiegend: Servlet.service() for servlet Faces Servlet threw exception
java.lang.IllegalArgumentException: Orchestra was unable to create an instance of bean with name 'AccessScopeManager'. Ensure that JSF variable resolution uses your dependency injection (DI) framework (eg Spring's DelegatingVariableResolver is in your faces-config.xml file) and the standard Orchestra configuration beans are defined (eg by using <import resource="classpath*:/META-INF/spring-orchestra-init.xml" />).
... I think I need some help
thanks
As you have upgraded to JSF 2 and JSF 2 comes with facelets built in so it is unlikely that you want to use the old facelets jar jsf-facelets-1.1.9.jar on your classpath.
BalusC (stackoverflow's JSF expert) has this written this excellent guide
Migrating from JSF 1.2 to JSF 2.0 on how to upgrade, it also covers facelets upgrading.
I also you are using facelets-taglib-jsf12-spring-3-0.4.jar
According to the spring-security-facelets-taglib you will need to use
facelets-taglib-jsf20-spring-3
I hope this helps
Take a look at these reports:
API changes report for the PrimeFaces library:
API changes report for the RichFaces library:

Resources