Problem with splitting sculptor model into different projects

48 views
Skip to first unread message

Kirill Alexandrovsky

unread,
Aug 18, 2015, 11:29:46 AM8/18/15
to Sculptor Generator
Hello

I have a problem with sculptor's importing mechanism.

I try to make a make multiple projects using archetypes from pure EJB3 tutorial:
  • helloworld-parent
  • helloworld
  • helloworld-ear
Model contains just one entity, repository, resource, and service. And it works just fine.

Then I add helloworld-shared project with next structure:
helloworld-shared/src/main/resources
  model
-shared.btdesign:
   
ApplicationPart MyApp {
   
    Module shared_model {
   
        basePackage=org.helloworld
            Entity Employee {
               
                String name
               
                Repository EmployeeRepository {
                    findById;
                    findAll;
                    save;
                    delete;
                }
            }
  model
.btdesign: //doesn't build without this file
    import "classpath:/model-shared.btdesign"

    Application MyApp {
        basePackage=org.helloworld
    }

And in business tier project I just have
import "classpath:/model-shared.btdesign"

Application MyApp {

    basePackage=org.helloworld

    Module test1 {
        Service EmployeeService {
            findById => EmployeeRepository.findById;
            findAll => EmployeeRepository.findAll;
            save => EmployeeRepository.save;
            delete => EmployeeRepository.delete;
        }

        Resource EmployeeResource {
            show => EmployeeService.findById;
            showAll => EmployeeService.findAll;
            create => EmployeeService.save;
            delete => EmployeeService.delete;
            update => EmployeeService.save;
        }

        Resource HelloWorldResource {
            void hello;
        }
    }
}
I also add needed dependencies in pom.xml for business tier project. Everything according to Advanced tutorial. Plus disabling generation for the shared part in sculptor-generator.properties.

After that I have two problems. Sculptor cannot find shared model on classpath when building parent project.
[ERROR] Failed to execute goal org.sculptorgenerator:sculptor-maven-plugin:3.1.0:generate (code-generation) on project helloworld: Execution code-generation of goal org.sculptorgenerator:sculptor-maven-plugin:3.1.0:generate failed: org.eclipse.xtext.resource.FileNotFoundOnClasspathException: Couldn't find resource on classpath. URI was 'classpath:/model-shared.btdesign' -> [Help 1]

This issue doesn't happen when I build business tier project separately. But in this case tests begin to fali:
Tests in error:
  testFindAll(org.helloworld.test1.serviceapi.EmployeeServiceTest): Name "MessagingTestBean" not found.
  testSave(org.helloworld.test1.serviceapi.EmployeeServiceTest): Name "MessagingTestBean" not found.
  testFindById(org.helloworld.test1.serviceapi.EmployeeServiceTest): Name "MessagingTestBean" not found.
  testDelete(org.helloworld.test1.serviceapi.EmployeeServiceTest): Name "MessagingTestBean" not found.

testDelete(org.helloworld.test1.serviceapi.EmployeeServiceTest)  Time elapsed: 0 sec  <<< ERROR!
javax.naming.NameNotFoundException: Name "MessagingTestBean" not found.

Can you tell me what can possibly lead to these errors? Maybe some general directions to look into.

Thank you

Torsten Juergeleit

unread,
Aug 18, 2015, 12:09:06 PM8/18/15
to Sculptor Generator

  model.btdesign: //doesn't build without this file
    import "classpath:/model-shared.btdesign"

    Application MyApp {
        basePackage=org.helloworld
    }

Here the (redundant) "model.btdesign" can be omitted if the Sculptor Maven Plugin is configured to look for "src/main/resources/model-shared.btdesign" instead of its default "src/main/resources/model.btdesign":

<plugin>
	<groupId>org.sculptorgenerator</groupId>
	<artifactId>sculptor-maven-plugin</artifactId>
	<executions>
		<execution>
			<id>code-generation</id>
			<goals>
				<goal>generate</goal>
			</goals>
			<configuration>
				<model>src/main/resources/model-shared.btdesign</model>
			</configuration>
		</execution>
	</executions>
</plugin>


After that I have two problems. Sculptor cannot find shared model on classpath when building parent project.
[ERROR] Failed to execute goal org.sculptorgenerator:sculptor-maven-plugin:3.1.0:generate (code-generation) on project helloworld: Execution code-generation of goal org.sculptorgenerator:sculptor-maven-plugin:3.1.0:generate failed: org.eclipse.xtext.resource.FileNotFoundOnClasspathException: Couldn't find resource on classpath. URI was 'classpath:/model-shared.btdesign' -> [Help 1]

In the POM of Maven Project "helloworld" the Sculptor Maven Plugin needs as a (plugin) dependency of the Maven artefact created by the Maven project "helloworld-shared" (containing the classpath resource "/model-shared.btdesign"):

<plugin>
	<groupId>org.sculptorgenerator</groupId>
	<artifactId>sculptor-maven-plugin</artifactId>
	<executions>
		<execution>
			<id>code-generation</id>
			<goals>
				<goal>generate</goal>
			</goals>
		</execution>
		<dependencies>
			<dependency>
				<groupId>your.groupid</groupId>
				<artifactId>helloworld-shared</artifactId>
				<version>1.0</version>
				<classifier>client</classifier>
			</dependency>
		</dependencies>
	</executions>
</plugin>

/Torsten
Reply all
Reply to author
Forward
0 new messages