cancel
Showing results for 
Search instead for 
Did you mean: 

JPA Warning - Urgent help needed

Former Member
0 Kudos

Hi,

Can somebody help me resolving this warning?

Description:

1. Warning exception has been returned while the 'sap.com/JDBCTestJBEAR' was starting. Warnings:

Warning occurred on server 3425650 during startApp sap.com/JDBCTestJBEAR : Application sap.com/JDBCTestJBEAR has a weak reference to resource MY_PRODIN_DB with type javax.sql.DataSource but the resource is not available and the application may not work correctly.

Many thanks,

Dharmi

Edited by: Dharmi Tanna on Apr 29, 2008 2:44 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Dharmi,

Go to nwa and check whether the resouce MY_PRODIN_DB is currently running.

For doing this you have

1. Go to nwa by url http://<host-name>:<port number>/nwa

2. Go to Configuration management

3. Select Infrastrucutre

4. Select Application Resources

There check whether your resource is ingreen(fully available) or not.

If not start it

Hope it helps.

Regards,

Srinivasan Subbiah

Former Member
0 Kudos

Hi Srinivasan,

Resource is green. Hereby the [Resource screenshot|http://img206.imageshack.us/img206/5735/appresourceis3.jpg]

Any more pointers?

Best regards,

Dharmi

Former Member
0 Kudos

Hi Dharmi,

Is your code not working?

I think it is just a warning and you can go ahead to execute and see whether it works.

Also check whether you code for lookup is correct.


public static final String DATASOURCENAME="jdbc/MYSQLDB_DS1_ALIAS1";
ctx=new InitialContext();
			ds=(DataSource)ctx.lookup(DATASOURCENAME);

This is an example with MYSQLDB_DS1_ALIAS1 as a custom alias.

Hope it helps.

Regards,

Srinivasan Subbiah

Former Member
0 Kudos

Hi Srinivasan,

I have no lookup mention in the code. Is that necessary? Did not see the same in the JPA tutorial!

Awaiting your reply.

Best regards,

Dharmi

Former Member
0 Kudos

Hi Srinivasan,

I do see the WSDL, but when I execute it from WS navigator, I get the following error:

javax.ejb.EJBException: Exception in getMethodReady() for stateless bean sap.com/ProdinSQLEJBEARannotation|ProdinSQLEJB.jarannotation|ProdinPartsBean; nested exception is: com.sap.engine.services.ejb3.util.pool.PoolException: javax.ejb.EJBException: Cannot perform injection over bean instance service.ProdinPartsBean@56a2601e for bean sap.com/ProdinSQLEJBEARannotation|ProdinSQLEJB.jarannotation|ProdinPartsBean; nested exception is: com.sap.engine.lib.injection.InjectionException: Injection on field em of instance service.ProdinPartsBean@56a2601e failed. Could not get a value to be injected from the factory.

Any ideas?

Best regards,

Dharmi

Former Member
0 Kudos

Hi dharmi,

We did had this in our code for access the datatbase. But we have not configured the xml as you did. But for us it is working fine.

Regards,

Srinivasan Subbiah

Former Member
0 Kudos

Hi Srinivasan,

Sorry did not understand what you meant! Do you mean the configuration of application-j2ee-jar.xml?

Can you please explain and suggest changes so that my code also works fine?

Best regards,

Dharmi

Former Member
0 Kudos

Hi dharmi,

Ok. Just try puting this code in and check whether it works. This is what i uased after creating the data source.


public static final String DATASOURCENAME="jdbc/MYSQLDB_DS1_ALIAS1";
	
	/**
	 * Constructor for initialization	 
	 */
	private DAOFactory(){
		Context ctx=null;
		try{
			ctx=new InitialContext();
			ds=(DataSource)ctx.lookup(DATASOURCENAME);
		}
		catch(NamingException ne){
			PLogger.getInstance().logException(CLASSNAME,"DAOFactory()",ne);
		}
	}

Hope it helps.

Regards,

Srinivasan Subbiah

Former Member
0 Kudos

Hello Srinivasan,

Where does this code go? In SessionBean? Do you then use DS further in the method or not?

Best regards,

Dharmi

Former Member
0 Kudos

Hi dharmi,

I am having it in a separate class. This class also has getInstance() and a getConnection(). Then you can use this in any bean.

Regards,

Srinivasan Subbiah

Former Member
0 Kudos

Hi Srinivasan,

I am totally confused here. Can you please explain step by step? Where all I need to change the code to get it working?

1. Create a DAO class????

Best regards,

Dharmi

Former Member
0 Kudos

Hi,

You are right. Just write a DAOFactory class.

This DAOFactory is going to have two methods and one private constructor.

1. Private Constructor- is where the context is lookedup for datasource. This is the code i gave you.

2. getInstance()- just checks whether a DAOFactory object exits if not creates a new one. In this way you maiontain only one connection at any time.

3. getConnection()- creates the connection from the datasource object you created.

From the class where you want to create a connection and execute a statement, first just call the getInstance()(static method). Then call getConnection() using the object you got from getInstance().

getConnection will return a Connection using which you can execute any statement.

This i think is the standard procedure.

Hope it is clear and helps you.

Regards,

Srinivasan Subbiah

Former Member
0 Kudos

Hi Srinivasan,

I am now getting the following error when testing the Web Service from WS Navigator.

javax.ejb.EJBException: Exception in getMethodReady() for stateless bean sap.com/JDBCTestJBEARannotation|JDBCTestEJB.jarannotation|ProdinEmpBean; nested exception is: com.sap.engine.services.ejb3.util.pool.PoolException: java.lang.NullPointerException

Can you help?

Thanks much,

Dharmi

Former Member
0 Kudos

Hi dharmi,

Could you deduce where exactly the nullopinter exception is taking place. Check whether you have called getInstance() or where is it occuring. It seems your mail is blocked at gateway of my office. Instead of attaching you can paste it in mail itself.

Regards,

Srinivasan Subbiah

Former Member
0 Kudos

Hi dharmi,

Have you fixed the exception.

Regards,

Srinivasan Subbiah

Former Member
0 Kudos

Hello Srinivasan,

Nope, I still get that message. Due to timelines, however I opted not to work with JPA and just do it with Java and that works.

I appreciate your help. Thank you very much.

Best regards,

Dharmi

Answers (0)