[JBoss AOP] - Re: Can i have interceptor on throw exception?
by stale.pedersen@jboss.org
yes, you can just add an interceptor that catches exceptions. i made an ejb3 interceptor for a client some time ago that was just a "wrapper" for exceptions. eg, if an exception was thrown the interceptor would catch it, parse it, and then throw a checked in-house exception ( we didnt want the client to be given ejb3 exceptions).
here is a sample of it:
| import javax.interceptor.AroundInvoke;
| import javax.interceptor.InvocationContext;
|
| public class FooSystemExceptionInterceptor
| {
| @AroundInvoke
| public Object intercept(InvocationContext ctx) throws Exception
| {
| long start = System.currentTimeMillis();
| try
| {
| return ctx.proceed();
| }
| catch(RuntimeException re)
| {
| System.out.println("Original Exception:");
| re.printStackTrace();
| throw handleException(re);
| }
| finally
| {
| System.out.println("Facade call "+ctx.getMethod().getName()+" took: "+(System.currentTimeMillis()-start));
| }
| }
|
| private FooSystemException handleException(RuntimeException e)
| {
| ....
| return mySystemException;
| }
|
| }
then you just add this interceptor to the beans you want to intercept. let me know if this solves (or not) your problem :)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4147451#4147451
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4147451
17 years, 11 months
[EJB 3.0] - Re: Setting persistence JNDI name for PersistenceContext
by jaikiran
The @PersistenceContext does not accept an attribute like jndiName, where you could have specified the jndi-name of the entitymanager.
However, i do see a way out. There's a @Resource annotation which accepts a mappedName attribute (which is nothing but the jndi-name of a resource) and also the "type" of the resource. So here's what you can do:
1) Bind the entitymanager to the JNDI. To do this, you have to add the following 2 properties to your persistence.xml:
| <?xml version="1.0" encoding="UTF-8"?>
|
| <persistence xmlns="http://java.sun.com/xml/ns/persistence">
|
| <persistence-unit name="msp-par">
| <jta-data-source>blahblahblah</jta-data-source>
| .....
| .....
| <properties>
| <property name="jboss.entity.manager.jndi.name" value="java:/MyEntityManager"/>
| <property name="jboss.entity.manager.factory.jndi.name" value="java:/MyEntityManagerFactory"/>
| </properties>
| </persistence-unit>
| </persistence>
2) In your bean, inject the persistence context as follows:
| @Resource (type = EntityManager.class, mappedName = "java:/MyEntityManager")
| private EntityManager entityManager;
Does this solve your problem?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4147447#4147447
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4147447
17 years, 11 months
[Clustering/JBoss] - Help me find best solution
by blady
Hi!
Problem:
I have an algorithm works on mathematical data structure (some kind of graph). Data structure is quite big (over 1GB), that is why first i need to load data into memory (it takes a while) and set some conditions for start and end. Generally it is all about tasks and resources.
What I need?
I want to use this algorithm inside JBoss (server-side component) probably best solution will be MDB(if you think I not right it will be great to hear your comment). I don't want to load data into memory every single time. For me best situation is something like shared memory over cluster scope (application scope?). Data in memory is read only and it is very static (it will change twice per year maybe). It will be great to have my bean running in cluster (performance and failover support) with cached data to make it faster. Now I think that if it will be possible to store my data in "cluster memory" best solution for me will be Stateless Session Beans managed by container. Please give some notes to help me find the best way :)
Thanks for supporting!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4147440#4147440
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4147440
17 years, 11 months
[Beginners Corner] - Re: Cant deply an .ear file into the JBOSS.
by leonidMir
Thank you Peter for your reply, you are always willing to help!
Here is my application.xml file:
| <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/ xml/ns/j2ee
| http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
| <display-name>JBoss Notebook ToDo Application</display-name>
| <description>JBoss Notebook ToDo Application</description>
| <module>
| <ejb>todo.jar</ejb>
| </module>
| <module>
| <web>
| <web-uri>todo.war</web-uri>
| <context-root>todo</context-root>
| </web>
| </module>
| </application>
|
I changed the following line to (removed the space):
| xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
|
and now got the following exceptions:
| 10:18:27,218 ERROR [AbstractKernelController] Error installing to Parse: name=vf
| sfile:/C:/jBossDev/JBoss_5_0_0_Beta4/build/output/jboss-5.0.0.Beta4/server/defau
| lt/deploy/todo.ear state=Not Installed mode=Manual requiredState=Parse
| org.jboss.deployers.spi.DeploymentException: Error creating managed object for v
| fsfile:/C:/jBossDev/JBoss_5_0_0_Beta4/build/output/jboss-5.0.0.Beta4/server/defa
| ult/deploy/todo.ear
| at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentExcept
| ion(DeploymentException.java:49)
| at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithO
| utput.createMetaData(AbstractParsingDeployerWithOutput.java:232)
| at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithO
| utput.createMetaData(AbstractParsingDeployerWithOutput.java:199)
| at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithO
| utput.deploy(AbstractParsingDeployerWithOutput.java:162)
| at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(Deployer
| Wrapper.java:169)
| at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFi
| rst(DeployersImpl.java:853)
| at org.jboss.deployers.plugins.deployers.DeployersImpl.install(Deployers
| Impl.java:794)
| at org.jboss.dependency.plugins.AbstractControllerContext.install(Abstra
| ctControllerContext.java:327)
| at org.jboss.dependency.plugins.AbstractController.install(AbstractContr
| oller.java:1309)
| at org.jboss.dependency.plugins.AbstractController.incrementState(Abstra
| ctController.java:734)
| at org.jboss.dependency.plugins.AbstractController.resolveContexts(Abstr
| actController.java:862)
| at org.jboss.dependency.plugins.AbstractController.resolveContexts(Abstr
| actController.java:784)
| at org.jboss.dependency.plugins.AbstractController.change(AbstractContro
| ller.java:622)
| at org.jboss.dependency.plugins.AbstractController.change(AbstractContro
| ller.java:411)
| at org.jboss.deployers.plugins.deployers.DeployersImpl.process(Deployers
| Impl.java:498)
| at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeploye
| rImpl.java:506)
| at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadPr
| ofile(ProfileServiceBootstrap.java:246)
| at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(
| ProfileServiceBootstrap.java:131)
| at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:
| 408)
| at org.jboss.Main.boot(Main.java:208)
| at org.jboss.Main$1.run(Main.java:534)
| at java.lang.Thread.run(Thread.java:619)
| Caused by: org.jboss.xb.binding.JBossXBException: Failed to parse source: cvc-co
| mplex-type.2.4.a: Invalid content was found starting with element 'description'.
| One of '{"http://java.sun.com/xml/ns/j2ee":display-name, "http://java.sun.com/x
| ml/ns/j2ee":icon, "http://java.sun.com/xml/ns/j2ee":module}' is expected. @ *unk
| nown*[6,18]
| at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBPars
| er.java:193)
| at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java
| :153)
| at org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer.parse(Sch
| emaResolverDeployer.java:120)
| at org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer.parse
| (AbstractVFSParsingDeployer.java:86)
| at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithO
| utput.createMetaData(AbstractParsingDeployerWithOutput.java:223)
| ... 20 more
| Caused by: org.xml.sax.SAXException: cvc-complex-type.2.4.a: Invalid content was
| found starting with element 'description'. One of '{"http://java.sun.com/xml/ns
| /j2ee":display-name, "http://java.sun.com/xml/ns/j2ee":icon, "http://java.sun.co
| m/xml/ns/j2ee":module}' is expected. @ *unknown*[6,18]
| at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$MetaDataErrorHandler
| .error(SaxJBossXBParser.java:432)
| at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
| at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
| at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
| at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportE
| rror(Unknown Source)
| at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknow
| n Source)
| at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unkno
| wn Source)
| at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Sou
| rce)
| at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Sourc
| e)
| at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unkn
| own Source)
| at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent
| Dispatcher.dispatch(Unknown Source)
| at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un
| known Source)
| at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
| at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
| at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
| at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
| at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Sour
| ce)
| at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBPars
| er.java:189)
| ... 24 more
|
Can you help :)
btw I am using JBOSS 5 Beta 4.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4147433#4147433
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4147433
17 years, 11 months