[EJB 3.0] - Multiple (different) relations between two entities?
by JoPe
I need to write an EntityBean that holds a collection of EntityBeans of another type plus two single references to EntityBeans of that type. A simple example would be a customer who has a work address and a home address, and a collection of previously used addresses that also need to be stored.
The classes could look like this:
| @Entity
| public class Customer implements Serializable
| {
| private Integer id;
| ...
| private Address homeAddress;
| private Address workAddress;
| private Address[] previousAddresses;
| ...
| @CollectionOfElements
| @IndexColumn(name="index1")
| public Address[] getPreviousAddresses()
| {
| return previousAddresses();
| }
|
| @OneToOne
| public Address getHomeAddress()
| {
| return homeAddress;
| }
|
| @OneToOne
| public Address getWorkAddress()
| {
| return workAddress;
| }
| ...
| }
|
| @Entity
| public class Address implements Serializable
| {
| private Integer id;
| ...
| }
|
However, I could not find any combination of annotations that would persist this setup in a sensible way. All the Addresses always get stored in one table, and I can't find a way to distinguish which address plays which "role" in the customer class when trying to write an SQL query to read them. I would especially like to avoid having to declare a Customer attribute in the Address class, since this would be redundant on the object level and would produce a lot of implementation overhead in my application.
Does anybody know how this can be done? I'm sure I am not the first person running into this need, but unfortunately, all the books, docs and tutorials I found don't cover it.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4161286#4161286
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4161286
17 years, 9 months
[JBossWS] - web service conflicts with jbossws and jaxws
by paramsevak
I used wconsume to auto-generate a webservice client. The client works within eclipse after I remove the jaxws-rt.jar and jaxws-tools.jar from the classpath.
However when I use the same client-code from within an ejb deployed to jboss-4.2.2GA I get the following error. I have tried removing the jaxws-rt.jar and jaxws-tools.jar from the %JBOSS_HOME%/client/ dir but the following error still occurs.
e calling FM. Exception: Failed to create a new SAX parser
14:17:16,557 ERROR [STDERR] org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new SAX parser
14:17:16,557 ERROR [STDERR] at org.jboss.xb.binding.UnmarshallerFactory$UnmarshallerFactoryImpl.newUnmarshaller
(UnmarshallerFactory.java:100)
14:17:16,557 ERROR [STDERR] at org.jboss.ws.metadata.config.JBossWSConfigFactory.parse(JBossWSConfigFactory.jav
a:76)
14:17:16,557 ERROR [STDERR] at org.jboss.ws.metadata.config.JBossWSConfigFactory.getConfig(JBossWSConfigFactory
.java:134)
14:17:16,557 ERROR [STDERR] at org.jboss.ws.metadata.umdm.EndpointMetaData.initEndpointConfig(EndpointMetaData.
java:704)
14:17:16,557 ERROR [STDERR] at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.rebuildEndpointMe
taData(JAXWSClientMetaDataBuilder.java:288)
14:17:16,557 ERROR [STDERR] at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.getPortInternal(ServiceDelegateI
mpl.java:262)
14:17:16,557 ERROR [STDERR] at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.getPort(ServiceDelegateImpl.java
:193)
14:17:16,557 ERROR [STDERR] at javax.xml.ws.Service.getPort(Service.java:116)
14:17:16,557 ERROR [STDERR] at com.cbc.services.salt.fm.TuxedoWebService.getFmservicesFMGWWSHTTPPort(TuxedoWebS
ervice.java:58)
14:17:16,557 ERROR [STDERR] at com.cbc.services.salt.fm.FMInterface.transactFM(FMInterface.java:78)
14:17:16,557 ERROR [STDERR] at com.cbc.isac.ejb20.iccon.IcconBean.tpcall(IcconBean.java:2543)
14:17:16,557 ERROR [STDERR] at com.cbc.isac.ejb20.iccon.IcconBean.getAllConsumerStatements(IcconBean.java:3173)
14:17:16,557 ERROR [STDERR] at com.cbc.isac.ejb20.iccon.IcconBean.getAllActiveStatements(IcconBean.java:701)
14:17:16,557 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
14:17:16,557 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
14:17:16,557 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
14:17:16,557 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
14:17:16,557 ERROR [STDERR] at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
14:17:16,557 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSes
sionContainer.java:237)
14:17:16,557 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedCo
nnectionInterceptor.java:158)
14:17:16,557 ERROR [STDERR] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessio
nInstanceInterceptor.java:169)
14:17:16,557 ERROR [STDERR] at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor
.java:63)
14:17:16,557 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.jav
a:121)
14:17:16,557 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java
:350)
14:17:16,557 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
14:17:16,557 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
14:17:16,557 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
14:17:16,557 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInt
erceptor.java:138)
14:17:16,557 ERROR [STDERR] at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:648)
14:17:16,557 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:960)
14:17:16,557 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
14:17:16,557 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
14:17:16,557 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
14:17:16,557 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
14:17:16,557 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155
)
14:17:16,557 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
14:17:16,557 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
14:17:16,557 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
14:17:16,557 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
14:17:16,557 ERROR [STDERR] at org.jboss.invocation.unified.server.UnifiedInvoker.invoke(UnifiedInvoker.java:23
1)
14:17:16,572 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
14:17:16,572 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
14:17:16,572 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
14:17:16,572 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
14:17:16,572 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155
)
14:17:16,572 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
14:17:16,572 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
14:17:16,572 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
14:17:16,572 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
14:17:16,572 ERROR [STDERR] at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandle
r.java:201)
14:17:16,572 ERROR [STDERR] at $Proxy16.invoke(Unknown Source)
14:17:16,572 ERROR [STDERR] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:769)
14:17:16,572 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.
java:573)
14:17:16,572 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:387)
14:17:16,572 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
14:17:16,572 ERROR [STDERR] Caused by: org.jboss.xb.binding.JBossXBException: Failed to create a new SAX parser
14:17:16,572 ERROR [STDERR] at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.(SaxJBossXBParser.java:96
)
14:17:16,572 ERROR [STDERR] at org.jboss.xb.binding.UnmarshallerImpl.(UnmarshallerImpl.java:55)
14:17:16,572 ERROR [STDERR] at org.jboss.xb.binding.UnmarshallerFactory$UnmarshallerFactoryImpl.newUnmarshaller
(UnmarshallerFactory.java:96)
14:17:16,572 ERROR [STDERR] ... 54 more
14:17:16,572 ERROR [STDERR] Caused by: javax.xml.parsers.ParserConfigurationException: Feature 'http://apache.org/x
ml/features/xinclude' is not recognized.
14:17:16,572 ERROR [STDERR] at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(Unknown Source)
14:17:16,572 ERROR [STDERR] at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.(SaxJBossXBParser.java:92
)
14:17:16,572 ERROR [STDERR] ... 56 more
14:17:16,572 INFO [IcconBean] com.cbc.isac.ejb20.iccon.IcconBean.requestTuxedoService(String, String) - closing tu
xedo connection
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4161276#4161276
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4161276
17 years, 9 months
[JNDI/Naming/Network] - Re: JNDI EJB local lookup is ok, but the bean cannot be invo
by j2ee4cxw
jaikiran:
I made minor change to my deployment. The EJB jar used to be deployed to JBoss 4.2.2GA as jar file. Now it is deployed as exploded tree directory structure. I tested the whole process. Again, for jndi remote lookup, everything is fine, while for jnid local lookup it has run time error. How ever the error is slightly different:
10:13:40,932 INFO [STDOUT] [2008-06-27 10:13:40,932] ERROR (LocalJndiCallAction.java:76) - javax.ejb.EJBException: java.lang.RuntimeException: java.lang.ExceptionInInitializerError
////Here is our jndi.properties file
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost:8080/BessyWeb
/////Here is ServiceLocator.java
public class ServiceLocator {
private ServiceLocator() {
}
public static Object getEJB(String jndiName) {
Object object = null;
try {
InitialContext ctx = new InitialContext();
object = ctx.lookup(jndiName);
} catch (Exception e) {
e.printStackTrace();
}
return object;
}
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4161267#4161267
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4161267
17 years, 9 months