iuoyo
Fevereiro 8, 2012, 4:20pm
#1
Boaa Tarde Galera!
Estou aqui apelando por meu ultimo recurso. Estou desenvolvendo um trabalho para a ferramenta TIDIA-AE que eh uma ferramenta derivada do Sakai Project.
Acontece que ela usa o Spring Framework e eu ainda estou apanhando com os beans e tals. Estou com uma exception no ApplicationContext.xml que eu não consigo instanciar a meleca do DominioService.
Não sei quais códigos devo postar, então vai uma parte da Exception (Ela está ocorrendo no tomcat, pois estou fazendo deploy e testando, mas não consigo sair dessa exception que ocorre no tomcat no log do statup.bat):
ERROR: Exception sending context initialized event to listener instance of class
org.sakaiproject.util.ContextLoaderListenet (2012-02-08 20:03:26,356 ContainerB
ackgroundProcessor[StandardEngine[Catalina]]_org.apache.catalina.core.ContainerBase.
[Catalina].[localhost].[/selfregulationsystem-tool])
org.springframework.beans.factory.BeanCreationException: Error Creating bean with
name 'masterBean' defined in ServletContext resource [/WEB-INF/applicationContext.xml]:
Instatiation of bean failed: nested exception is java.lang.NoClassDefFoundError:
br/edu/ufabc/srs/service/DominioService
Caused By:
java.lang.NoClassDefFoundError: br/edu/ufabc/srs/service/DominioService
at java.lang.Class.getDeclaredMethods0(Native Method)
Esse aqui é meu ApplicationContext.xml:
[code]<?xml version=“1.0” encoding=“UTF-8”?>
<!DOCTYPE beans PUBLIC “-//SPRING//DTD BEAN//EN”
“http://www.springframework.org/dtd/spring-beans.dtd ”>
<beans>
<bean id=“masterBean” class=“br.edu.ufabc.srs.bean.MasterBean”>
<property name=“sakaiService” ref=“br.edu.ufabc.srs.service.SakaiService” />
<property name=“dominioService” ref=“br.edu.ufabc.srs.service.DominioService” />
</bean>
</beans>
[/code]
Por fim, meu MasterBean:
[code]package br.edu.ufabc.srs.bean;
import java.sql.SQLException;
import java.util.ArrayList;
import br.edu.ufabc.srs.model.Dominio;
import br.edu.ufabc.srs.service.DominioService;
import br.edu.ufabc.srs.service.SakaiService;
public class MasterBean {
private SakaiService sakaiService;
private DominioService dominioService;
public void setSakaiService(SakaiService sakaiService) {
this.sakaiService = sakaiService;
}
public void setDominioService(DominioService dominioService) {
this.dominioService = dominioService;
}
public SakaiService getSakaiService() {
return sakaiService;
}
public ArrayList<Dominio> pegarDominios() throws SQLException {
return this.dominioService.buscarTodosDominios();
}
}
[/code]
Agradeço a atenção de todos! Estou ficando louco com esse erro que eu nao consigo resolver. Já pesquisei de tudo.
Vc está utilizando dois projetos separados?
Um só com modelo e outro apenas com a view?
iuoyo
Fevereiro 8, 2012, 4:33pm
#3
Estou utilizando Maven no projeto divididos nos seguintes módulos:
O tool é onde fica a parte web e ele implementa a API que tem as interfaces que eu estou utilizando. O Negócios é que o pom.xml jah esta declarando a dependencia, tanto que o SakaiService ele não da erro, não sei porque. =[
Vc faz o deploy dentro de um EAR? WAR/jar separados?
Só para tirar uma dúvida bem idiota, verifica se essas classes estão indo na hora do deploy.
iuoyo
Fevereiro 8, 2012, 4:39pm
#5
eu ainda nao domino o maven completamente, mas nao vejo nenhum EAR e nem na pasta raiz. Ele compila e jah faz deploy direto no tomcat com arquivo .war
na pasta raiz ele produz uma pasta bin que contem toda as classes compiladas. assim como o projeto web e as inclusões do PACK.
No arquivo WAR você consegue ver essas classes que estão faltando?
Eu imagino que o problema seja: mesmo que você tenha adicionado no mavem que as classes são dependência, pode ser que elas não estão sendo empacotadas por falta de alguma configuração extra.
iuoyo
Fevereiro 8, 2012, 5:25pm
#8
É, eu abri o war e na WEB-INF na pasta /lib não tem nenhuma das bibliotecas e nem na pasta classes.
Estranho porque deveria dar problema ao instanciar o SakaiService não?
Preciso dar uma olhada na configuração do Maven.
[quote=iuoyo]É, eu abri o war e na WEB-INF na pasta /lib não tem nenhuma das bibliotecas e nem na pasta classes.
Estranho porque deveria dar problema ao instanciar o SakaiService não?
Preciso dar uma olhada na configuração do Maven.[/quote]
Eu imaginei que era classe faltando por empacotamento. Agora, oq tinha que fazer ou não, aí não sei te falar.
Tenho muito q aprender de Maven e Spring. [=
Coloca sua configuração do mavem aí que talvez outra pessoa possa te ajudar.
iuoyo
Fevereiro 8, 2012, 5:40pm
#10
realmente eh complicado maven, aqui tem arquivos project.xml, é do maven? Segue meus pom.xml
do Project
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Sakai SelfRegulationSystem</name>
<groupId>br.edu.ufabc</groupId>
<artifactId>selfregulationsystem</artifactId>
<organization>
<name>Sakai Project</name>
<url>http://sakaiproject.org/</url>
</organization>
<inceptionYear>2008</inceptionYear>
<packaging>pom</packaging>
<version>0.1</version><!--SelfRegulationSystem.version-->
<!-- Sakai master pom is the parent -->
<parent>
<artifactId>master</artifactId>
<groupId>org.sakaiproject</groupId>
<!-- <version>SNAPSHOT</version>-->
<!-- <version>M2</version>-->
<version>2.5.3</version>
<relativePath>../master/pom.xml</relativePath>
</parent>
<profiles>
<profile>
<id>full</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
<module>api</module>
<module>impl</module>
<module>pack</module>
<module>tool</module>
</modules>
</profile>
<profile>
<id>tool</id>
<modules>
<module>tool</module>
</modules>
</profile>
<profile>
<id>api</id>
<modules>
<module>api</module>
</modules>
</profile>
<profile>
<id>ddl</id>
<modules>
<module>impl/src/ddl</module>
</modules>
</profile>
</profiles>
<!-- handles the management of all related dependencies -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>br.edu.ufabc.srs</groupId>
<artifactId>selfregulationsystem-api</artifactId>
<version>0.1</version><!--SelfRegulationSystem.version-->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>br.edu.ufabc.srs</groupId>
<artifactId>selfregulationsystem-impl</artifactId>
<version>0.1</version><!--SelfRegulationSystem.version-->
</dependency>
<!--
<dependency>
<groupId>org.sakaiproject.entitybroker</groupId>
<artifactId>entitybroker-api</artifactId>
<version>[1.3.3,1.4.0)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.sakaiproject.entitybroker</groupId>
<artifactId>entitybroker-utils</artifactId>
<version>[1.3.3,1.4.0)</version>
</dependency>
-->
</dependencies>
</dependencyManagement>
<!-- ensure master jars can be found -->
<repositories>
<repository>
<id>sakai-maven</id>
<name>Sakai Maven Repo</name>
<layout>default</layout>
<url>http://source.sakaiproject.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
API
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Sakai SelfRegulationSystem API</name>
<groupId>br.edu.ufabc.srs</groupId>
<artifactId>selfregulationsystem-api</artifactId>
<organization>
<name>Sakai Project</name>
<url>http://sakaiproject.org/</url>
</organization>
<inceptionYear>2008</inceptionYear>
<description>SelfRegulationSystem interfaces (API)</description>
<packaging>jar</packaging>
<properties>
<deploy.target>shared</deploy.target>
</properties>
<!-- the base is parent -->
<parent>
<groupId>br.edu.ufabc</groupId>
<artifactId>selfregulationsystem</artifactId>
<version>0.1</version><!--SelfRegulationSystem.version-->
</parent>
<dependencies />
<build>
<resources>
<resource>
<directory>${basedir}/src/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<!-- include the readme.txt file and the java source files -->
<resource>
<directory>${basedir}</directory>
<includes>
<include>*.txt</include>
<include>src/**/*.java</include>
<include>src/**/*.html</include>
<include>src/**/*.xml</include>
<include>src/**/*.properties</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
</project>
IMPL
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Sakai SelfRegulationSystem Implementation</name>
<groupId>br.edu.ufabc.srs</groupId>
<artifactId>selfregulationsystem-impl</artifactId>
<organization>
<name>Sakai Project</name>
<url>http://sakaiproject.org/</url>
</organization>
<inceptionYear>2008</inceptionYear>
<description>SelfRegulationSystem implementation</description>
<packaging>jar</packaging>
<properties>
<deploy.target />
</properties>
<!-- the base is parent -->
<parent>
<groupId>br.edu.ufabc</groupId>
<artifactId>selfregulationsystem</artifactId>
<version>0.1</version><!--SelfRegulationSystem.version-->
</parent>
<dependencies>
<!-- internal dependencies -->
<dependency>
<groupId>br.edu.ufabc.srs</groupId>
<artifactId>selfregulationsystem-api</artifactId>
</dependency>
<!-- generic DAO -->
<dependency>
<groupId>org.sakaiproject</groupId>
<artifactId>generic-dao</artifactId>
<version>0.9.1</version>
</dependency>
<!-- shared external dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
<!--
<dependency>
<groupId>org.sakaiproject.entitybroker</groupId>
<artifactId>entitybroker-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.entitybroker</groupId>
<artifactId>entitybroker-utils</artifactId>
</dependency>
-->
<!-- Sakai dependencies -->
<dependency>
<groupId>org.sakaiproject</groupId>
<artifactId>sakai-entity-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject</groupId>
<artifactId>sakai-authz-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject</groupId>
<artifactId>sakai-entity-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject</groupId>
<artifactId>sakai-site-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject</groupId>
<artifactId>sakai-tool-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject</groupId>
<artifactId>sakai-user-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject</groupId>
<artifactId>sakai-util-api</artifactId>
</dependency>
<!-- testing dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
<version>2.0.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jta</groupId>
<artifactId>jta</artifactId>
<version>h2.1.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.1_3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>1.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>easymock</groupId>
<artifactId>easymock</artifactId>
<version>1.2_Java1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>${basedir}/src/bundle</directory>
<includes>
<include>**/*.properties</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>${basedir}/src/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
<!-- unit testing -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<!--
By default, the surefire plugin will automatically include all test classes with the following wildcard patterns:
"**/Test*.java" - includes all of its subdirectory and all java filenames that start with "Test".
"**/*Test.java" - includes all of its subdirectory and all java filenames that end with "Test".
"**/*TestCase.java" - includes all of its subdirectory and all java filenames that end with "TestCase".
-->
</plugin>
</plugins>
<testResources>
<testResource>
<directory>${basedir}/../pack/src/webapp/WEB-INF</directory>
<includes>
<include>spring-hibernate.xml</include>
<include>logic-support.xml</include>
</includes>
</testResource>
<testResource>
<directory>${basedir}/src/test</directory>
<includes>
<include>hibernate-test.xml</include>
<include>hibernate.properties</include>
</includes>
</testResource>
</testResources>
</build>
</project>
PACK
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Sakai SelfRegulationSystem Components Pack</name>
<groupId>br.edu.ufabc.srs</groupId>
<artifactId>selfregulationsystem-pack</artifactId>
<organization>
<name>Sakai Project</name>
<url>http://sakaiproject.org/</url>
</organization>
<inceptionYear>2008</inceptionYear>
<description>SelfRegulationSystem components pack (special Sakai convention)</description>
<packaging>sakai-component</packaging>
<properties>
<deploy.target>components</deploy.target>
</properties>
<!-- the base is parent -->
<parent>
<groupId>br.edu.ufabc</groupId>
<artifactId>selfregulationsystem</artifactId>
<version>0.1</version><!--SelfRegulationSystem.version-->
</parent>
<dependencies>
<!-- internal dependencies -->
<dependency>
<groupId>br.edu.ufabc.srs</groupId>
<artifactId>selfregulationsystem-impl</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build />
</project>
Tools
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Sakai SelfRegulationSystem Tool</name>
<groupId>br.edu.ufabc.srs</groupId>
<artifactId>selfregulationsystem-tool</artifactId>
<organization>
<name>Sakai Project</name>
<url>http://sakaiproject.org/</url>
</organization>
<inceptionYear>2008</inceptionYear>
<description>SelfRegulationSystem webapp (tool)</description>
<packaging>war</packaging>
<!-- the base is the parent pom -->
<parent>
<groupId>br.edu.ufabc</groupId>
<artifactId>selfregulationsystem</artifactId>
<version>0.1</version><!--SelfRegulationSystem.version -->
</parent>
<dependencies>
<!-- Internal Dependency -->
<dependency>
<groupId>br.edu.ufabc.srs</groupId>
<artifactId>selfregulationsystem-api</artifactId>
</dependency>
<!-- we are running a webapp in tomcat so we need the servlet api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
<!-- We need this special package to run the jsps in Sakai -->
<dependency>
<groupId>org.sakaiproject</groupId>
<artifactId>sakai-jsp-adapter</artifactId>
<version>0.8-M2</version>
<scope>runtime</scope>
</dependency>
<!-- Sakai util dependency -->
<dependency>
<groupId>org.sakaiproject</groupId>
<artifactId>sakai-util</artifactId>
<version>${sakai.version}</version>
<scope>runtime</scope>
</dependency>
<!-- standard tag libraries -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
</dependency>
<!-- apache commons logging -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/java</sourceDirectory>
<resources>
<resource>
<directory>${basedir}/src/bundle</directory>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
</project>
Desculpe se não postei certo =[
Esses são os arquivos de configuração do MAVEN do projeto.
Agradeço a atenção.
iuoyo
Fevereiro 9, 2012, 2:09am
#11
Aeee galera, consegui capturar o erro no tomcat…
Ainda nao consegui resolver. Toda ajuda é bem vinda.
Grato