Spring 4 + hibernate & jpa 2.1 on weblogic 10.3.5 - jpa

Will I be able to run Hibernate with JPA 2.1 on weblogic 10.3.5.
I have specified the below lines in weblogic-application.xml and packaged the jpa 2.1 API jar in the EAR along with other jars.
<wls:prefer-application-packages>
<wls:package-name>javax.persistence</wls:package-name>
</wls:prefer-application-packages>
Some how weblogic recognizes META-INF/persistence.xml and tries to automatically create persistence unit using Eclipse Link during application deployment/startup. This is where the weblogic classloader (parent of application class loader) is trying to load the persistence unit but failing with below exception.
java.lang.IllegalArgumentException: interface javax.persistence.EntityManagerFactory is not visible from class loader
Any help with this is very much appreciated.

Have you enabled JPA 2.1 on your Weblogic Instalation ?
If you refer to :
https://docs.oracle.com/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309
and
https://docs.oracle.com/middleware/1213/wls/EJBAD/using_toplink.htm#EJBAD1309
you will note that:
"Support for JPA 2.1 in WebLogic Server is provided as a patch because JPA 2.1 is part of the Java Platform, Enterprise Edition (Java EE) 7. Therefore, enabling JPA 2.1 support in the current release results in WebLogic Server not meeting all Java EE 6 compatibility requirements. To maintain Java EE 6 compatibility, the files required for JPA 2.1 support are not enabled by default, although they are included in a standard WebLogic Server installation."
Have a look #
How to Enable Java Persistence 2.0 for Weblogic 10.3.6
and
https://docs.oracle.com/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309

Related

How do I upgrade from CDI1.0 to CDI 1.1

For Java EE project I use JBoss AS7.1 and Eclipse IDE. In Eclipse I can see the current version of CDI under: Project -> Properties -> ProjectFacets -> CDI
How do I change the version to CDI 1.1 ?
If you are prepared to upgrade your application server, then make the switch to WildFly 8 or higher (WildFly is the new name of JBoss AS). CDI 1.1 is part of the Java EE 7 spec, which is implemented in WildFly 8.*, GlassFish 4.*, et al. If you are not able to upgrade your application server, you might be able to drop a JAR of an implementation of CDI 1.1 into your build, but it would probably be better to upgrade to EE 7 if you can.

migrating jsf application from weblogic10 to weblogic 12c

We are encountering issues while deploying the new core SDM modules (wars) in weblogic 12c version. The new SDM core module (wb-tss-core-sdm-web-war-0.9.1.war) uses the JSF ,SeamListeners & FacesServlet (version 1.2 jars) and we have found that the JSF 1.2 version is not directly compatible with the weblogic 12c version. Hence, the application deployment is failed with user defined listener conflict issue
As per Weblogic 12c documentation,
"WebLogic Server 12.1.1 has enhanced support for JSF and JSTL. In this
release, JSF 2.x and JSTL 1.2 have been incorporated directly in the
server's classpath. Your applications deployed to WebLogic Server can
seamlessly make use of JSF 2.x and JSTL 1.2 without requiring you to
deploy and reference separate shared libraries, as was the case in
previous releases. For backward compatibility, WebLogic Server
provides JSF and JSTL libraries that can be deployed and referenced by
applications. See Deploying JSF 1.2 and JSTL Libraries. "
We had tried to install the JSF 1.2 wars explicitly in the weblogic server path as per the documentation to support the backward compatibility and forced the SDM application/war to use the JSF 1.2 version jars by adding the below entries in the weblogic.xml .
<wls:library-ref>
<wls:library-name>jsf</wls:library-name>
<wls:specification-version>1.2</wls:specification-version>
<wls:implementation-version>1.2</wls:implementation-version>
<wls:exact-match>false</wls:exact-match>
</wls:library-ref>
But the deployment is failed again with FacesServlet listener issue as the "jsf-impl-1.2_04_P02.jar" jar is already part of (wb-tss-core-sdm-web-war-0.9.1.war) war .
Tried to add the following entries in the weblogic,xml to force the application to use the application specific jars/classes which are part of the application war file.
<wls:prefer-application-packages>
<wls:package-name>javax.faces.*</wls:package-name>
<wls:package-name>com.sun.faces.*</wls:package-name>
<wls:package-name>com.bea.faces.*</wls:package-name>
<wls:package-name>com.sun.facelets.*</wls:package-name>
</wls:prefer-application-packages>
After adding the above entries, the application deployment is completed successfully but have noticed the following errors in the console:
<BEA-101162> <User defined listener com.sun.faces.config.ConfigureListener failed: javax.faces.FacesException: org.jboss.seam.jsf.SeamApplicationFactory.
javax.faces.FacesException: org.jboss.seam.jsf.SeamApplicationFactory
Due to this above error, some of the Jasper file upload SDM screens are not accessible and it is getting failed with this error:
java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.render.RenderKitFactory. Attempting to find backup.
How do we get past this?
We had the same issue during migration of JBoss Seam application from Weblogic 10.3.3 to Weblogic 12.1.1.
It was resolved by switching to Weblogic's default JSF 2.1.14 and updating Seam version to 2.3.
Hope this helps.
Not sure if you saw the longer discussion on this question:
Migrating JSF-Application to Weblogic 12
This helped me when analysing a similar library migration issues (hibernate was on my list).

converting JPA 1.0 to JPA 2.0

In eclipse ,I am trying to upgrade my JPA from 1.0 to 2.0 (EJB project). I have made changes in the library and using eclipselink also but when I am again creating a project it is not giving an option of JPA 2 in faclets to select
any one have some idea whats the problem
It will depend on the version of Eclipse, and the weblogic plugin (OEPE) you are using. Without the correct connectors Eclipse is only aware that WebLogic server can run JPA1.0.
Perhaps try the latest version of OEPE pack here and point it at your workspace.
You also need to make sure the version of WebLogic you are using supports JPA2- you have tagged the question as weblogic 10.x which only supports JPA2.0 in 10.3.4 and later, and may require you to patch weblogic to enable the support.

Upgrading GlassFish 3.1.2.2 to use JPA 2.1

I am working with GlassFish 3.1.2.2 (I can not upgrade to 4 due to OS restrictions).
I'm interested in upgrading JPA 2.0 to JPA 2.1 GlassFish 3.1.2.2. How can I achieve this?
This is most likely not possible at all. JPA 2.1 is part of EE 7 and therefore not fully integrated with EE 6 GF 3.1.2.2.
Did you try just replacing the EclipseLink and JPA jar files in Glassfish?
It will probably work, but if you use managed persistence units they will not expose any JPA 2.1 API, you would need to unwrap the EntiyManager to access these.
I'm using Hibernate 4.3.8 (requires JPA 2.1) with Glassfish 3.1.2.2.
Note: I'm not using any services provided by glassfish. All the libraries I use are in the WEB-INF/lib.
1 - Override all JPA classes (package javax.persistence) in glassfish/modules/javax.persistence.jar with JPA 2.1 version. You should not replace the entire JAR, only override the classes. This JAR has an OSGI manifest and other classes that must remain there.
2 - Remove all javassist classes (package javasssist) from glassfish/modules/weld-osgi-bundle.jar. This solves a possible incompatibility if you are using Hibernate.

What is the minimally required server to deploy JSF 2.0 project?

I can either install Tomcat or glassfish server in the production server inorder to deploy my JSF 2.0 project. Which from which versions of these servers are compatible with JSF 2.0? Please give suggestion.
I have developed with Mojarra 2.0.2, Facelets and PrimeFaces, Netbeans 6.8
In general you need at least a server that supports Servlet 2.5 or later for JSF 2.0 (found at coreservlets.com JSF 2.0 tutorial), e.g.:
Tomcat 6+
Glassfish 2.1+
Jetty 6+
Google App Engine
JBoss 5+
WebSphere 6+
WebLogic 9+
If not integrated, you then need jsf-api.jar and jsf-impl.jar for JSF 2.0
If you have a server that supports Java EE 6 (Glassfish 3, JBoss 6, WebLogic 11g) these jar's are already included.
JSF 2.0 uses version 2.5 of the servlet-api, which means it should be compatible with Tomcat version 6.0.x.
Sources:
http://javaserverfaces.java.net/nonav/rlnotes/2.0.0/releasenotes.html
http://tomcat.apache.org/whichversion.html