I am using log4j2 with this 2 dependencies:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>2.6.2</version>
</dependency>
When I try to log for example an error with a throwable like:
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.testng.annotations.Test;
public class Test {
private static final Logger logger = LogManager.getLogger(Test.class);
#Test
public void testSendMessage() throws Exception {
Exception exception = new Exception("some exception");
logger.error("error with exception", exception);
}
}
using patternlayout:
<Configuration>
<properties>
<property name="filters">org.testng,org.apache.maven,sun.reflect,java.lang.reflect</property>
</properties>
<Appenders>
<Console name="ConsoleAppender" target="SYSTEM_OUT" direct="true">
<PatternLayout pattern="%maxLen{%d{DEFAULT} [%p] %c{-3}:%L - %enc{%m} %xEx{filters(${filters})}%n}{200}"/>
</Console>
</Appenders>
<Loggers>
<logger name="my.test.class.path" level="trace" additivity="false">
<AppenderRef ref="ConsoleAppender" />
</logger>
</Loggers>
</Configuration>
Then the filtered packages won't disappear from the stacktrace, I can't even manipulate the stacktrace in any way like maximizing the lines:
%xEx{5}
Highlightning also don't work in eclipse nor in Kibana(ELK environment).
Can anybody help?
Could it be that the %xEx PatternLayout converter doesn't support property substitution in its options?
What if you put the packages you want to filter directly in the filters list?
It may be worth raising a Jira ticket on the Log4j 2 issue tracker for this.
try to remove the ending{200}. i think there is an issue using more sub parameters.
here is a snippet which works. please note if you add additional things like separator(|) it will stop working [tested in version 2.8.1 and 2.9.1]
<Properties>
<Property name="exfilters">org.jboss,java.lang.reflect,sun.reflect</Property>
<Property name="log-pattern">%d %-5p %m%n%xEx{filters(${exfilters})}/Property>
</Properties>
...
<PatternLayout pattern="${sys:log-pattern}"/>
Works for me on Log4j2 v 2.17 (and also for rThrowable):
<Properties>
<Property name="PACKAGE_FILTER">org.jboss,java.lang.reflect,sun.reflect</Property>
<Property name="LOG_PATTERN">%xThrowable{filters(${PACKAGE_FILTER})}</Property>
</Properties>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="${LOG_PATTERN}"/>
</Console>
</Appenders>
Related
I am developing a website on TomEE, and I want to use the EclipseLink Query Results Cache (L2) working, but every time I reload my web page, SELECT query is running (checked via general_log of mysql).
My Database entity looks like below:
#Entity(name="item")
#NamedQueries({
#NamedQuery(name="ItemEntity.getAllList",
query="Select distinct itemEntity from mypackage.entity.ItemEntity itemEntity",
hints={
#QueryHint(name="eclipselink.query-results-cache", value="true"),
#QueryHint(name="eclipselink.query-results-cache.size", value="1000"),
#QueryHint(name="eclipselink.query-results-cache.expiry", value="10000"), //10 secs for test but not working
#QueryHint(name="eclipselink.query-results-cache.type", value="FULL")
}
)
})
#org.eclipse.persistence.annotations.Cache(
type= CacheType.FULL,
size=10000,
expiry=60000, // 1 minute for test
coordinationType= CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS
)
public class ItemEntity implements Serializable, Comparable {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
#Column(name="name", unique=true, nullable=false)
private String name;
/* getters and setters for fields */
public CompanyEntity(){}
#Override
public int compareTo(Object o) {.......}
}
My persistence.xml looks like below:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="myprojectname-persistence-unit" transaction-type="JTA">
<jta-data-source>myprojectname-mysql-jdbc-jta-resource</jta-data-source>
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<properties>
<property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.MySQLPlatform"/>
<property name="eclipselink.cache.shared.default" value="true"/>
</properties>
</persistence-unit>
</persistence>
I read database table like below:
#Stateful
public class CompanyDao {
#PersistenceContext(unitName = "myprojectname-persistence-unit", type = PersistenceContextType.EXTENDED)
protected EntityManager em;
public List<CompanyEntity> getAllList(){
return this.em.createNamedQuery("ItemEntity.getAllList", ItemEntity.class).getResultList();
}
}
Dependency version details:
TomEE 1.7.2, Java EE6, openJPA 2.4.0, openEJB Java EE API 6.0-6, openEJB core 4.7.2, EclipseLink 2.6.2, MySQL 5.6.23, MySQL connector/J 5.1.38 (Tomcat connection pool)
I've looked at a similar question:
Can't get Eclipselink level 2 cache to work
but it doesn't describe how the OP managed to cache query results.
BTW, the default cache (L2), with em.find(ItemEntity.class, id); is working just fine.
What am I missing? Please help me out.
Solved.
I was using EclipseLink 2.6.2, I downgraded to version 2.4.2, and now Query Results Cache WORKS as expected!
I guess EclipseLink 2.6.x or 2.5.x is not quite compatible with JPA 2.0.x.
It's confusing, because when I use 2.5.x or higher, those still seem to be working, BESIDES the feature of Query Results Cache.
My persistence.xml looks like bellow now, so I can get log output:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="myprojectname-persistence-unit" transaction-type="JTA">
<jta-data-source>myprojectname-mysql-jdbc-jta-resource</jta-data-source>
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<properties>
<property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.MySQLPlatform"/>
<property name="eclipselink.logging.logger" value="JavaLogger"/>
<!-- The warning log of "Problem while registering MBean: java.lang.NullPointerException" did not go away even if I set bellow 2 propertes -->
<!--
<property name="eclipselink.register.dev.mbean" value="false" />
<property name="eclipselink.register.run.mbean" value="false" />
-->
<property name="eclipselink.cache.shared.default" value="true"/>
<property name="eclipselink.logging.parameters" value="true"/>
<property name="eclipselink.logging.timestamp" value="true"/>
<property name="eclipselink.logging.session" value="true"/>
<property name="eclipselink.logging.thread" value="true"/>
<property name="eclipselink.logging.exceptions" value="true"/>
<property name="eclipselink.logging.level" value="FINEST"/>
</properties>
</persistence-unit>
</persistence>
I'm working on a Swing application with JPA and Hibernate. But every time I try to call following code to get EntityManager
try {
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
EntityManagerFactory emf = Persistence.createEntityManagerFactory("abcd");
EntityManager em = emf.createEntityManager();
I get following exceptions:
Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named abcd: Provider named org.hibernate.jpa.HibernatePersistenceProvider threw unexpected exception at create EntityManagerFactory:
javax.persistence.PersistenceException
javax.persistence.PersistenceException: Unable to build entity manager factory
and
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
Path to persistence.xml is my.jar/meta-inf/persistence.xml
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="abcd" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="hibernate.connection.url" value="xxx"/>
<property name="hibernate.connection.password" value="xxx"/>
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
<property name="hibernate.connection.user" value="xxx"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
</properties>
</persistence-unit>
</persistence>
Dependencies:
All dependencies except junit are in a classpath
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.10.Final</version>
<scope>compile</scope>
</dependency>
It seems, it cannot find your persistence.xml file. The correct folder for the persistence.xml file is META-INF and not meta-inf.
I want to generate a JSON response of my object I write code for that but not getting success it is giving error 406 I am not using maven I am using ant
This is my controller
#Controller
public class LoginRestCtrl {
#RequestMapping(value = "/test", method=RequestMethod.GET)
#ResponseBody
public Employee checklogin(){
Employee e=new Employee();
e.setEmailId("sdosi#cur.com");
e.setId(1);
e.setPassword("a");
return e;
}
}
This is my configuration file
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="com" />
<mvc:annotation-driven />
<bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer" id="tilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver" id="viewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
</bean>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
I am calling as http://localhost:8080/SpringMVC/test but getting error 406
You can try following to produce JSON Rsponse. You would require Gson library, and the controller would look as follows:
#Controller
public class LoginRestCtrl {
#RequestMapping(value = "/test", method=RequestMethod.GET)
#ResponseBody
public String checklogin(){
Employee e=new Employee();
e.setEmailId("sdosi#cur.com");
e.setId(1);
e.setPassword("a");
Gson gson=new Gson();
String jsonResponse=gson.toJson(e);
return jsonResponse;
}
}
Json response looks as following:
{"emailId":"sdosi#cur.com","id":1,"password":"a"}
I suggest to put jackson dependencies in your pom.xml if they are not already there.
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.2.3</version>
</dependency>
If they are already there can you update your RequestMapping with
#RequestMapping(value = "/test", method=RequestMethod.GET, produces = "application/json;charset=utf-8")
This will ensure that we return a response with a json header.
add the following dependencies in your pom.xml file
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.12</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
with in your spring configuration xml files add the following beans
<bean id="jacksonMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="jacksonMessageConverter" />
</list>
</property>
</bean>
now you can use your controller as it is
#Controller
public class LoginRestCtrl {
#RequestMapping(value = "/test", method=RequestMethod.GET)
#ResponseBody
public Employee checklogin() {
Employee e=new Employee();
e.setEmailId("sdosi#cur.com");
e.setId(1);
e.setPassword("a");
return e;
}
}
I'm getting the exception above while running a JUnit/Arquillian test in Eclipse Juno having a #Deployment method like this:
#Deployment
public static Archive<?> createDeployment() throws Exception {
File[] libs = Maven.resolver()
.loadPomFromFile("pom.xml")
.importRuntimeDependencies()
.as(File.class);
WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")
.addClass(Permission.class)
.addClass(PermissionInterface.class)
.addClass(PermissionModel.class)
.addClass(PermissionModelInterface.class)
...
.addAsLibraries(libs)
.addAsResource(
"resources-jbossas-managed/test-persistence.xml",
"META-INF/persistence.xml")
.addAsWebResource(
EmptyAsset.INSTANCE,
ArchivePaths.create("beans.xml"));
System.out.println(war.toString(true));
return war;
}
and a persistence unit described like this:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="talmudDatabaseTest">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>java:/Alpha2Test</jta-data-source>
<properties>
<property name="eclipselink.target-server" value="JBoss" />
<property name="eclipselink.target-database" value="MySQL" />
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.weaving" value="static" />
<property name="eclipselink.logging.level" value="FINEST" />
<property name="eclipselink.deploy-on-startup" value="True" />
<property name="eclipselink.session-event-listener" value="it.cnr.ilc.omega.model.PersistenceEventListener" />
<property name="omega.import-sql" value="false" />
<property name="omega.import-sql.postlogin-filename" value="preconstruct.sql" />
<property name="omega.import-sql.postcreate-filename" value="postconstruct.sql" />
</properties>
</persistence-unit>
</persistence>
The running JBoss 7.1.1 Final instance has been launched with this configuration (on a Macbook Pro):
-server -Xms512m -Xmx1024m -XX:MaxPermSize=512m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true "-Dorg.jboss.boot.log.file=/usr/local/jboss-as-7.1.1.Final/standalone/log/boot.log" "-Dlogging.configuration=file:/usr/local/jboss-as-7.1.1.Final/standalone/configuration/logging.properties" "-Djboss.home.dir=/usr/local/jboss-as-7.1.1.Final" "-Dfile.encoding=UTF-8" "-Djboss.modules.system.pkgs=com.apple.laf,com.apple.laf.resources"
The #Test method isn't even called... the exception is thrown before it, but after the completion of the #Deployment method. Shrinkwrap creates this web archive:
test.war:
/beans.xml
/WEB-INF/
/WEB-INF/lib/
/WEB-INF/lib/atmosphere-compat-tomcat-1.1.0.beta3.jar
/WEB-INF/lib/bcprov-jdk14-1.38.jar
/WEB-INF/lib/jackson-databind-2.0.5.jar
/WEB-INF/lib/bcmail-jdk14-1.38.jar
/WEB-INF/lib/maven-aether-provider-3.0.5.jar
/WEB-INF/lib/shrinkwrap-impl-base-1.1.2.jar
/WEB-INF/lib/jcl-over-slf4j-1.6.4.jar
/WEB-INF/lib/shrinkwrap-resolver-spi-maven-2.0.0-beta-3.jar
/WEB-INF/lib/shrinkwrap-resolver-api-2.0.0-beta-3.jar
/WEB-INF/lib/maven-plugin-registry-2.0.9.jar
/WEB-INF/lib/shrinkwrap-spi-1.1.1.jar
/WEB-INF/lib/maven-model-builder-3.0.5.jar
/WEB-INF/lib/plexus-container-default-1.0-alpha-9-stable-1.jar
/WEB-INF/lib/geronimo-stax-api_1.0_spec-1.0.jar
/WEB-INF/lib/maven-plugin-api-2.0.9.jar
/WEB-INF/lib/poi-3.7.jar
/WEB-INF/lib/bcmail-jdk14-138.jar
/WEB-INF/lib/wagon-http-shared4-2.4.jar
/WEB-INF/lib/bcprov-jdk14-138.jar
/WEB-INF/lib/xmlbeans-2.3.0.jar
/WEB-INF/lib/maven-profile-2.0.9.jar
/WEB-INF/lib/poi-ooxml-schemas-3.7.jar
/WEB-INF/lib/aether-util-1.13.1.jar
/WEB-INF/lib/slf4j-log4j12-1.6.4.jar
/WEB-INF/lib/atmosphere-compat-jbossweb-1.1.0.beta3.jar
/WEB-INF/lib/jackson-core-2.0.5.jar
/WEB-INF/lib/commons-io-1.3.2.jar
/WEB-INF/lib/shrinkwrap-resolver-spi-2.0.0-beta-3.jar
/WEB-INF/lib/log4j-1.2.16.jar
/WEB-INF/lib/commons-digester-2.1.jar
/WEB-INF/lib/itext-2.1.7.js1.jar
/WEB-INF/lib/plexus-interpolation-1.14.jar
/WEB-INF/lib/classworlds-1.1-alpha-2.jar
/WEB-INF/lib/slf4j-simple-1.7.5.jar
/WEB-INF/lib/plexus-utils-2.0.6.jar
/WEB-INF/lib/annotation-detector-3.0.1.jar
/WEB-INF/lib/commons-codec-20041127.091804.jar
/WEB-INF/lib/atmosphere-compat-tomcat7-1.1.0.beta3.jar
/WEB-INF/lib/commons-collections-2.1.jar
/WEB-INF/lib/el-api-2.2.jar
/WEB-INF/lib/jdtcore-3.1.0.jar
/WEB-INF/lib/primefaces-3.5.jar
/WEB-INF/lib/commonj.sdo-2.1.1.v201112051852.jar
/WEB-INF/lib/shrinkwrap-resolver-impl-maven-2.0.0-beta-3.jar
/WEB-INF/lib/eclipselink-staticweave-maven-plugin-1.0.4.jar
/WEB-INF/lib/aether-spi-1.13.1.jar
/WEB-INF/lib/aether-impl-1.13.1.jar
/WEB-INF/lib/stax-api-1.0.1.jar
/WEB-INF/lib/jcommon-1.0.15.jar
/WEB-INF/lib/commons-logging-1.1.1.jar
/WEB-INF/lib/wagon-provider-api-2.4.jar
/WEB-INF/lib/xml-apis-1.4.01.jar
/WEB-INF/lib/plexus-compiler-javac-2.1.jar
/WEB-INF/lib/shrinkwrap-api-1.1.1.jar
/WEB-INF/lib/shrinkwrap-resolver-api-maven-2.0.0-beta-3.jar
/WEB-INF/lib/jsoup-1.6.3.jar
/WEB-INF/lib/plexus-component-api-1.0-alpha-33.jar
/WEB-INF/lib/maven-project-2.0.9.jar
/WEB-INF/lib/shrinkwrap-resolver-impl-maven-archive-2.0.0-beta-3.jar
/WEB-INF/lib/httpcore-4.2.3.jar
/WEB-INF/lib/maven-settings-builder-3.0.5.jar
/WEB-INF/lib/shrinkwrap-resolver-api-maven-archive-2.0.0-beta-3.jar
/WEB-INF/lib/maven-artifact-2.0.9.jar
/WEB-INF/lib/poi-ooxml-3.7.jar
/WEB-INF/lib/wagon-http-lightweight-2.4.jar
/WEB-INF/lib/dom4j-1.6.1.jar
/WEB-INF/lib/jena-core-2.10.0.jar
/WEB-INF/lib/slf4j-api-1.6.4.jar
/WEB-INF/lib/eclipselink-2.4.0.jar
/WEB-INF/lib/aether-connector-wagon-1.13.1.jar
/WEB-INF/lib/xercesImpl-2.10.0.jar
/WEB-INF/lib/castor-1.2.jar
/WEB-INF/lib/jfreechart-1.0.12.jar
/WEB-INF/lib/maven-repository-metadata-3.0.5.jar
/WEB-INF/lib/bctsp-jdk14-1.38.jar
/WEB-INF/lib/jasperreports-fonts-4.0.0.jar
/WEB-INF/lib/shrinkwrap-resolver-spi-maven-archive-2.0.0-beta-3.jar
/WEB-INF/lib/jena-tdb-0.10.0.jar
/WEB-INF/lib/commons-lang3-3.0.1.jar
/WEB-INF/lib/maven-artifact-manager-2.0.9.jar
/WEB-INF/lib/plexus-classworlds-2.4.jar
/WEB-INF/lib/maven-settings-3.0.5.jar
/WEB-INF/lib/commons-beanutils-1.8.0.jar
/WEB-INF/lib/jena-arq-2.10.0.jar
/WEB-INF/lib/httpclient-4.2.3.jar
/WEB-INF/lib/javax.persistence-2.0.4.v201112161009.jar
/WEB-INF/lib/aether-api-1.13.1.jar
/WEB-INF/lib/maven-model-3.0.5.jar
/WEB-INF/lib/atmosphere-runtime-1.1.0.beta3.jar
/WEB-INF/lib/plexus-compiler-api-2.1.jar
/WEB-INF/lib/jena-iri-0.9.5.jar
/WEB-INF/lib/jackson-annotations-2.0.5.jar
/WEB-INF/lib/jasperreports-5.0.0.jar
/WEB-INF/lib/wagon-file-2.4.jar
/WEB-INF/classes/
/WEB-INF/classes/META-INF/
/WEB-INF/classes/META-INF/persistence.xml
/WEB-INF/classes/it/
/WEB-INF/classes/it/cnr/
/WEB-INF/classes/it/cnr/ilc/
/WEB-INF/classes/it/cnr/ilc/omega/
/WEB-INF/classes/it/cnr/ilc/omega/resources/
/WEB-INF/classes/it/cnr/ilc/omega/resources/model/
/WEB-INF/classes/it/cnr/ilc/omega/resources/model/SourceInterface.class
/WEB-INF/classes/it/cnr/ilc/omega/resources/model/Source.class
/WEB-INF/classes/it/cnr/ilc/omega/resources/model/AttachmentInterface.class
/WEB-INF/classes/it/cnr/ilc/omega/resources/model/ResourceType.class
/WEB-INF/classes/it/cnr/ilc/omega/resources/model/ResourceInterface.class
/WEB-INF/classes/it/cnr/ilc/omega/resources/model/Resource.class
/WEB-INF/classes/it/cnr/ilc/omega/resources/model/Attachment.class
/WEB-INF/classes/it/cnr/ilc/omega/resources/model/ResourceTypeInterface.class
/WEB-INF/classes/it/cnr/ilc/omega/access/
/WEB-INF/classes/it/cnr/ilc/omega/access/LoginViewController.class
/WEB-INF/classes/it/cnr/ilc/omega/access/LoginViewControllerInterface.class
/WEB-INF/classes/it/cnr/ilc/omega/access/model/
/WEB-INF/classes/it/cnr/ilc/omega/access/model/Task.class
/WEB-INF/classes/it/cnr/ilc/omega/access/model/Role.class
/WEB-INF/classes/it/cnr/ilc/omega/access/model/Credentials.class
/WEB-INF/classes/it/cnr/ilc/omega/access/model/PermissionModel.class
/WEB-INF/classes/it/cnr/ilc/omega/access/model/TaskInterface.class
/WEB-INF/classes/it/cnr/ilc/omega/access/model/UserInterface.class
/WEB-INF/classes/it/cnr/ilc/omega/access/model/UserModelInterface.class
/WEB-INF/classes/it/cnr/ilc/omega/access/model/TaskModelInterface.class
/WEB-INF/classes/it/cnr/ilc/omega/access/model/PermissionInterface.class
/WEB-INF/classes/it/cnr/ilc/omega/access/model/PermissionModelInterface.class
/WEB-INF/classes/it/cnr/ilc/omega/access/model/User.class
/WEB-INF/classes/it/cnr/ilc/omega/access/model/LogoutEvent.class
/WEB-INF/classes/it/cnr/ilc/omega/access/model/TaskModel.class
/WEB-INF/classes/it/cnr/ilc/omega/access/model/Permission.class
/WEB-INF/classes/it/cnr/ilc/omega/access/model/UserModel.class
/WEB-INF/classes/it/cnr/ilc/omega/model/
/WEB-INF/classes/it/cnr/ilc/omega/model/AbstractEntityModel.class
/WEB-INF/classes/it/cnr/ilc/omega/model/AbstractEntityInterface.class
/WEB-INF/classes/it/cnr/ilc/omega/model/EntityDeleteEvent.class
/WEB-INF/classes/it/cnr/ilc/omega/model/EntityCreateEvent.class
/WEB-INF/classes/it/cnr/ilc/omega/model/EntityUpdateEvent.class
/WEB-INF/classes/it/cnr/ilc/omega/model/AbstractEntityModelInterface.class
/WEB-INF/classes/it/cnr/ilc/omega/model/AbstractEntity$Status.class
/WEB-INF/classes/it/cnr/ilc/omega/model/PersistenceEventListener.class
/WEB-INF/classes/it/cnr/ilc/omega/model/AbstractEntity.class
/WEB-INF/classes/it/cnr/ilc/omega/BaseController.class
/WEB-INF/classes/it/cnr/ilc/omega/Resources.class
/WEB-INF/classes/it/cnr/ilc/omega/reference/
/WEB-INF/classes/it/cnr/ilc/omega/reference/model/
/WEB-INF/classes/it/cnr/ilc/omega/reference/model/Reference.class
/WEB-INF/classes/it/cnr/ilc/omega/reference/model/ReferenceInterface.class
After that, Arquillian adds the archive on the active instance of JBoss, but the deployment can't terminate its operations. I've also managed to raise the memory for the JVM, but it doesn't seem to work. If I remove the libs form the archive, the #Test method is passed correctly, but the Session bean i'd like to inject:
#Inject
LoginViewController loginViewController;
isn't resolved like it should.
Can anyone help to find why the exception occurs? Thanks in advance... any help is appreciated!
.addAsWebResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
should be
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
What's the best way to set HTTP headers (based on filename patterns) in Jetty 6.1? Is it possible via jetty.xml (or jetty-web.xml)? Or do I have to modify web.xml?
You can add headers by configuration. In jetty.xml, put the following example :
<New id="RewriteHandler" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
<Set name="rules">
<Array type="org.eclipse.jetty.rewrite.handler.Rule">
<Item>
<New id="header" class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
<Set name="pattern">*.jsp</Set>
<Set name="name">myheader</Set>
<Set name="value">the value of myheader</Set>
</New>
</Item>
</Array>
</Set>
</New>
<Set name="handler">
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<Item>
<Ref id="RewriteHandler"/>
</Item>
</Array>
</Set>
</New>
</Set>
See RewriteHandler api for more examples of what is possible (it was already available in Jetty 6 RewriteHandler)
For information, here is my maven configuration of jetty plugin :
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.5.v20120716</version>
<configuration>
<jettyXml>${basedir}/src/main/etc/jetty.xml</jettyXml>
</configuration>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<version>8.1.5.v20120716</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-rewrite</artifactId>
<version>8.1.5.v20120716</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
The generic answer to my question is of course this:
<web-app>
<filter>
<filter-name>headersFilter</filter-name>
<filter-class>com.example.MyHeadersFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>headersFilter</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>
...
</web-app>
public class MyHeadersFilter implements Filter {
#Override
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
throws IOException,
ServletException {
final HttpServletRequest httpRequest = (HttpServletRequest) request;
final HttpServletResponse httpResponse = (HttpServletResponse) response;
final String requestUri = httpRequest.getRequestURI();
if (requestUri.matches(...)) {
httpResponse.addHeader(...);
}
chain.doFilter(request, response);
}
}
This should work in any JavaEE web container (and can be made more configurable with <init-param>s).
But isn't there a way to do this purely declaratively in Jetty?
There is a way to adding header in jetty.
using java.lang.instrument and javassist. refer following link for details:
http://hunmr.blogspot.com/2012/12/mock-jetty-behavior-adding-customized.html