Posts Tagged ‘weblogic’

No EJBs found in the ejb-jar file ‘MyApplication.jar’. Please ensure the ejb-jar contains EJB declarations via an ejb-jar.xml deployment descriptor or at least one class annotated with the @Stateless, @Stateful or @MessageDriven EJB annotation

30 November 2010 4 comments

Another migration error. In my application.xml I have defined an <ejb> module but my ejb project only contains EJB 3.0 @Entity annotated beans. WebLogic (10.3) doesn’t like this and expects a @Stateless, @Stateful or @MessageDriven annotated bean. It doesn’t find any and throws a

No EJBs found in the ejb-jar file ‘MyApplication.jar’. Please ensure the ejb-jar contains EJB declarations via an ejb-jar.xml deployment descriptor or at least one class annotated with the @Stateless, @Stateful or @MessageDriven EJB annotation

exception. The exact same jar file works fine on JBoss and WebSphere though. Not sure which one is right but I had to add a dummy @Stateless EJB in the jar file order to make it work.

Categories: JBoss, Seam, WAS, WebLogic Tags: , , , ,

java.lang.UnsupportedOperationException: The user must supply a JDBC connection

26 November 2010 5 comments

If you get this with Hibernate it probably means that you have an error, or an incomplete persistence.xml file. I got this while migrating from JBoss to WebLogic server and had forgotten to migrate the configuration from JBoss’ *-ds.xml to persistence.xml.

It happens because of this bit of code (Hibernate’s

ConnectionProvider connections;
String providerClass = properties.getProperty(Environment.CONNECTION_PROVIDER);
if ( providerClass!=null ) {
	try {"Initializing connection provider: " + providerClass);
		connections = (ConnectionProvider) ReflectHelper.classForName(providerClass).newInstance();
	catch ( Exception e ) {
		log.error( "Could not instantiate connection provider", e );
		throw new HibernateException("Could not instantiate connection provider: " + providerClass);
else if ( properties.getProperty(Environment.DATASOURCE)!=null ) {
	connections = new DatasourceConnectionProvider();
else if ( properties.getProperty(Environment.URL)!=null ) {
	connections = new DriverManagerConnectionProvider();
else {
	connections = new UserSuppliedConnectionProvider();

It tries to load several connection providers based on the Environment properties, it can’t find any connection providers (since their corresponding properties are not defined in the persistence.xml) and it just returns the default UserSuppliedConnectionProvider which, alas, it’s getConnection method is the following

public Connection getConnection() {
	throw new UnsupportedOperationException("The user must supply a JDBC connection");

After fixing the error, my persistence.xml is the following

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="" 
   <persistence-unit name="myUnit" transaction-type="JTA">


		<property name="hibernate.connection.provider_class" value="org.hibernate.connection.DatasourceConnectionProvider"/>
	   	<property name="hibernate.connection.datasource" value="myDatasource"/>
	   	<property name="transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
	   	<property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
	   	<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/>
        <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
        <property name="" value="validate"/>
        <property name="hibernate.show_sql" value="true"/>
        <property name="hibernate.format_sql" value="true"/>
        <property name="hibernate.default_schema" value="MYSCHEMA"/>
	 <property name="hibernate.query.factory_class" value="org.hibernate.hql.ast.ASTQueryTranslatorFactory"/>