tag:blogger.com,1999:blog-106449775438946661.post1452781131515443141..comments2024-03-19T05:14:38.879-07:00Comments on Overcoming Fear: Spring, Hibernate and JAX-WS WebServices on WeblogicTim Myerhttp://www.blogger.com/profile/01514263555690798238noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-106449775438946661.post-82406532030534281562011-12-22T13:31:28.824-08:002011-12-22T13:31:28.824-08:00Hi Tim,
This is Sam. If I have to run the "S...Hi Tim,<br /><br />This is Sam. If I have to run the "Spring, Hibernate and JAX-WS WebServices on Weblogic" using Spring 3.0.7 framework, what needs to be done? I tired and getting error during the deployment. PLease advise.<br /><br />SamSamhttps://www.blogger.com/profile/04656017060186631748noreply@blogger.comtag:blogger.com,1999:blog-106449775438946661.post-12002130321169180552011-06-15T21:51:44.048-07:002011-06-15T21:51:44.048-07:00Hi Tim
I'm coding the same your example. But i...Hi Tim<br />I'm coding the same your example. But i get error :<br />Caused By: weblogic.wsee.ws.WsException: Two port in the UserServiceService(WebserviceDescriptionBean) has the same name {http://service.core.donriver.com/}UserServicePort. <br /> at weblogic.wsee.deploy.WSEEAnnotationProcessor.checkWsdlPortNames(WSEEAnnotationProcessor.java:143)<br /> at weblogic.wsee.deploy.WSEEAnnotationProcessor.process(WSEEAnnotationProcessor.java:133)<br /> at weblogic.wsee.deploy.WSEEAnnotationProcessor.process(WSEEAnnotationProcessor.java:52)<br /> at weblogic.wsee.deploy.WSEEModule.prepare(WSEEModule.java:111)<br /> at weblogic.wsee.deploy.AppDeploymentExtensionFactory.prepare(AppDeploymentExtensionFactory.java:79)<br /> Truncated. see log file for complete stacktrace<br /><br />Please help me !Web dynamic max level - 8xhttps://www.blogger.com/profile/07358786533640825084noreply@blogger.comtag:blogger.com,1999:blog-106449775438946661.post-9613051671155344442009-11-09T09:34:01.482-08:002009-11-09T09:34:01.482-08:00Thanks for the feedback and for the utility, Cycli...Thanks for the feedback and for the utility, Cycling Beaver!<br />---Tim---Tim Myerhttps://www.blogger.com/profile/01514263555690798238noreply@blogger.comtag:blogger.com,1999:blog-106449775438946661.post-10228629482052209112009-11-04T14:20:48.164-08:002009-11-04T14:20:48.164-08:00Thanks so much! I was using Hibernate to generate...Thanks so much! I was using Hibernate to generate a data access layer that I wanted to expose as web services. I am using Weblogic 10.3, and Workshop. This really helped a lot. I had to create more than one service, so I wrote this little abstract generic class that helped me create multiple web service classes. I thought I'd put it out here in case anyone else might find it useful. Thanks!<br /><br />package com.comcastmediacenter.boss.web.service;<br /><br />import java.util.concurrent.atomic.AtomicReference;<br /><br />import javax.annotation.Resource;<br />import javax.servlet.ServletContext;<br />import javax.xml.ws.WebServiceContext;<br /><br />import org.springframework.web.context.WebApplicationContext;<br />import org.springframework.web.context.support.WebApplicationContextUtils;<br /><br />/**<br /> * Abstract base class for all Spring beans that are<br /> * being exposed as JAXWS web services<br /> * <br /> * @author ldobbi5949k<br /> *<br /> */<br />public abstract class AbstractSpringService<I> {<br /> <br /> @Resource<br /> private WebServiceContext context = null;<br /> private final AtomicReference<I> autoWiredDelegate;<br /> private final String myBeanName;<br /><br /> public AbstractSpringService(String bean) {<br /> autoWiredDelegate = new AtomicReference<I>();<br /> myBeanName = bean;<br /> }<br /> <br /> final I getAutoWiredDelegate() {<br /> final I existingValue = autoWiredDelegate.get();<br /> if (existingValue != null) {<br /> return existingValue;<br /> }<br /> final I newValue = createAutoWiredDelegate();<br /> if (autoWiredDelegate.compareAndSet(null, newValue)) {<br /> return newValue;<br /> }<br /> return autoWiredDelegate.get();<br /> }<br /> <br /> @SuppressWarnings("unchecked")<br /> private I createAutoWiredDelegate() {<br /> final ServletContext servletContext = (ServletContext) context.getMessageContext().get("javax.xml.ws.servlet.context");<br /> final WebApplicationContext webApplicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);<br /> return (I) webApplicationContext.getAutowireCapableBeanFactory().getBean(myBeanName);<br /> }<br />}<br /><br />Here's an instance example:<br /><br />/**<br /> * <br /> */<br />package com.comcastmediacenter.boss.web.service;<br /><br />import java.util.List;<br /><br />import javax.jws.WebParam;<br />import javax.jws.WebResult;<br />import javax.jws.WebService;<br />import javax.jws.soap.SOAPBinding;<br /><br />import com.comcastmediacenter.boss.dto.Account;<br />import com.comcastmediacenter.boss.service.IAccountService;<br /><br />/**<br /> * @author ldobbi5949k<br /> *<br /> */<br />@WebService(name="AccountService", <br /> targetNamespace="http://www.comcastmediacenter.com/Boss",<br /> serviceName="AccountService")<br />@SOAPBinding(style=SOAPBinding.Style.DOCUMENT, use=SOAPBinding.Use.LITERAL,<br /> parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)<br />public class AccountService extends AbstractSpringService<IAccountService> implements<br /> IAccountService {<br /><br /> public AccountService () {<br /> super("AccountService");<br /> }<br /> <br /> /* (non-Javadoc)<br /> * @see com.comcastmediacenter.boss.service.IAccountService#findAccountById(java.lang.Long)<br /> */<br /> @Override<br /> @WebResult(name = "Account")<br /> public Account findAccountById(@WebParam(name="id") Long id) throws Exception {<br /> return getAutoWiredDelegate().findAccountById(id);<br /> }<br />}Cycling Beaverhttps://www.blogger.com/profile/13660810714701091322noreply@blogger.comtag:blogger.com,1999:blog-106449775438946661.post-42673616761083116372009-05-15T09:51:00.000-07:002009-05-15T09:51:00.000-07:00Interesting, personally I don't have much experien...Interesting, personally I don't have much experience with what network admins find acceptable -- so I'm just guessing here.<br /><br />The policy you describe is this: if the JNDI request comes from the local machine, the caller is entitled to the resource. It's not the same as saying: web application X can only access datasource A (it implies that any web application (web or otherwise) hosted on the local machine can access datasource A. It seems (to me) that should be the obvious way to deploy web applications -- but I can't seem to find much evidence of this.<br /><br />The solution I have been trying to put together (but can't quite get my head around) is this:<br /> - define a security-role in my web.xml for my application "MyAppRole"<br /> - have the spring dispatch servlet run as that role using a servlet "run-as" tag:<br /> - In weblogic.xml, Map that DD role to a security principle that the container understands using a "run-as-role-assignment" mapping MySystemRole to a user in the WL security realm MyAppUser.<br /> - put a WL policy constraint on the JNDI tree or datasource that says "require role = MyAppUser"<br /><br />In theory, when my spring controllers need to acquire container resources (like datasources), they will be acting as that principal, and have permission to the datasource.<br /><br />At this point I can't tell if it works, as I have a filter which needs the database. Since I can't put the run-as on the filter, i'm out of luck.Justinhttps://www.blogger.com/profile/01612687657898506940noreply@blogger.comtag:blogger.com,1999:blog-106449775438946661.post-6663055676395372852009-05-14T16:50:00.000-07:002009-05-14T16:50:00.000-07:00Hi Justin,
Thank you for the feedback.
You make a ...Hi Justin,<br />Thank you for the feedback.<br />You make a good point that including database credentials directly in the Spring application context is not a best practice. In production deployments, I have generally used Spring with JNDI to configure datasources without second-guessing by network security admins. Who has access to JNDI can be configured at the network level. If JNDI connections are only available to localhost or to a limited set of addresses, then password protection of the JNDI tree could be overkill.<br />The datasource can be configured in the spring application context similarly to this:<br /><br /><bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <br /> <property name="jndiName" value="my/jndi/name" /> <br /> <property name="jndiEnvironment"> <br /> <props> <br /> <prop key="java.naming.provider.url">t3://localhost:7001</prop> <br /> </props> <br /> </property> <br /></bean><br /><br />I hope that answers your question. If I have misunderstood, please let me know.<br />Thanks.<br />---Tim---Tim Myerhttps://www.blogger.com/profile/01514263555690798238noreply@blogger.comtag:blogger.com,1999:blog-106449775438946661.post-58009467619600822312009-05-14T12:36:00.000-07:002009-05-14T12:36:00.000-07:00Here, you have hardcoded the database password int...Here, you have hardcoded the database password into your spring beans xml. This seems like a common, but poor practice, as changing the DB password requires that the war file must be rebuilt and redeployed.<br /><br />I understand that your article is intended to be 'quick setup', but could you explain how to things the right way (perhaps in another article).<br /><br />The best practice seems to be -- have the spring application lookup its datasource in JNDI. However, this only works with spring if there is no security on the jndi tree or datasource (not realistic).Justinhttps://www.blogger.com/profile/01612687657898506940noreply@blogger.comtag:blogger.com,1999:blog-106449775438946661.post-87127604046760978572008-09-07T16:38:00.000-07:002008-09-07T16:38:00.000-07:00Hi Peter,Thanks very much for the comment and for ...Hi Peter,<BR/>Thanks very much for the comment and for the solution -- it works for me.<BR/>-----Tim-----Tim Myerhttps://www.blogger.com/profile/01514263555690798238noreply@blogger.comtag:blogger.com,1999:blog-106449775438946661.post-56103582967810747202008-09-07T01:21:00.000-07:002008-09-07T01:21:00.000-07:00Thanks for linking to my HSQLDB + BeanShell tip. ...Thanks for linking to my <A HREF="http://ptrthomas.wordpress.com/2006/12/18/how-to-shutdown-hsqldb-from-ant/" REL="nofollow">HSQLDB + BeanShell tip</A>. I was not sure what you meant by the "java.sql.SQLException: Connection is broken" problem so I tried myself to use the Ant <A HREF="http://ant.apache.org/manual/CoreTasks/sql.html" REL="nofollow">SQL Task</A> and I hit the problem straight away. With a little bit of guesswork I found that if you add autocommit="true" the problem is solved.<BR/><BR/>So try this:<BR/><BR/><target name="hsqldb-stop"><BR/> <sql<BR/> classpathref="master-classpath"<BR/> driver="org.hsqldb.jdbcDriver"<BR/> url="${db.url}"<BR/> userid="${db.username}"<BR/> password="${db.password}"<BR/> autocommit="true">SHUTDOWN</sql><BR/></target><BR/><BR/>Let me know if it works and I will update my post as well.Peter Thomashttps://www.blogger.com/profile/12601547950877794218noreply@blogger.com