What's the solution to the JBoss AS 7.1 dom4j Exception? - jboss

I've got RESTful web services that I deploy in a .war file in JBoss AS 7.1. So far so good. Now I'm adding a .jar file with JPA 2.0 Entities. When I deploy the .war with the .jar file with the JPA Entities included I get this Exception at deploy time:
org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
This problem is posted numerous times all over the web and there are about half as many suggested solutions but none of them work.
There is no dom4j.jar in my archive. My Hibernate 4.0 dependencies are all <scope>provided</scope>. None of the .jar files included in my .war file have any dom4j classes in them.
Does anyone know what causes this with JBoss 7.1 and what the solution is?
Thanks.

The dom4j Exception was caused by having an incorrect port number in the in standalone.xml. Instead of throwing a meaningful exception JBoss threw the meaningless exception about dom4j.
After correcting the port number, I tried to reproduce the error by undeploying the archive, shutting down JBoss and setting the port number back to the incorrect port number. When I deployed and enabled the archive this time JBoss showed an Exception that it could not get a managed connection for the datasource. The meaningless exception gets replaced by meaningful exception after the first successful deployment of the archive with the correct .
A longer thread about this process is here.

Related

Glassfish V3.1 Invalid ejb jar it contains zero ejb

I'm just about migrating from JBoss 6.1 to Glassfish 3.1 (don't ask why). The following occurs:
Invalid ejb jar [mmsUserMgmtAct-0.0.1-SNAPSHOT.jar]: it contains zero ejb
...
Note:
1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message-
driven bean.
2. EJB3+ entity beans (#Entity) are POJOs and please package them as library jar.
3. If the jar file contains valid EJBs which are annotated with EJB component level
annotations (#Stateless, #Stateful, #MessageDriven, #Singleton), please check server.log
to see whether the annotations were processed properly.
As everything was running perfectly with Jboss I can swear there are EJBs within the jars. The only thing which might cause the error is the fact, that I splitted the interfaces (#Remote and #Local) plus the entities (#Entity) into a package xyzService.jar and the stateless bean (#Stateless, #Remote(XyzService.class)) into another archive named xyzServiceImpl.jar.
All packaging was generated by maven, so no issues with this. Maybe I should mention that I simply copied the things into autodeploy folder.
Any glues?
Thx in advance
El Subcomandante

Deploying to Glassfish classpath not set for com.mysql.jdbc.jdbc2.optional.MysqlXADataSource

Glassfish is not loading the com.mysql.jdbc.jdbc2.optional.MysqlXADataSource package.
The following error is thrown
javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence
Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException:
Error in allocating a connection. Cause: Class name is wrong or classpath is not set
for:com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
Error Code: 0 at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy
(EntityManagerSetupImpl.java:517)...
I have copied the mysql-connector jar file to the lib directory of Glassfish but I still get the above error.
How do I ensure that Glassfish can find my JDBC driver for my deployed application?
You will need to make the MySQL JDBC jar file available to Glassfish.
http://ushainformatique.com/blog/2010/03/19/jdbcwithglassfish/
EDIT:
How do I use different JDBC drivers? Where should I copy the jar(s)?
It is recommended to place JDBC drivers, that are used by all the
applications in the domain, in domain-dir/lib or
domain-dir/lib/classes. A restart of the application server instance
is required today so that the JDBC drivers are visible to applications
deployed in the domain.
From https://blogs.oracle.com/sivakumart/entry/classloaders_in_glassfish_an_attempt
So move the jar file into the lib dir below the domain into which you are deploying your app. The default Glassfish domain is domain1.
Restart Glassfish and this should work.
There is a Maven Glassfish plugin which may be worth evaluating http://maven-glassfish-plugin.java.net/ Using Maven and this plugin would help automate the deployment step. This would be more robust than doing manual deployments. Your call though of course.
Besides adding the driver to your classpath, you should try adding the appserv-rt.jar file to your project's build path (the jar is located in Glassfish's lib directory). If you don't want to include all the other jars you should first create a library containing the appserv-rt jar and then add it to your project's build path.
We could fix using
./asadmin start-database
This starts Derby (don't know why this is required, may be a bug, and I dont use this DB in my app)
:)

Including DB2JCC4 in Tomcat 7

I have just upgraded to Tomcat v7. I am trying to include a jar in the lib that my java classes need. It is DB2JCC4.JAR. I use this to access DB2 on an IBM mainframe.
This used to work fine in Tomcat6.
When I include the jar, then I get errors such as:
Deploying web application directory C:\tomcat7\webapps\dbs
org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component
.....
caused by: org.apache.tomcat.util.bcel.classfile.ClassFormatException: null is
not a Java .class file....
I have tried putting URIEncoding in the Server.XML but that does not help.
When I take out the DB2JCC4 jar file, I do not get startup errors. Of course, then I cannot access DB2! I appreciate any suggestions.
Try changing $TOMCAT_HOME/conf/catalina.properties and add DB2JCC4.jar to tomcat.util.scan.DefaultJarScanner.jarsToSkip property value. It is used to turn off classpath scanning (which is used across JavaEE 6 specs implementations).
If you were wondering why the issue is happening in the first place and not just a workaround you can find the answer here. IBM has acknowledged the issue and has provided options for fixing it. Essentially a few of the class files are corrupt.

Deploy failed on online GlassFish, works locally

I have an EJB JAR + JSF WAR that runs fine on local GlassFish deployed from NetBeans, but if i try to deploy the WAR on an online GlassFish, I get the following error:
Exception while loading the app :
java.lang.Exception: java.lang.IllegalStateException:
ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED!
com.ejb.entity.myEntity
EDIT GlassFish Log Message:
Message ID
Unsanitized stacktrace from failed start... com.sun.faces.config.ConfigurationException
Complete Message
http://pastebin.com/deSsYgDV
Also:
EJB deploys fine on online GF
EJB # local GF: sometimes yes, mostly not: http://pastebin.com/9R1acDVq
The EJB is pretty messy, both interfaces implement the same methods: When a session bean has remote as well as local business interface, there should not be any method common to both the interfaces. Should I fix this first?
Both servers are configured the same way. The EJB is imported in the WAR. What could be the problem? Any thoughts or ideas would be appreciated!
When a session bean has remote as well as local business interface, there should not be any method common to both the interfaces.
This is a NetBeans warning which I thought would cause no problems since the web application was using Local interfaces only. After removing the Remote interfaces from the EJB, I was able to deploy the WAR on both local and online GlassFish.

Classloader in WEBLOGIC SERVER

I did ear deployment in weblogic 10.It conatins war, ejb jar, APP-INF, META-INF. Now When I am calling the service from war, I am getting classnot found exception.When I deploy the war file , without using ear file this service works absoulutely fine.
How to resolve this problem. How classloader will check for jars
It's impossible to solve your problem without more details but as you asked for documentation on how classloaders work in WebLogic, you will find information in Understanding WebLogic Server Application Classloading. Also have a look at Understanding J2EE Application Server Class Loading Architectures on TheServerSide.com (quite old but still perfectly valid).
In your particular case, I'd like to know if you are using Manifest Class-Path entries. More details on how your EAR is structure exactly would be also welcome. Please update your question accordingly.