I try to develop JPA project on ibm RAD. And i can run it on Webpshere successfully,
but the problem is my machine is quite old. So deploying in Java EE container isn't
reasonable.And i want to run it on JSE.But it gives following error:
94 test INFO [main] openjpa.Runtime - Starting OpenJPA 1.2.1-SNAPSHOT
235 test INFO [main] openjpa.jdbc.JDBC - Using dictionary class "com.ibm.ws.persistence.jdbc.sql.DB2Dictionary".
1797 test WARN [main] openjpa.Enhance - This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "[class Customer]".
Exception in thread "main" <openjpa-1.2.1-SNAPSHOT-r422266:686069 fatal user error> org.apache.openjpa.persistence.ArgumentException: The type "class Customer" has not been enhanced.
at org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1650)
at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1624)
at org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:717)
at org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:616)
at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:541)
at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:308)
at org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1114)
at org.apache.openjpa.kernel.DelegatingBroker.newObjectId(DelegatingBroker.java:268)
at org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:451)
at deneme.main(deneme.java:21)
What i'm missing?
By the my persistent.xml is:
**<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
<provider>
com.ibm.websphere.persistence.PersistenceProviderImpl
</provider>
<class>Customer</class>
<properties>
<property name="openjpa.ConnectionDriverName" value="com.ibm.db2.jcc.DB2Driver"/>
<property name="openjpa.ConnectionURL" value="jdbc:db2://localhost:50000/PARUD:retrieveMessagesFromServerOnGetMessage=true;"/>
<property name="openjpa.ConnectionUserName" value="db2admin"/>
<property name="openjpa.ConnectionPassword" value="xxxxx"/>
<property name="openjpa.jdbc.Schema" value="POOL"/>
</properties>
</persistence-unit>
</persistence>**
Just a pointer:
You need to enhance your classes e.g. at runtime via -javaagent:yourlib.jar
or even while compiling. You could learn more on this topic here:
"The second and recommended way get runtime enhancement is to provide a javaagent when launching the JVM that OpenJPA is going run in."
I just went through the exercise of getting OpenJPA 2.1.0 to run on Tomcat 7.0. I was simply unable to get run-time enhancement to work under Tomcat so I gave up and decided to use build-time enhancement. I am developing my code under Eclipse so I followed the instructions here:
http://openjpa.apache.org/enhancement-with-eclipse.html
Note however that the instructions on this page are for generic java projects. If you are working with Dynamic Web Projects, be sure to specify the build directory argument correctly. I used -Dbuild.dir=build/classes which is the typical location for the compiled code.
One more annoying quirk you have to live with. You must manually invoke the builder using the "Project > Build Project" menu item. When the enhancer runs, it modifies the previously built classes. Consequently, you need to hit F5 or Refresh for the project before you publish to Tomcat.
Related
I use cucumber testNG for my project and and already added some configuration based on Configuring BDD for execution and QAF Cucumber but when i run it, GherkinScenarioFactory not run any test.
[main] ERROR com.qmetry.qaf.automation.util.PropertyUtil - resources\application.properties (The system cannot find the path specified)
[main] INFO com.qmetry.qaf.automation.core.ConfigurationManager - ISFW build info: {qaf-Type=core, qaf-Revision=15, qaf-Version=2.1, qaf-Build-Time=20-N
ov-2019 22:28:06}
[main] ERROR com.qmetry.qaf.automation.core.ConfigurationManager - D:\Automation\resources not exist!
include groups []
exclude groups: [] Scanarios location: resources/features
[main] INFO com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory - scenario.file.loc[Ljava.lang.String;#400cff1a
[main] INFO com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory - total test found: 0
I've added the dependency qaf and also qaf-cucumber with version 2.1.15. I've also added the #QAFTestStepProvider annotation in the step file. Here's my testng.xml file :
<suite name="MyTest">
<test name="ComparationTest" >
<parameter name="step.provider.pkg" value="com.example.steps" />
<parameter name="scenario.file.loc" value="resources/features" />
<classes>
<class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
</classes>
</test>
in the feature file I added : Examples: {'datafile': 'resources/data/data.xls'}
and last in cucumber runner I added plugin "com.qmetry.qaf.automation.cucumber.QAFCucumberPlugin"
I'm still learing, can somebody tell me what did i miss?
It looks that you are pointing to wrong location for resources and feature file/directory. You need to provide relative path to project root directory for resources and scenarios directory. If you observe the log also complains that fie/folder not exist.
[main] ERROR com.qmetry.qaf.automation.util.PropertyUtil - resources\application.properties (The system cannot find the path specified)
[main] INFO com.qmetry.qaf.automation.core.ConfigurationManager - ISFW build info: {qaf-Type=core, qaf-Revision=15, qaf-Version=2.1, qaf-Build-Time=20-N
ov-2019 22:28:06}
[main] ERROR com.qmetry.qaf.automation.core.ConfigurationManager - D:\Automation\resources not exist!
Make sure that you have resources directory under project root.
Regarding feature files, according to your current configuration
scenario.file.loc is resources/features. In that case make sure that <project-root>/resources/features is exist. For example your project root is D:/Automation then resources/features points to D:/Automation//resources/features
If not then provide correct relative path to project root.
For example resources/features expects <project-root>/resources/features if it is not there provide correct location.
Same is applied for other resources including properties file and test data files.
For application.properties it is expected under <project_root>\resources\application.properties if it is not there you can provide location by using system property application.properties=<relateive_path_to_project> or alternately place under default location <project_root>\resources.
As a side note,
instead of GherkinScenarioFactory recommended is BDD2 factory com.qmetry.qaf.automation.step.client.text.BDDTestFactory2
Latest version of qaf as of today is 3.1.0-RC1 the version you are using 2.1.15 is quite old.
I'm trying to use Hibernate-Search in one of my JavaEE projects and seem to run into the exact same problem as described by Rallenaldo:
My Maven-project is using
Java JDK 1.8.0_73
Hibernate 5.0.6.Final
Hibernate-Search 5.5.2.Final (which uses Lucene 5.3.1)
and try to deploy on a Glassfish 4.1.1 application server (with just minimal changes to the standard configuration).
When deploying my application the deployment process ends in the following ClassCastException, when Lucene tries to load codecs from the package lucene-backward-codecs (version 5.3.1):
java.lang.ClassCastException: class org.apache.lucene.codecs.lucene40.Lucene40PostingsFormat
at java.lang.Class.asSubclass(Class.java:3404)
at org.apache.lucene.util.SPIClassIterator.next(SPIClassIterator.java:141)
at org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:65)
at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:47)
at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:37)
at org.apache.lucene.codecs.PostingsFormat$Holder.<clinit>(PostingsFormat.java:49)
at org.apache.lucene.codecs.PostingsFormat.forName(PostingsFormat.java:112)
at org.apache.lucene.codecs.lucene40.Lucene40Codec.<init>(Lucene40Codec.java:115)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at java.lang.Class.newInstance(Class.java:442)
at org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:67)
at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:45)
at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:37)
at org.apache.lucene.codecs.Codec$Holder.<clinit>(Codec.java:47)
at org.apache.lucene.codecs.Codec.forName(Codec.java:113)
at org.apache.lucene.index.SegmentInfos.readCodec(SegmentInfos.java:469)
...
As has been elsewhere suggested, I have already verified that on my computer there is no other version of Lucene nor Hibernate-Search.
If I exclude the lucene-backward-codecs dependecy from the Maven-project, I get a similar ClassCastException at the exact same location in the Lucene-code:
java.lang.ClassCastException: class org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat
at java.lang.Class.asSubclass(Class.java:3404)
at org.apache.lucene.util.SPIClassIterator.next(SPIClassIterator.java:141)
at org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:65)
at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:47)
at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:37)
at org.apache.lucene.codecs.PostingsFormat$Holder.<clinit>(PostingsFormat.java:49)
at org.apache.lucene.codecs.PostingsFormat.forName(PostingsFormat.java:112)
at org.apache.lucene.codecs.lucene53.Lucene53Codec.<init>(Lucene53Codec.java:160)
at org.apache.lucene.codecs.lucene53.Lucene53Codec.<init>(Lucene53Codec.java:80)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
...
I was not able to find a solution to this problem. And I am aware that Rallenaldo's question is actally also still open. Does someone know what causes this problem? Is this a Glassfish 4.1.1 problem?
Edit: I want to add the following observation to my original post: part of my project generates an standalone application packed as a self executable jar-file with the identical hibernate and lucene related dependencies, where I also use an entity manager with essentially the same configuration for the presistence context. In this case I do not have the above problem with hibernate-search. It starts without any problem and I can see it generate the expected index files. Here are the relevant lines from the persistence.xml:
<persistence-unit name="puName" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
...
<property name="hibernate.search.default.directory_provider" value="filesystem"/>
<property name="hibernate.search.default.indexBase" value="/path/to/lucene/indexes"/>
...
</properties>
</persistence-unit>
Ok. Here is better answer. The solution (workaround) for us was to put lucene-analyzers-common-5.3.1.jar and lucene-core-5.3.1.jar directly into domain lib folder. After debugging I have found that class Lucene40PostingsFormat is being loaded by two classloaders and then instantiated from first classloader as a subclass of another (it gives class cast exception). I assume there is one unnecessary loading but I do not know why and how to change it with configuration only.
We are trying to make a webservice call using CXF framework involving CXF - ws security and the application being deployed in weblogic 10.3 , but receiving the below exception and seems like the weblogic specific jars are picked up , though the xercesimpl jar is present in the application in /WEB-INF/lib .
Options tried , but did not help:
Setting the weblogic container descriptor with
web-inf preferences
true .
Setting the JVM arguments or system property as -
-Djavax.xml.soap.MessageFactory=com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl
-Djavax.xml.soap.SOAPFactory=com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl
-Djavax.xml.soap.SOAPConnectionFactory=weblogic.wsee.saaj.SOAPConnectionFactoryImpl
Adding xercesimpl jar to maven pom.
Exception
]] Root cause of ServletException.
java.lang.AssertionError: UNIMPLEMENTED
at weblogic.xml.domimpl.NodeImpl.setTextContent(NodeImpl.java:216)
at org.apache.jcp.xml.dsig.internal.dom.XmlWriterToTree.writeAttribute(XmlWriterToTree.java:137)
at org.apache.jcp.xml.dsig.internal.dom.XmlWriterToTree.writeNamespace(XmlWriterToTree.java:114)
at org.apache.jcp.xml.dsig.internal.dom.DOMXMLSignature.marshal(DOMXMLSignature.java:211)
at org.apache.jcp.xml.dsig.internal.dom.DOMXMLSignature.sign(DOMXMLSignature.java:329)
at org.apache.wss4j.dom.message.WSSecSignature.computeSignature(WSSecSignature.java:578)
at org.apache.wss4j.dom.action.SignatureAction.execute(SignatureAction.java:151)
at org.apache.wss4j.dom.handler.WSHandler.doSenderAction(WSHandler.java:226)
at org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor.access$100(WSS4JOutInterceptor.java:54)
at org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessageInternal(WSS4JOutInterceptor.java:282)
at org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessage(WSS4JOutInterceptor.java:154)
at org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessage(WSS4JOutInterceptor.java:141)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)enter code here
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:514)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:423)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:326)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:279)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:98)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:138)
Thanks,
Soumya
I finally found the answer without modifying any weblogic startup script (tested on CXF 2.7.0 and weblogic 10.3.6
The reason for this issue is that CXF is not compatible with weblogic implementation of SAAJ. http://cxf.apache.org/docs/application-server-specific-configuration-guide.html
1.
Q: I have this error: javax.xml.ws.WebServiceException: Cannot create SAAJ factory instance.
A: Please make sure you have the saaj-impl-1.3.jar in the classpath and make sure your app picks up this one instead of weblogic one.
The same issue is also causing the UNIMPLEMENTED error in the question
So my solution is
1) put saaj-impl in classpath. If you are using maven, put the dependency on pom.xml
2) in weblogic.xml (in your resources folder) put
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>com.sun.xml.messaging.saaj.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
3) Restart your server through Node Manager and by right the CXF WS-Security should be working
Hope it helps!
I'm currently trying to upgrade my web application from jboss 5.1 to jboss 7.1.1.Final
In my jboss.xml I have configured some custom ejb timeouts like the following:
<session>
<ejb-name>MSServiceEJB</ejb-name>
<jndi-name>ejb/MSServiceEJB</jndi-name>
<local-jndi-name>ejb/LocalMSServiceEJB</local-jndi-name>
<method-attributes>
<method>
<method-name>*</method-name>
<transaction-timeout>3600</transaction-timeout>
</method>
</method-attributes>
</session>
jboss 7 ignores jboss.xml, where can I specify my ejb 2.1 transaction timeouts?
Per
Source
Replace the jboss.xml deployment descriptor file
The jboss-ejb3.xml deployment descriptor replaces the jboss.xml deployment descriptor to
override and add to the features provided by the Java Enterprise
Edition (EE) defined ejb3-jar.xml deployment descriptor. The new file
is incompatible with jboss.xml, and the jboss.xml is now ignored in
deployments.
You need to create a jboss-ejb3.xml and put the configuration inside it.
It would look something like this:
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>EJBName</ejb-name>
<method-name>methodName</method-name>
<method-intf>Local</method-intf>
</method>
<tx:trans-timeout>
<tx:timeout>500</tx:timeout>
<tx:unit>Seconds</tx:unit>
</tx:trans-timeout>
</container-transaction>
</assembly-descriptor>
You are using EJB2.x , so it would be better and wise to configure it in ejb-jar.xml
It should be created in META-INF of the EJB jar.
You can specify on the Bean method with #TransactionTimeOut annotation.
#TransactionTimeout(value = 10, unit = TimeUnit.SECONDS)
For detailed description of how to set, please refer here
Maddy
As part of our application we are using apache's xerces jaxp parser. When we deploy the application on weblogic 9.2, we are getting the following error.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.cxf.wsdl.WSDLManager' defined in class path resource [META-INF/cxf/cxf.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.apache.cxf.wsdl11.WSDLManagerImpl]: Constructor threw exception; nested exception is java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
As per our analysis, weblogic is trying to to load its own DocumentBuilderFactoryImpl which is present in weblogic.jar instead of apache's xerces.
We tried the following to force the weblogic to load DocumentBuilderFactoryImpl from xerces
i) we have added the following tag into weblogic.xml
<prefer-web-inf-classes>true</prefer-web-inf-classes>
ii) we have put latest versions of xalan in jre/lib/endorced folder. this didn't resolve our problem.
ii) we have added entries in weblogic-application.xml
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
<application-param>
<param-name>webapp.encoding.default</param-name>
<param-value>UTF-8</param-value>
</application-param>
<prefer-application-packages>
<package-name>javax.jws.*</package-name>
<package-name>org.apache.xerces.*</package-name>
<package-name>org.apache.xerces.jaxp.*</package-name>
</prefer-application-packages>
</weblogic-application>
ii)Added the following entry in weblogic-application.xml
<xml>
<parser-factory>
<saxparser-factory>org.apache.xerces.jaxp.SAXParserFactoryImpl</saxparser-factory>
<document-builder-factory>org.apache.xerces.jaxp.DocumentBuilderFactoryImpl</document-builder-factory>
<transformer-factory>org.apache.xalan.processor.TransformerFactoryImpl</transformer-factory>
</parser-factory>
</xml>
iii) Added jaxp.properties to load DocumentBuilderFactoryImpl from xerces to the jre/lib and started the server.In this case, the weblogic didnt start.
iv) Then we started the server first and then copied the jaxp.properties file during the run time when server starts.But no success
None of the above worked for us.
Any help is highly appreciated.
You did so many things that I don't understand the exact status. My advice would be to strictly follow the Application Server Specific Configuration Guide for WebLogic that I've successfully used in the past with WLS 9.2.
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
<application-param>
<param-name>webapp.encoding.default</param-name>
<param-value>UTF-8</param-value>
</application-param>
<prefer-application-packages>
<package-name>javax.jws.*</package-name>
</prefer-application-packages>
</weblogic-application>
You'll certainly have to add more packages under prefer-application-packages to setup Weblogic ClassLoader filtering but in the current state of the question, it's impossible to provide a precise answer.
Just in case, you can maybe try to blindly use the weblogic-application.xml from this thread:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
<xml>
<parser-factory>
<saxparser-factory>
org.apache.xerces.jaxp.SAXParserFactoryImpl
</saxparser-factory>
<document-builder-factory>
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
</document-builder-factory>
<transformer-factory>
org.apache.xalan.processor.TransformerFactoryImpl
</transformer-factory>
</parser-factory>
</xml>
<application-param>
<param-name>webapp.encoding.default</param-name>
<param-value>UTF-8</param-value>
</application-param>
<prefer-application-packages>
<package-name>javax.jws.*</package-name>
<package-name>org.apache.xerces.*</package-name>
<package-name>org.apache.xalan.*</package-name>
</prefer-application-packages>
</weblogic-application>
But this is a shot in the dark.
You could try forcing the use of the specified document builder factory as a command line option:
-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
This is assuming that you have the required Xerces builder factory class in your classpath.
In general, you shouldn't use a separate xerces.jar anymore, unless required by some legacy code. The Xerces parser classes come with the JRE, the package names just start with com.sun.org.apache instead of org.apache. You could try also
-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
and remove xerces.jar from your classpath altogether (this is what we did on WLS 10.3 and Java 1.6).
I managed to resolve the issue DocumentBuilderFactory not found with simple solution.
Try to copy xercesImpl.jar to the domain specific lib directory on weblogic MyDomain\servers\MyServer\lib.
In my case the problem was that i made a dependency on commons-digester which in turn used another version of xerces (that caused the conflict). So you can review your dependencies in case some other version of xerces was transitively included.