Jan 16th, 2011, 03:13 PM
class path resource cannot be opened because it does not exist
I have two projects
Dynamic web project called 'productwebproject' and java project called 'productcoreproject'
In my productwebproject i have WEB-INF\app\applicaiton-config.xml file
This is my applicaiton-config.xml file
<?xml version="1.0" encoding="UTF-8"?>
<bean id="productervice" class="com.buisnessservice.ProductService">
<property name="productDao" ref="dao"></property>
<bean id="dao" class="core.dao.ProductDao"> ***ProductDao is in productcoreproject
....and so on
<import resource="classpath:/core/dao/ProductDao"/> --this line fails it says
/core/dao/ProductDao cannot be opened because it does not exist
I have productcoreproject on the buildpath of productwebproject but i guess that is not enough
Any idea what other settings i have to make? I am using RAD Ide.
Jan 17th, 2011, 05:17 AM
import resource is to load bean definitions from other xml files, not to import classes (which doesn't make any sense) !!!
I suggest you carefully read first chapters of the reference documentation.
Jan 17th, 2011, 09:04 AM
Thanks for the response.
yes you are right, it is to import xmls(and not java). I was just giving an example.The question remains how do we import a file, a bean xml file which is in another project? I dont think the document describes that.
Imagine i have core/dao/beans-database.xml sitting in the
'productcoreproject' , when i do
<import resource="classpath:/core/dao/beans-database.xml"/> in my 'productwebproject' , it doesnt work.
I googled it and it says the 'productcoreproject' needs to be in classpath of websphere? Not sure if that is the solution.
I use RAD Ide with websphere application server.
Jan 17th, 2011, 09:22 AM
To make this work, you need the xml you are trying to import to be on the classpath of the application that contains the xml file that imports it. To achieve this, you either:
- use the enterprise application structure, making your 2 projects part of an EAR and declaring that the xml importing project depends on the project which contains the xml you are trying to import (either install the latter as a shared library in the ear structure, or declare the dependency in the application.xml and manifest). This is the standard and logical way to proceed when you have, for example, multiple web applications that are part of the same EAR and share a single back-end or business layer;
- put the xml file you are trying to import onto the classpath of the application server (in your case, IBM Websphere). The application server classpath is automatically added to the classpath of all the enterprise or web applications that are deployed into that server. To accomplish this, you either put the file in the server's "shared lib" directory or you add the file location to the classpath variable used to execute the java command that starts the server.
The first option being the recommended one.
Jan 17th, 2011, 12:19 PM
thanks v much for the detailed explanation.