Websphere 9.0.0.7 - Cluster Loading Wrong JPA Specification - jpa

Having a very frustrating problem right now that I've exhausted all other avenues of research on. In short, we have a certain vendor application that runs on Websphere 9 and requires JPA 2.0 specification for java persistence.
The issue is, despite setting the JPA specification level to 2.0 in the administrative console, as well as setting it via wsadmin command directly, the cluster continues to load JPA 2.1 and ultimately causing big errors when the application runs.
We see it in the startup logs at:
00000001 SharedJPAComp I CWWJP0048I: Initialized the JPA service for
the JPA 2.1 specification level.
Seen in verbose class loading at:
class load: com.ibm.ws.jpa.runtime.JPA21Runtime from:
file:/opt/app/WebSphere90/AppServer_x64/plugins/com.ibm.ws.jpa.container21.jar
And seen in System.Out logs during the actual exception :
0000017c BusinessExcep E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "insert" on bean
"BeanId([app name redacted], null)". Exception data:
java.lang.AbstractMethodError:
javax/persistence/EntityManagerFactory.createEntityManager(Ljavax/persistence/SynchronizationType;Ljava/util/Map;)Ljavax/persistence/EntityManager;
at
com.ibm.ws.jpa.runtime.JPA21Runtime.createEntityManagerInstance(JPA21Runtime.java:165)
Actual correct setting shown here
Websphere Java Persistence Settings
Has anyone encountered this kind of issue? Research so far has found nothing. Running on Websphere fixpack 9.0.0.7

Related

NoClassDefFoundError when using instrumentation on Bluemix

I am trying to add a javaagent to my bluemix app, this agent uses Instrumentation. The thing is that when I run the application I get the following error:
premain() - Instrumentation is already running
...
CWWKF0004E: An unknown exception occurred while installing or removing features. Exception: java.lang.NoClassDefFoundError: agent.ClassInstrumentorTransform
ERR at com.ibm.ws.kernel.feature.internal.subsystem.SubsystemFeatureDefinitionImpl.setHeader(SubsystemFeatureDefinitionImpl.java)
ERR at [internal classes]
I have tried creating another agent with the same Premain-Class and Agent-Class structure but with my own classes and it works, I have tried uploading my own copy of Instrumentation classes and point the javaagent to it using Class-Path but the error still appears.
Any sugestion what can be the problem?
I suspect maybe the Bluemix enviorment uses the Instrumentation, any ideas how this might be checked and how I can solve the inter dependency?
Based on the error message, it looks like you have a class in a feature bundle that is trying to access a class from the javaagent, but you have not added the javaagent package to org.osgi.framework.bootdelegation as described in the Specifying Liberty profile bootstrap properties" topic in the knowledge center topic.

javax.servlet.ServletException: PWC1391: Servlet.init() for servlet <project>.webservice.ApplicationConfig threw exception

What could be the cause for this error while running my Java EE 6 app from embedded container using Eclipse?
HTTP Status 500 -
type Exception report
message
description: The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: PWC1391: Servlet.init() for servlet <project>.webservice.ApplicationConfig threw exception
root cause
com.sun.jersey.spi.inject.Errors$ErrorMessagesException
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.
Edit: Basically since I ran it successfully, I upgraded eclipse and made some changes in project (refactor/renaming variables) and svn repository setup.
Have you tried the suggestions Google produces when you search for PWC1391? Namely resolving potential version conflicts with the Jersey library (i.e. removing it from project).
Finally figured out that there were some libraries missing...including Glassfish 3.1.2 being the major one from "Web"'s "Java Build Path > Libraries".

websphere 7 and (application based) open-jpa 2

I want to not use the built in Websphere 7 jpa plugin, instead use an application WEB-INF/lib/open-jpa 2 and a proprietary persistence provider. I cannot install the OSGI and JPA 2 feature pack for Websphere.
Originally, I was getting a sax parse error simply trying to load the persistence.xml (version="2" not supported). The error was thrown by a class in open-jpa 1.2.3. When I run websphere/appserver/bin/wsjpaversion.bat, the open-jpa 1.2.3 jar is displayed. By default it overrides the open-jpa 2 jar in the app. I created a shared library containing the open-jpa 2 jar with this config option checked: 'Use an isolated class loader for this shared library'. I set my application classloader to load parent last and assigned it the new shared library resource. The 'version 2' error is gone, but there is another problem. When I try to initialize an EntityManager I get an error:
Caused by: javax.persistence.PersistenceException: Failed to load provider from META-INF/services
at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:121)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:91)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
... 2 more
Caused by: java.lang.ClassCastException: com.ibm.websphere.persistence.PersistenceProviderImpl incompatible with javax.persistence.spi.PersistenceProvider
at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:110)
... 11 more
One more detail: inside the persistence.xml, the provider element is set to the proprietary PersistenceProviderImpl not the default Websphere persistence provider. So where is this websphere default coming from and how do I prevent it? (another important note: when I remove persistence.xml completely, I get the same error)
Thank you
Without installing the feature pack, you're fighting a losing battle. While it is possible to plug in your own JPA implementation, it is not possible to do that with JPA API — so WAS 7 ties you to the 1.0 version of JPA (see, for example, here how this is done — no class loader policy juggling will change that, though it seems tempting at first).

jsf-console 3.x on JBoss 6.x possible?

I'm trying to move an application from JBoss 4.2.2 AS to 6.x AS. Right now I'm trying to get jbpm 3.x running on the AS I have this problem when trying to upload a .par file to the server:
13:41:51,713 ERROR [org.jbpm.db.GraphSession] (http-127.0.0.1-8888-1) java.lang.ClassCastException: org.jbpm.graph.def.Node_$$_javassist_92 cannot be cast to javassist.util.proxy.ProxyObject
Which then results in:
13:41:51,740 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/app].[ProcessUploadServlet]] (http-127.0.0.1-8888-1) Servlet.service() for servlet ProcessUploadServlet threw exception: org.jbpm.JbpmException: couldn't find process definition 'ProcessName'.
I've tried using both old and new versions of javassist which has no positive effect. Any ideas?
It seems you are using eclipse plugins and you have class loader problem between 2 plugins, make sure that you have only one class loader to load ProxyObject (Javassist)

Trouble with Aspectj load-time-weaving when using EclipseLink JPA in Spring dm Server 1.x

I am attempting to get EclipseLink JPA working inside the Spring dm Server OSGi environment.
Relevant frameworks and libraries downloaded from the Spring Enterprise Bundle Repository include:
dm Server 1.0.2.SR02
AspectJ Runtime 1.6.3
AspectJ Weaver 1.6.3
Spring Framework 2.5.6.A
Eclipse Persistence 1.1.0
Javax Persistence API 1.99.0
I followed the same structure as presented in the PetClinic-1.5.0 example for setting up EclipseLink JPA. Everything works until lazy-fetching is enabled (which requires proxied objects).
Once lazy-fetching is enabled, the following error suggests that load-time-weaving is not working correctly.
---- (truncated for readability)
Exception [EclipseLink-60] (Eclipse Persistence Services - 1.1.0.r3634): org.eclipse.persistence.exceptions.DescriptorExcep tion
Exception Description: The method [_persistence_setcustomer_vh] or [_persistence_getcustomer_vh] is not defined in the object [net.fractech.fds.backoffice.Job].
Internal Exception: java.lang.NoSuchMethodException: net.fractech.fds.backoffice.Job._persistence_getcu stomer_vh()
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[customer]
Descriptor: RelationalDescriptor(net.fractech.fds.backoffice.J ob --> [DatabaseTable(JOBS)])
This shows that the _persistence_getcustomer_vh() and _persistence_setcustomer_vh() methods were not automatically weaved into the Job domain object.
Questions
1.) How do I determine if load-time-weaving is actually working; moreover, how do I log which load time weaving agent and weaver was started? How do I pass switches to this weaver to have it output debugging information?
I assume I started load-time-weaving with <context:load-time-weaver aspectj-weaving="on" />
2.) Many searches have revealed that I do not need to pass the -javaagent parameter to the jvm when using dm Server. Is this correct?
3.) I have assured that my domain objects in another bundle have access to the eclipse persistence classes by asserting com.springsource.org.eclipse.persistence;version="[1.1.0,1.1.0]";import-scope:=application in my eclipselink bundle and including all application bundles within a PAR. Are there any other configurations needed to enable EclipseLink JPA in Spring dm Server?
I had similar problems. First try setting eclipselink.weaving.lazy=false, or eclipselink.weaving=false if that doesn't work. I had to set the latter.
If you would like to refer to the setup I am using to see if it applies to you, I have a post about it on my site.
It is better to use Equinox Waving Springwaver
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
...
<property name="loadTimeWeaver">
<bean class="org.eclipse.equinox.weaving.springweaver.EquinoxAspectsLoadTimeWeaver"/>
</property>
</bean>
You don't need to use -javaagent option then.
You can find working examples with JPA and EclipseLink here http://code.google.com/p/springdm-in-action/ (see Chapter 7).
I have tried to use EquinoxAspectsLoadTimeWeaver into JPa context (with EclipseLink) but it doen't transform the model classes if your EquinoxAspectsLoadTimeWeaver bean declaration is not done into the same bundle than Model bundle.
EquinoxAspectsLoadTimeWeaver transform class ONLY for the classes stored into the bundle wich declare EquinoxAspectsLoadTimeWeaver.
I have tried the sample http://code.google.com/p/springdm-in-action/ (see Chapter 7) (thank for this sample Lukasz). The declaration of EquinoxAspectsLoadTimeWeaver avoid having the error
Caused by: java.lang.IllegalStateException: Cannot apply class transformer without LoadTimeWeaver specified
But Model classes are not transformed (woven). Weaving into EclipseLink manage for instance lazy mode. For instance if you set into the sample model Contact lazy mode like this :
public class Contact {
...
#Column(name="last_name")
#Basic(fetch=FetchType.LAZY)
private String lastName;
you will notice that lazy loading is not applied because Model Contact class is not wowen.
Regards Angelo