Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[wtp-dev] Server Adapter Use Case Question

Hi All:

I've been having a bit of trouble with a simple use-case, and I wanted to know if this was a valid use case or if it's not actually a use-case. My issue is that the following works 100% for generic adapters, but not for the example adapter I'm including.

When you create a dynamic web project, depending on the runtime used, different jars may be added to the project's classpath. My use case is very simple. Create a dynamic web project with some server adapter (in this case, the attached stripped-down server adapter), and then add only 1 class file inside that new project, a JUnit test file, which attempts to merely access classes contributed by the facets. The goal is to see if the junit test case will be able to access these classes at runtime.

I am confronted with ClassNotFoundExceptions upon doing this. Also, in the problems view, is the following message:

Classpath entry example.app.server.classpath.genericInitializer/Example Server Runtime/jst.java/5.0 will not be exported or published. Runtime ClassNotFoundExceptions may result.

Step by step reproduction:
1) untar the attached project
2) Open a blank workspace. Import the attached project into the workspace.
3) Run the attached project as an eclipse plugin.
4) Create a new server of type Example (RS) -> Example Server Type
5) Create a dynamic web project targeting the Example Server Runtime
6) Note the classpath containers added to the project
7) Note the warnings in the Problems View
8) Create a JUnit Test *inside* this dynamic web project with the following method:
   public void testShouldNotFail() {
       Start1.class.getName();
       Start.class.getName();
   }
9a) Before running, verify that the classpath container "Example entries for jst.java" includes a jar "jst.java.jar" which has one class in it, Start1.class

9b) Before running, verify that the classpath container "Example entries for jst.web" includes a jar "jst.web.jar" which has one class in it, Start.class

10) right-click on the junit test file, and run it as a junit test.

Result:
The first line will not fail. Start1.getClass().getName() will resolve successfully. The second line *will* fail. Start.getClass().getName() will not resolve successfully.

This seems very odd, because both were added to the classpath in the same fashion as far as I can tell by looking at my stripped down server adapter example. (in example.app.server.core.classpath.ProjectRuntimeClasspathProvider in the method getClasspathEntries(IProjectFacetVersion) Also, both classpath containers receive the warning in the problems view, so it seems odd that one of the classes would resolve and the other would not.

I realize this is most likely an error in the enclosed adapter, but I'm completely unsure what one would need to do to make this junit test work properly, to ensure that these jars are exported to the junit's launch.

- Rob Stryker

Attachment: exampleServer.tar
Description: Binary data


Back to the top