I've been struggling with this one for a few days now, hopefully someone can help.
I'm getting the following error when my application tries to build my Hibernate3 SessionFactory:
...
org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml
...
Caused by: org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
...
Below is my /WEB-INF/jboss-web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<loader-repository>some.unique.package.name:archive=lvs.war
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</jboss-web>
Hibernate works fine in my unit tests, it's only when I deploy it to the test server that this happens.
From what I've found, this appears to be happening because jboss already has a copy of dom4j.
No I can't remove dom4j from my project, web-apps on the server it will be hosted on are expected to use all their own jars.
Try to change / check value for your server configuration.
In server/xxx/deploy/jboss-web.deployer/META-INF/jboss-service.xml
there are two attributes to try
Java2ClassLoadingCompliance
UseJbossWebLoader
Both are boolean values and control some class loader behaviour.
HTH.
Related
I am trying to migrate my project from jboss-eap-6.4 to jboss-eap-7.2.
When I try to deploy my war file, I get following error:
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYUT0027: Failed to parse XML descriptor \"/C:/jboss-eap-7.2/standalone/deployments/my.war/WEB-INF/lib/spring-modules-validation-1.0.0.jar/META-INF/valang.tld\" at [13,23]
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[13,23]
Message: Unexpected value 'body-content' encountered"}}
I tried searching about this and I got to know that this is common issue.
And I got one of the solution as,
changing <body-content>None</body-content> to <body-content>empty</body-content> in valang.tld
in this redhat link:
https://access.redhat.com/solutions/910833
as body-content is present at line 13 and I read the documentation for jboss eap 7.2 in which it has written that the value should be empty.
I saw another solution as making this as dependency in maven pom.xml or excluding it.
But I can't do any of this things.
I am using JBOSS EAP 7.2 with gradle, So is there any thing I can do by making changes in gradle or JBOSS's configuration files to solve this issue?
Please help me on this :)
I finally made this change
changing <body-content>None</body-content> to <body-content>empty</body-content> in valang.tld
When I add Hibernate 5 to my website, I can't get it to work in Glassfish 4.1.1. I always get an error
java.lang.NoSuchMethodError:
org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V
I've tried to replace the jboss-logging library in Glassfish' modules folder, like I read in an answer to a similar problem, but it didn't change anything. I also tried to use Hibernate 4, but that gave an other error.
In my case, I was running the Hibernate 5 with JPA annotations on tomcat and stop working when I changed to glassfish 4.1
The error:
hibernate.properties not found
Make sure: src/main/resources/hibernate.cfg.xml exists
And if you only have the dependency of hibernate-core, I was using hibernate-annotations and hibernate-common-annotations and it was creating conflict. The hibernate 5 doesnt need these two, I had read somewhere.Try to remove ;)
After that a new error appears:
java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V
The reason was the oldest jboss-logging.jar at:
"YOUR_GLASSFISH_FOLDER/glassfish/modules"
Why? The hibernate 5 has dependency with the newest version of
jboss-logging, and the glassfish 4 uses the oldest version even if you
declare inside your POM file the newest version. Actually I'm using:
org.jboss.logging jboss-logging 3.3.0.Final
Then I downloaded it and replace the old .jar inside the modules path
and it back to work, I spent 2 days trying to solve that and I hope it
helps some future issues =D
I used this link to help me: https://medium.com/#mertcal/using-hibernate-5-on-payara-cc242212a5d6#.npq2hdprz
Another solution, in my case, could be back to the last Hibernate 4 version (4.3.11.Final) but it is already too old in my opinion
I had a similar issue, I was able to fix it by creating a glassfish-web.xml file in the WEB-INF directory. The contents of the file are shown below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
<class-loader delegate="false"/>
</glassfish-web-app>
This ensures that glassfish does not load it's internal libraries, but libraries from your project..
Try to clean glassfish osgi-cache folder in your domain. You can find details in this Payara github issue: https://github.com/payara/Payara/issues/554 (Payara is a fork of Glassfish with additional features, so basic mechanics remain the same as in Glassfish)
I have a project with a EJB implementing a JWS Webservice, like this:
#Stateless
#Remote(WebServiceTest.class)
#WebService(
serviceName="TestService",
name="TestName"
)
public class WebServiceTestImpl implements WebServiceTest {
#Override
#WebMethod(operationName="hello")
public String hello() {
return "Hello World!";
}
}
I deploy and test this perfectly on WebLogic 10.3 using a simple EAR project. Now I need to use Hibernate on my project, so from previous experiences I know that I have to use Antrl from Hibernate and not from the container, so I create a weblogic-application.xml in the EAR project:
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-application ...>
<wls:prefer-application-packages>
<wls:package-name>antlr.*</wls:package-name>
</wls:prefer-application-packages>
</wls:weblogic-application>
Now when I deploy the EAR I get this error:
Unable to deploy EJB: WebServiceTestImpl from test-1.0.0-SNAPSHOT.jar:
***** ASSERTION FAILED *****
at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:467)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:507)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:149)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: test.WebServiceTestImpl_zd33dy_WSOImpl
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:280)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:253)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:177)
Truncated. see log file for complete stacktrace
How can I solve this? If I don't put Antlr in wls:prefer-application-packages Hibernate will not work, and if I put it I cannot deploy the webservice...
Weblogic somehow keeps precompiled versions of EJBs even though you do a new/update deployment.
this works for me with wls 10.3.5:
within the server directory of your domain (e.g. in my case /home/myUser/apps/bea/domains/myDomain/servers/AdminServer) there is a subfolder "cache/EJBCompilerCache". Stop your weblogic instance and remove the contents of this subfolder. Restart weblogic and everything will work :-)
I'm not sure if this is the same bug, but there is a known bug in Weblogic 10.3.0-2 that causes a problem when using JaxWS with an EJB v 2.x. But I'm getting a near identical error when I put the #WebService annotation on an EJB v 3.0 on Weblogic 10.3.1. The error is loading what looks like the supposedly generated local stubs that Weblogic creates, and its happening on Weblogic 10.3.0, 10.3.1, 10.3.2, and 10.3.3. (yes, I really have them all deployed ;)
I had this problem deploying session bean and then trying to convert it to web service. WebLogic seems to cache session beans somehow.
There are several solution to this:
- Rename slsb.
- Comment #Stateless and #Remote annotations, deploy application, uncomment annotations, redeploy again.
- Bounce WebLogic.
GWT with JPA
There are two projects in my eclipse workspace, let's name them:
-JPAProject
-GWTProject
JPAProject contains JPA configuration stuff (persistence.xml, entity classes and so on). GWTProject is an examplary GWT project (taken from official GWT tutorial).
Both projects work fine alone. That is, I can create EMF (EntityManagerFactory) in JPAProject and get entities from the database. GWTProject works fine too, I can run it, fill the field text in the browser and get the response.
My goal is to call JPAProject from GWTProject to get entities. But the problem is that when calling DAO, I get the following exception:
[WARN] Server class 'com.emergit.service.dao.profile.ProfileDaoService' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/home/maliniak/workspace/emergit/build/classes/' to the web app classpath for this session
[WARN] /gwttest/greet
javax.persistence.PersistenceException: No Persistence provider for EntityManager named emergitPU
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at com.emergit.service.dao.profile.JpaProfileDaoService.<init>(JpaProfileDaoService.java:19)
at pl.maliniak.server.GreetingServiceImpl.<init>(GreetingServiceImpl.java:21)
...
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
[ERROR] 500 - POST /gwttest/greet (127.0.0.1) 3812 bytes
I guess that the warnings at the beginning can be omitted for now.
Do you have any ideas? I guess I am missing some basic point. All hints are highly appreciated.
Update: My persistence provider is well defined, the JPA project works well by itself.
I guess it's classpath related problem too. When running the GWT project, in WEB-INF/lib there is only gwt-servlet.jar.
Do you think that making custom Ant file to build whole thing up is the only solution (i.e. make jar out of the JPA project and copying it to WEB-INF/lib)? Or is there any Eclipse solution, so I could set the GWT project properties properly so GWT project would know to include persistence.xml file?
Update: OK, I got it working. I tried to put persitence.xml everywhere in war/WEB-INF where it was possible, but kept getting 'no persistence provider' error. It turned out that it wasn't about persistence.xml. I didn't copy the eclipselink jar to WEB-INF/lib, so it couldn't find provider class defined in persistence.xml. Copying all the jars did the thing.
Thank you very much Pascal.
Struggling a lot with the same error message, I solved the problem with copying all jars (eclipselink.jar, eclipselink-jpa-modelgen_2.1.0.v20100614-r7608.jar, javax.persistence_1.0.0.jar, javax.persistence_2.0.1.v201006031150.jar) from the EclipseLink zip to the .../war/WEB-INF/lib folder of my GWT project to make everything available for the Jetty in hosted mode.
As you can see from the list of files, I was using EclipseLink 2.1. Please adapt this list to your JPA implementation, if necessary.
Hoping, that this may help you as well.
Do you have a persistence provider declared in your persistence.xml? Something like this (I'm using Hibernate here, adapt it to whatever persistence provider you're using):
<persistence
<persistence-unit name="emergitPU" transaction-type="...">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
...
</persistence-unit>
</persistence>
If you do, then I suspect a classpath problem. Did you package the JPA project correctly in the webapp i.e. in WEB-INF/lib?
i am using jwsc to build my webservices application. This produces a war file with a weblogic.xml like the following:
<?xml version='1.0' encoding='UTF-8'?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
<context-root>eori-ws</context-root>
</weblogic-web-app>
As you can see the namespace points towards bea.com. When i try to deploy the war (inside an ear) to my weblogic i get the following:
An error occurred during activation of changes, please see the log for details.
[HTTP:101064][WebAppModule(eori_services:eori-ws)] Error parsing descriptor in Web appplication
"/softs/apps/bea1001/user_projects/domains/myapp/servers/myServer/tmp/_WL_user/myapp/jd3urj/myapp-ws.war"
weblogic.application.ModuleException: Unmarshaller failed at
weblogic.servlet.internal.WebAppModule.loadDescriptor(WebAppModule.java:858) at
weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:285)
(snip)
weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:464)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200) at
weblogic.work.ExecuteThread.run(ExecuteThread.java:172) Caused by:
com.bea.xml.XmlException: failed to load java type corresponding to e=weblogic-web-app#http://www.bea.com/ns/weblogic/weblogic-web-app at
com.bea.staxb.runtime.internal.UnmarshalResult.getPojoBindingType(UnmarshalResult.java:329)
at
com.bea.staxb.runtime.internal.UnmarshalResult.determineTypeForGlobalElement(UnmarshalResult.java:296)
at
(snip)
weblogic.servlet.internal.WebAppDescriptor.getWeblogicWebAppBean(WebAppDescriptor.java:164)
at weblogic.servlet.internal.WebAppModule.loadDescriptor(WebAppModule.java:853)
... 25 more weblogic.application.ModuleException: Unmarshaller failed
Failed to load java type corresponding to e=weblogic-web-app#http://www.bea.com/ns/weblogic/weblogic-web-app
i've tried changing the url to match the new domain and i get the same error. I've tried downloading the xsd and putting it in the same folder of the weblogic.xml, wich i changed to look like:
<?xml version='1.0' encoding='UTF-8'?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="weblogic-web-app.xsd">
<context-root>eori-ws</context-root>
</weblogic-web-app>
and the error is still the same
I'm out of ideas. Any help?
EDIT: no solution yet, ill post solution when i find it.
I solved my problem. Seems i was using the wrong version of the JWSC ant task. Just make sure to use the correct weblogic.jar