OpenJPA 2.1.1 enhancement problem on Glassfish 3.1.1 - jsf

My problem is this exception:
Caused by: <openjpa-2.1.1-r422266:1148538 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "
I'm trying to get an very simple java application with jsf and jpa running, but there seems to be a problem with the enhancement of my entities. As far as I know, tries OpenJPA to enhance my entities at runtime, which are listet in the persistence.xml, however there is no agent to do this. The keyword for this is: Enhancing at Runtime, right?
I thought the enhancement will automatically done by the application server at deployment? How can I configure this?
My exactly environment:
Glassfish 3.1.1
Derby, which is integrated in Glassfish
OpenJPA 2.1.1
Mojarra JSF 2.1.3
Update #1:
After some comments I've added the following lines to my persistence.xml:
<property name="openjpa.DynamicEnhancementAgent" value="false"/>
<property name="openjpa.RuntimeUnenhancedClasses" value="supported" />
It works now, but OpenJPA throw this warning:
SEVERE: 52 myApp WARN [http-thread-pool-8080(5)] openjpa.Enhance - Creating subclass for "[class myApp.model.entities.AbstractEntity, class myApp.model.entities.Post]".
This means that your application will be less efficient and will consume more memory than it would if you ran the OpenJPA enhancer. Additionally, lazy loading will not be available for one-to-one and many-to-one persistent attributes in types using field access; they will be loaded eagerly instead.
I think this can't be the solution.
Update #2:
Refer to fvu's answer, I've tried to define the -javaagent jvm parameter in the domain.xml and over the web admin console. After a restart appeared the problem again.
Update #3:
Refer to update #2, I've played a bit around. There must be thrown an error, when the -javaagent parameter is used, but the file is missing, right?. Yes, there it is:
Waiting for domain1 to start .Command start-domain failed.
Error starting domain domain1.
The server exited prematurely with exit code 1.
Before it died, it produced the following output:
Error occurred during initialization of VM
agent library failed to init: instrument
Error opening zip file or JAR manifest missing : /tmp/openjpa.jar
If I copying the agent to this location, this error doesn't appear, but openjpa could still not enhance my entities!

If you're still having issues... I'd highly recommend biting the bullet and setting up build time enhancement. You'll be much happier in the long run if you get that going.

A couple of ideas:
add the Java agent for enhancement to GF's JVM option, see this link for an example of how to install a javaagent and OpenJPA's doc 5.2.3, enhancing at runtime. That emulates enhancer activation in desktop apps as closely as possible IMO.
However, when I read chapter 5.2.4 of the OpenJPA docs it might be capable of picking up the correct enhancer automatically. Try copying openjpa.jar to the domain's library directory, and check what happens after a server restart.

Related

Runtime error when class files added to jar in wrong order

This is a very strange error that took a while to find out what was going on. We have multiple jenkins linux slaves that were building a library. When the library was tested from one slave all was well. When it was tested with the other it got a runtime error with where it was trying to call a method signature that was non-existent. After lots of testing, I was able to determine that the order in which the class files were added to the jar determined if the tests would work or not. Does anyone know where to begin trying to remedy this? Is this a bug in groovy classloading? java classloading? Any ideas are appreciated.
I took the approach that the error state was in fact the correct state and started looking at the application config in detail (I'm on build team, so I was not familiar with this app) and found a bad spring configuration object. The issue dealt with order in which classes were processed by annotation scanner. If one class was processed first it would give a bad config which gave a bad app state which caused the error. The other build servers were building the jar with the bad class later in the config which caused a different state to be loaded which essentially ignored the bad file. This is why order in which classes were added to the jar mattered. I was able to correct the bad config and solve the error permanently.

Error loading solr config from solrconfig.xml

I'm using solr 5.2.1 with jetty.In my logs(solr.log) there's an error with
"org.apache.solr.core.CoreContainer; Error creating core [dosweb]: Could not load conf for core project : Error loading solr config from solrconfig.xml" title
,and I understand it's because of misconfigured in solr version,and it is showing me this exception:Caused by: java.lang.IllegalArgumentException: Illegal parameter 'termIndexInterval'
,what I should do to fix it.
thanks alot.
Not enough data.
It seems like your core is misconfigured for 5.2.1
I'd suggest that you try first with a reference configuration core, or a reference empty core, make sure that works, and then merge the config from the dosWeb core to the newly created core in steps.
This way you will find the part of the configuration that causes the issue.
EDIT -
After you added information (still not enough - a snippet of the offending configuration would have been good) I've been able to track down the bug that refers to the issue you get.
https://issues.apache.org/jira/browse/SOLR-6560
Essentially - the configuration for termIndexInterval is now not only deprecated, but can't be done in a standard way at all. From what I understand from the bug, It's also not needed anymore.

getting jHipster project working with Atomikos JTA/XA transactions

I've been playing with the jHipster yeoman generator for the past week and I'm trying to get my application working with atomikos for JTA/XA transactions and I'm running into a number of problems, which is to be expected since I'm new to spring boot and a number of the other components in the jHipster stack.
I have been using the example found here as my starting point for configuring atomikos. I've implemented everything described there, replacing HikariCP entirely.
At the moment I have eliminated Metrics and liquibase from my configuration as they were giving me problems and I wanted to get the basics working and then add them back in. However, I'm now hitting a Hibernate issue.
Hibernate is complaining that second-level cache is used but hibernate.cache.region.factory_class is not given. The factory_class setting is specified in the configuration and I'm not able to figure out what I'm missing.
Has anyone managed to get atomikos (or maybe bitronix) working with this stack?
I've managed to get this working. For some reason I had to explicitly set hibernate.cache.use_second_level_cache to false. Not sure why it would require this given that I am not setting any second level cache flags anywhere that I can see.
Never the less. It's working now.

WARNING: Multiple JSF Applications found on same ClassLoader. Unable to safely determine which FactoryManager instance to use

I am trying to create an application where I combine jsf2, prettyfaces, jpa and glassfish 3.1. I had some trouble gettings prettyfilter to load properly, which was fixed by following the tutorial here.
However, after completing the steps I got a problem with the Glassfish log being flooded by some really really irritating warnings mesages. It seams they dont have any impact on the functionality of my page, but I would like to know if there is something that will make them go away? The warning is:
WARNING: Multiple JSF Applications found on same ClassLoader. Unable to safely determine which FactoryManager instance to use. Defaulting to first match
In addition I'm having problem undeploying this webapp. Glassfish admin gui will show a text saying "Long lasting process has been detected", before the admin gui is useless and I have to restart the gf server. I get an error in the gf log:
INFO: PrettyFilter shutting down...
INFO: Admin Console: Initializing Session Attributes...
WARNING: java.lang.reflect.InvocationTargetException while attempting to process a 'command' event for 'button1'.
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException while attempting to process a 'command' event for 'button1'.
Not sure if this makes any sense for anyone, but any help is much appreciated!!:)
Both issues are already reported to the Glassfish dev team.
Issue GLASSFISH-15809 - JSF PhaseListener executed for each virtual host
Issue GLASSFISH-16112 - Admin GUI fails with NPE when attempting to undeploy an application
Glassfish 3.2 will be the earliest version where both issues will be fixed.

Xerces error: org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl

I'm developing a web application using JSF 2.0, NetBeans 6.9.1, GlassFish Server 3.1, mojarra 2.0.3, and JasperReports 3.7.6. Included in my project library is the jar file "xerces-2.8.0.jar". This file was imported as part of the JasperReports jar file library. Whenever I try to deploy, run, or debug my project through NetBeans, I receive this error:
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! DTD factory class org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl does not extend from DTDDVFactory.
After any change in my project my build fails, and I receive the above error, when I try to deploy, run, or debug it. I have to restart the server and run/debug a second time. I've searched the internet and cannot find a solution to this problem. I've looked at the jar file in question, and and DTDDVFactoryImpl does indeed extend from DTDDVFactory - I don't know why I'm receiving this error. While I can eventually get my project running, it would be much nicer if I wasn't receiving this error.
Can anyone please tell me how I can fix this? Do I need to remove this file from my project library? Do I need to update this file with a newer version/older version?
If you provide your own xerces.jar, you have to do that through the Endorsed Standards Override Mechanism (java -Djava.endorsed.dirs=/path/to/xerces.jar), you are not allowed to just add it on the classpath (and will sooner or later run into trouble if you do). Let me explain.
JAXP is the Java API for XML Processing. The creation of JAXP objects (like parsers, XSLT transfomers, DOM Documents) is done through the factory/factory-method pattern so you can plugin a new JAXP implementation (it has to be newer than the one provided in your JRE). Xerces provides (part of) a JAXP implementation and contains endorsed standards (an endorsed standard is a Java API defined through a standards process other than the Java Community Process, see the Endorsed Standards Override Mechanism). You'll run in all kinds of troubles if you don't use the ESOM.
I got this error when using Selenium with Glassfish. I got around it by copying XML jars (xerces-*, xalan-*, xml-apis*, serialize*) from selenium/libs/ to $AS_HOME/lib/endorsed (for Glassfish 2) or to $AS_HOME/glassfish/lib/endorsed for Glassfish 4.

Resources